Lazy-initialize external helper template.
This commit is contained in:
parent
dffcef785a
commit
600106b9cb
@ -3,19 +3,22 @@ import generator from "@babel/generator";
|
|||||||
import template from "@babel/template";
|
import template from "@babel/template";
|
||||||
import * as t from "@babel/types";
|
import * as t from "@babel/types";
|
||||||
|
|
||||||
const buildUmdWrapper = template(`
|
// Wrapped to avoid wasting time parsing this when almost no-one uses
|
||||||
(function (root, factory) {
|
// build-external-helpers.
|
||||||
if (typeof define === "function" && define.amd) {
|
const buildUmdWrapper = replacements =>
|
||||||
define(AMD_ARGUMENTS, factory);
|
template`
|
||||||
} else if (typeof exports === "object") {
|
(function (root, factory) {
|
||||||
factory(COMMON_ARGUMENTS);
|
if (typeof define === "function" && define.amd) {
|
||||||
} else {
|
define(AMD_ARGUMENTS, factory);
|
||||||
factory(BROWSER_ARGUMENTS);
|
} else if (typeof exports === "object") {
|
||||||
}
|
factory(COMMON_ARGUMENTS);
|
||||||
})(UMD_ROOT, function (FACTORY_PARAMETERS) {
|
} else {
|
||||||
FACTORY_BODY
|
factory(BROWSER_ARGUMENTS);
|
||||||
});
|
}
|
||||||
`);
|
})(UMD_ROOT, function (FACTORY_PARAMETERS) {
|
||||||
|
FACTORY_BODY
|
||||||
|
});
|
||||||
|
`(replacements);
|
||||||
|
|
||||||
function buildGlobal(whitelist) {
|
function buildGlobal(whitelist) {
|
||||||
const namespace = t.identifier("babelHelpers");
|
const namespace = t.identifier("babelHelpers");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user