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

Circumvent typeof transform for umd build template #10701

Merged
merged 3 commits into from Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";

Object.defineProperty(_exports, "__esModule", {
Expand Down
8 changes: 5 additions & 3 deletions packages/babel-plugin-transform-modules-umd/src/index.js
Expand Up @@ -14,7 +14,9 @@ import { types as t, template } from "@babel/core";
const buildPrerequisiteAssignment = template(`
GLOBAL_REFERENCE = GLOBAL_REFERENCE || {}
`);

// Note: we avoid comparing typeof results with "object" or "symbol" otherwise
// they will be processed by `transform-typeof-symbol`, which in return could
// cause typeof helper used before declaration
const buildWrapper = template(`
(function (global, factory) {
if (typeof define === "function" && define.amd) {
Expand All @@ -28,8 +30,8 @@ const buildWrapper = template(`
GLOBAL_TO_ASSIGN;
}
})(
typeof globalThis === "object" ? globalThis
: typeof self === "object" ? self
typeof globalThis !== "undefined" ? globalThis
: typeof self !== "undefined" ? self
: this,
function(IMPORT_NAMES) {
})
Expand Down
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports);
global.input = mod.exports;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

_exports.__esModule = true;
Expand Down
Expand Up @@ -10,6 +10,6 @@
factory();
global.myCustomModuleName = mod.exports;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function () {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () {
"use strict";
});
Expand Up @@ -10,7 +10,7 @@
factory(mod.exports, global.evens);
global.input = mod.exports;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports, _evens) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_fooBar, _fooBar2, _fizzbuzz) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (foo) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_foo, _fooBar, _fooBar2) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_foo, _fooBar, _fooBar2) {
"use strict";
});
Expand Up @@ -11,7 +11,7 @@
global.foo = global.foo || {};
global.foo.bar = mod.exports;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? 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;
}
})(typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : this, function (_exports) {
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
"use strict";

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

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

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

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

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