-
Notifications
You must be signed in to change notification settings - Fork 10
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
caught ReferenceError: global is not defined #2
Comments
Thanks for the report. I've generally found myself making a similar polyfill in most angular projects for one reason or another, but agree with the reasoning behind the comment you linked. Based on the stack trace it's coming from a deeply nested dependency, so there may not be a lot I can do, but I'll investigate and at the least add a note to the readme if it's not practical to patch the underlying dependency. I wouldn't feel comfortable adding such a polyfill to the library itself, as that feels a bit presumptuous to do in a library |
Thanks @mnahkies. I saw that too. Just thought I'd reach out in any case. |
I've had a more detailed investigation into this, and it's actually quite a tricky situation. The issueLooking at the https://github.com/feross/buffer repository, you'll notice that the bug is present in the 4.x branch, but not master - it's fixed on I made a new project, and then did:
So you can see, that the For whatever reason webpack chooses to bundle up the old v4 version instead of the v5 version that our dependency actually wants. Ideally the angular team would update angular to use However this seems a bit of a band aid solution, as the current way that the angular/webpack bundling is working seems to completely preclude the ability to have two libraries in the dependency tree that depend on incompatible library versions co-exist correctly. I don't know enough about webpack configuration to know if this is a problem that can be solved through tweaks there, but bottom line is that angular 9 still depends on webpack 4 and so this specific problem won't be going away by itself in a hurry. Possibly related webpack issue: webpack/webpack#9739 WorkaroundsI can see two different workarounds, each with pro's/con's. I'll go ahead and document these on the readme and then close this issue. Define
|
Closing as per above comment. Note that with some further observation I've found that it doesn't affect every project, seems to be a bit of luck involved as to how the node modules directory structure ends up looking - deleting |
Note that webpack@5 is still in beta (as of 2020 02 20) |
Great library!
For some reason, today ng-qrcode failed with a big fat error.
I did some Googling and found:
global is not available as of Angular 6.
Library authors should not depend on this property. See this post: angular/angular-cli#9827 (comment)
As a workaround for now, I am putting this is my polyfills.ts
(window as any).global = window;
The text was updated successfully, but these errors were encountered: