-
Notifications
You must be signed in to change notification settings - Fork 217
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
“global is not defined” when attempting to consume in Angular/Webpack (using Angular CLI) #455
Comments
Hi @poke , Thanks for writing in. I will take a look and get back to you. Thanks, Manjesh Malavalli |
Hey @manjeshbhargav, did you have a chance to look into this problem yet? |
Hi @poke , Sorry for the delay. According to this comment, they have stopped polyfilling Node "globals" in Angular. However, you can do it yourself by adding this line at the end of your (window as any).global = window; Please let me know if this works for you. Thanks, Manjesh Malavalli |
Yeah, that workaround works for me. Since originally posting the issue, I also have been able to work around this with a TypeScript path mapping to the Are there any plans to fix this within the library though? There is no |
@poke , I think it is a reasonable expectation that any framework that supports UMD-style modules should polyfill According to this, Webpack does polyfill Having said that, we will refactor how we determine the global context soon. Please watch this space for updates. Thanks, Manjesh Malavalli |
Hm, not sure that I would agree that this is related to UMD since But thanks for your response, I’m looking forward to the changes! |
Any updates on this issue? I have just started integrating |
… twilio-video package. Here's a link to a forum post that talks about this weird error and the fix: twilio/twilio-video.js#455 (comment)
I am getting a “global is not defined” reference error when attempting to integrate the project into an Angular application. The error is caused by the use of
global
ininsightspublisher/index.js
but I would expect the same error to also occur from thesip.js
file.The way the sources expect a global
global
makes this difficult to use the library in certain build environments that do not provide this as part of the bundling process. Webpack in particular does not do this. Instead, Webpack puts the compiled modules into a closure that looks approximately like this:As you can see, there’s no
global
being provided.Steps to reproduce:
ng new
with a current Angular CLI (7.0.3)npm i --save twilio-video
to install the dependencyapp.component.ts
:ng serve
Workaround
A possible workaround would be to import the bundle instead from
twilio-video/dist/twilio-video
. This changes the import name though, prevents@types/twilio-video
from matching, and is generally less efficient as this will now bundle a bundle.The text was updated successfully, but these errors were encountered: