Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Zone.js browser bundle pollutes global namespace #456

Closed
ggoodman opened this issue Sep 19, 2016 · 7 comments
Closed

Zone.js browser bundle pollutes global namespace #456

ggoodman opened this issue Sep 19, 2016 · 7 comments
Assignees

Comments

@ggoodman
Copy link

The browser.ts file (https://github.com/angular/zone.js/blob/master/lib/browser/browser.ts) is not being bundled inside any closure, resulting in all of its top-level functions and variables becoming globals.

This was discovered because this behaviour was breaking Plunker's preview by overriding window.name to alert. Down the rabbit hole we go and find ourselves here.

@juliemr
Copy link
Member

juliemr commented Sep 19, 2016

We're also seeing this issue causing problems with Protractor since we rely on window.name there as well.

@juliemr
Copy link
Member

juliemr commented Sep 19, 2016

See also #452

@ggoodman
Copy link
Author

@juliemr this is, indeed a duplicate. Sorry about that. Feel free to close one and track it one place or the other.

@juliemr
Copy link
Member

juliemr commented Sep 19, 2016

I think this one is more general, I'll close the other.

@juliemr
Copy link
Member

juliemr commented Sep 19, 2016

I'm pretty sure this was due to the swap from webpack to rollup for bundling. The suggested fix is to go back to having everything execute in a closure, I'm trying to figure out how to do that with rollup.

juliemr added a commit to juliemr/zone.js that referenced this issue Sep 19, 2016
This means that we will stop polluting the global namespace when
zone.js is included.

Fixes angular#456
juliemr added a commit to juliemr/zone.js that referenced this issue Sep 19, 2016
This means that we will stop polluting the global namespace when
zone.js is included.

Fixes angular#456
juliemr added a commit that referenced this issue Sep 19, 2016
This means that we will stop polluting the global namespace when
zone.js is included.

Fixes #456
@juliemr
Copy link
Member

juliemr commented Sep 20, 2016

This is now fixed in the latest release.

@ocombe
Copy link
Contributor

ocombe commented Sep 20, 2016

Awesome, this also fixed my problem: I had an error message of ERROR in [default] C:\[...]\node_modules\typescript\lib\lib.d.ts:18448:14 Cannot redeclare block-scoped variable 'name'. with typescript 2.0.2 and awesome-typescript-loader for webpack, I updated and the error disappeared :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants