Circumvent typeof transform for umd build template (#10701)

* add test case

* fix: circumvent typeof transform

* chore: update test fixtures
This commit is contained in:
Huáng Jùnliàng
2019-11-13 16:47:56 -05:00
committed by Nicolò Ribaudo
parent 433b6ba3a4
commit e1839e5ec9
98 changed files with 136 additions and 101 deletions

View File

@@ -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) {
@@ -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) {
})