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

Extend UMD loader to use globalThis #3666

Closed
frank-dspeed opened this issue Jul 10, 2020 · 4 comments · Fixed by #3691
Closed

Extend UMD loader to use globalThis #3666

frank-dspeed opened this issue Jul 10, 2020 · 4 comments · Fixed by #3691

Comments

@frank-dspeed
Copy link
Contributor

Expected Behavior / Situation

Actual Behavior / Situation

(function (global, factory) {
   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
   typeof define === 'function' && define.amd ? define(factory) :
   (global = global || self, global.myBundle = factory());
}(this, (function () { 'use strict';
 /* code */
})));

Modification Proposal

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
/**
(global = global || self, global.myBundle = factory());
needs refactor
*/
}(this, (function () { 'use strict';
/
code */
})));

@lukastaegert
Copy link
Member

What are environments that support neither this nor self but do not throw when either is accessed? globalThis seems like it makes sense here but it is only supported in rather new environments. The question is also how big do we really want to make the already rather bulky wrapper?

So what is your use case, i.e. the environment that requires that and does not work with the existing wrapper?

@frank-dspeed
Copy link
Contributor Author

@lukastaegert I agree the environments are GraalJS, Deno while deno will probally fix that via bundling inside parcel but for beeing technical correct i think this is the right step todo as all new environments will use globalThis and it works in browsers and node so i think this is the way to go as it is the standard for exact that problem

@lukastaegert
Copy link
Member

I believe #3691 would fix this sufficiently?

@frank-dspeed
Copy link
Contributor Author

@lukastaegert it looks like for me at last i did only execute the code in my head but i think it does at last the most importent thing. All Tests that i did execute in my head did pass so LGTM+1 for #3691

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

Successfully merging a pull request may close this issue.

2 participants