Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zone.js: zone lost inside requireJS (AMD) module #38516

Closed
mblout opened this issue Aug 18, 2020 · 7 comments
Closed

zone.js: zone lost inside requireJS (AMD) module #38516

mblout opened this issue Aug 18, 2020 · 7 comments
Assignees
Labels
area: zones P2 The issue is important to a large percentage of users, with a workaround regression Indicates than the issue relates to something that worked in a previous version state: confirmed type: bug/fix
Milestone

Comments

@mblout
Copy link

mblout commented Aug 18, 2020

🐞 bug report

Affected Package

The issue is caused by package @angular/packages/zone.js

Is this a regression?

Yes, worked in 0.9.1

Description

When loading modules using requireJS, the zone is lost.

🔬 Minimal Reproduction

The following in index.html, which should also include zone.js


  <script src="zone.js"></script>
  <script src="../node_modules/requirejs/require.js"></script>
  <script>
  function testOne () {
    Zone.current.fork({name:'one-zone'})
      .run(() => new Promise((resolve) => {
        // load one.js
        requirejs(['one'], (one) => {
          one();
          resolve(one);
        });
      }));
  }

  // bootstrap
  Zone.current.fork({ name: 'main' }).run(testOne);
  </script>
`

the entire contents of one.js, in the same folder of index.html


console.log('outside module "one" : ' + window.Zone.current.name); 
define(() => {
    console.log('module "one": ' + window.Zone.current.name); 
    return () => {
        console.log('module "one" function: ' + window.Zone.current.name); 
    }
});

In 0.10.X, all three console.logs report the name of the zone as the <root>, and not my one-zone.

With 0.9.1, I see the following:

outside module "one" : <root>
module "one": one-zone
module "one" function: one-zone

🌍 Your Environment

Angular Version:


angular: 10.1.0-next.6
zone.js: 0.10.3
requirejs: 2.3.6
@ngbot ngbot bot added this to the needsTriage milestone Aug 18, 2020
@JiaLiPassion JiaLiPassion self-assigned this Aug 19, 2020
@JiaLiPassion JiaLiPassion added type: bug/fix regression Indicates than the issue relates to something that worked in a previous version state: confirmed labels Aug 19, 2020
JiaLiPassion added a commit to JiaLiPassion/angular that referenced this issue Aug 19, 2020
…es field

Close angular#38526, angular#38516, angular#38513

After update to `APF`, the `directories` and `files` options are not compatible,
so we need to remove those fileds to make sure everything work as expected.
atscott pushed a commit that referenced this issue Aug 19, 2020
…es field (#38528)

Close #38526, #38516, #38513

After update to `APF`, the `directories` and `files` options are not compatible,
so we need to remove those fileds to make sure everything work as expected.

PR Close #38528
@JoostK
Copy link
Member

JoostK commented Aug 19, 2020

@JiaLiPassion I don't think this is related to the NPM package being corrupt, as this was reported before 0.11.0 was released and the issue description mentions it occurs in 0.10.3.

@JiaLiPassion
Copy link
Contributor

@JoostK, yes you are right, I will check the issue again.

@mhevery
Copy link
Contributor

mhevery commented Aug 19, 2020

@mhevery mhevery closed this as completed Aug 19, 2020
@JiaLiPassion
Copy link
Contributor

I put wrong issue number to associate with this issue, reopen it to do more investigation.

@JiaLiPassion JiaLiPassion reopened this Aug 19, 2020
subratpalhar92 pushed a commit to SUBRATPALHAR-ALL-JAVASCRIPT/angular that referenced this issue Aug 29, 2020
…es field (angular#38528)

Close angular#38526, angular#38516, angular#38513

After update to `APF`, the `directories` and `files` options are not compatible,
so we need to remove those fileds to make sure everything work as expected.

PR Close angular#38528
subratpalhar92 pushed a commit to SUBRATPALHAR-ALL-JAVASCRIPT/angular that referenced this issue Aug 31, 2020
…es field (angular#38528)

Close angular#38526, angular#38516, angular#38513

After update to `APF`, the `directories` and `files` options are not compatible,
so we need to remove those fileds to make sure everything work as expected.

PR Close angular#38528
profanis pushed a commit to profanis/angular that referenced this issue Sep 5, 2020
…es field (angular#38528)

Close angular#38526, angular#38516, angular#38513

After update to `APF`, the `directories` and `files` options are not compatible,
so we need to remove those fileds to make sure everything work as expected.

PR Close angular#38528
@jelbourn jelbourn added the P2 The issue is important to a large percentage of users, with a workaround label Oct 1, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Oct 1, 2020
@JiaLiPassion
Copy link
Contributor

@mblout , I tried the code with zone.js 0.10.3 and 0.11.2 the result is the same with 0.9.1, all output

outside module "one" : <root>
module "one": one-zone
module "one" function: one-zone

could you check it again?

@mblout
Copy link
Author

mblout commented Oct 20, 2020

thanks for checking; yes, I see what you see;
i can't explain why i saw different behavior with the same test before, other than ...I goofed somehow? I'll close (and re-open iff needed).

@mblout mblout closed this as completed Oct 20, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: zones P2 The issue is important to a large percentage of users, with a workaround regression Indicates than the issue relates to something that worked in a previous version state: confirmed type: bug/fix
Projects
None yet
Development

No branches or pull requests

6 participants