Skip to content

Commit

Permalink
Changes UMD callsite to be more likely to pass in the intended… (#10477)
Browse files Browse the repository at this point in the history
* Changes UMD callsite to be more likely to pass in the intended object.

Fixes #10476
Note: This PR should be considered pseudocode and used as an illustration of the proposed fix.  I do not know nearly enough about this project to know if this is an appropriate solution to the problem, nor do I have the confidence to update the tests appropriately.

* Update tests
  • Loading branch information
MicahZoltu authored and nicolo-ribaudo committed Oct 29, 2019
1 parent 143d159 commit 198b4a0
Show file tree
Hide file tree
Showing 95 changed files with 103 additions and 95 deletions.
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

Object.defineProperty(_exports, "__esModule", {
Expand Down
6 changes: 5 additions & 1 deletion packages/babel-plugin-transform-modules-umd/src/index.js
Expand Up @@ -27,7 +27,11 @@ const buildWrapper = template(`
GLOBAL_TO_ASSIGN;
}
})(this, function(IMPORT_NAMES) {
})(
typeof globalThis === "object" ? globalThis
: typeof self === "object" ? self
: this,
function(IMPORT_NAMES) {
})
`);

Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.foo);
global.input = mod.exports;
}
})(this, function (_exports, _foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _foo) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.foo);
global.input = mod.exports;
}
})(this, function (_exports, _foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _foo) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.foo);
global.input = mod.exports;
}
})(this, function (_exports, _foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _foo) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.foo);
global.input = mod.exports;
}
})(this, function (_exports, _foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _foo) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.foo);
global.input = mod.exports;
}
})(this, function (_exports, _foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _foo) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.foo);
global.input = mod.exports;
}
})(this, function (_exports, _foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _foo) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,6 +10,6 @@
factory();
global.myCustomModuleName = mod.exports;
}
})(this, function () {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function () {
"use strict";
});
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.evens);
global.input = mod.exports;
}
})(this, function (_exports, _evens) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _evens) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.foo);
global.input = mod.exports;
}
})(this, function (_foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo) {
"use strict";

_foo = babelHelpers.interopRequireDefault(_foo);
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.fooBAR, global.fooBAR, global.fizzBuzz);
global.input = mod.exports;
}
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
"use strict";

_fooBar = babelHelpers.interopRequireDefault(_fooBar);
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.fooBar, global.fooBar, global.fizzbuzz);
global.input = mod.exports;
}
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
"use strict";

_fooBar = babelHelpers.interopRequireDefault(_fooBar);
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.fooBAR, global.mylib.fooBar, global.fizz.buzz);
global.input = mod.exports;
}
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
"use strict";

_fooBar = babelHelpers.interopRequireDefault(_fooBar);
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.fooBar, global.mylibFooBar, global.fizzbuzz);
global.input = mod.exports;
}
})(this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
"use strict";

_fooBar = babelHelpers.interopRequireDefault(_fooBar);
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.foo);
global.input = mod.exports;
}
})(this, function (foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (foo) {
"use strict";

foo = babelHelpers.interopRequireWildcard(foo);
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.foo);
global.input = mod.exports;
}
})(this, function (_foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo) {
"use strict";

_foo = babelHelpers.interopRequireWildcard(_foo);
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(global.foo);
global.input = mod.exports;
}
})(this, function (_foo) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo) {
"use strict";

_foo.bar;
Expand Down
Expand Up @@ -10,6 +10,6 @@
factory(global.foo, global.fooBar, global.fooBar);
global.input = mod.exports;
}
})(this, function (_foo, _fooBar, _fooBar2) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo, _fooBar, _fooBar2) {
"use strict";
});
Expand Up @@ -11,7 +11,7 @@
global.foo = global.foo || {};
global.foo.bar = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -13,7 +13,7 @@
global.foo.bar.baz = global.foo.bar.baz || {};
global.foo.bar.baz.qux = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.baz = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory();
global.MyLib = mod.exports;
}
})(this, function () {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function () {
"use strict";

foobar();
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.looseModuleNameWithOverriddenGlobalInput = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory();
global.looseModuleNameInput = mod.exports;
}
})(this, function () {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function () {
"use strict";

foobar();
Expand Down
Expand Up @@ -10,6 +10,6 @@
factory(global.render);
global.input = mod.exports;
}
})(this, function (_render) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_render) {
"use strict";
});
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(this, function (_exports) {
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
"use strict";

_exports.__esModule = true;
Expand Down

0 comments on commit 198b4a0

Please sign in to comment.