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

[bug] 1.4.0 introduces "global is not defined" #218

Closed
jasonmit opened this issue Jun 10, 2019 · 2 comments

Comments

@jasonmit
Copy link

commented Jun 10, 2019

As of 1.4.0, Webpack no longer is polyfilling global.

This was spotted in my CI pipeline for ember-intl. Other users also reported seeing this on other libs that ember-auto-import bundles i.e, auth0-lock.

I believe the issue was introduced here: #216

If node: false is recommended then I'd suggest a new major version and reverted for 1.x branch.

A workaround for now:
ember-intl/ember-intl@f0419f2#diff-168726dbe96b3ce427e7fedce31bb0bc

@ef4

This comment has been minimized.

Copy link
Owner

commented Jun 10, 2019

The problem is that doing a major doesn't really help you. Only one copy of ember-auto-import is allowed to win, and if the app has one, it will be that one. So as soon as apps upgrade, ember-intl would break again in the same way.

I do consider #216 a bugfix. Automatically polyfilling node behaviors for the browser was never intentional. global is not valid Javascript in browsers. I'm sorry this is likely to break things for people who were accidentally relying on the bug.

I agree that the situation with webpack configs is not ideal. Unfortunately they don't compose well, and most settings are extremely global in nature. So it's hard for addons to change settings without having big side effects. But that is why I think it's so important to have defaults that try to adhere as closely as possible to web standards, without sneaking in implementation-defined things like webpack's polyfills.

Thankfully global is quite easy to polyfill directly. Before importing the library that uses global, you can import your own module that says window.global = window.

@jasonmit

This comment has been minimized.

Copy link
Author

commented Jun 10, 2019

Ah, I forgot about the single add-on limitation. Embroider won't suffer from this, correct? It sounds like a one off polyfill then is more reliable solution then modifying the unified webpack config.

Thanks a ton for the quick response, feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.