This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+17 -9
View File
@@ -37,16 +37,20 @@ const buildWrapper = (0, _core.template)(`
`);
var _default = (0, _helperPluginUtils.declare)((api, options) => {
var _api$assumption, _api$assumption2;
api.assertVersion(7);
const {
globals,
exactGlobals,
loose,
allowTopLevelThis,
strict,
strictMode,
noInterop
noInterop,
importInterop
} = options;
const constantReexports = (_api$assumption = api.assumption("constantReexports")) != null ? _api$assumption : options.loose;
const enumerableModuleMeta = (_api$assumption2 = api.assumption("enumerableModuleMeta")) != null ? _api$assumption2 : options.loose;
function buildBrowserInit(browserGlobals, exactGlobals, filename, moduleName) {
const moduleNameOrBasename = moduleName ? moduleName.value : (0, _path.basename)(filename, (0, _path.extname)(filename));
@@ -101,17 +105,21 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
exit(path) {
if (!(0, _helperModuleTransforms.isModule)(path)) return;
const browserGlobals = globals || {};
let moduleName = (0, _helperModuleTransforms.getModuleName)(this.file.opts, options);
if (moduleName) moduleName = _core.types.stringLiteral(moduleName);
const moduleName = (0, _helperModuleTransforms.getModuleName)(this.file.opts, options);
let moduleNameLiteral;
if (moduleName) moduleNameLiteral = _core.types.stringLiteral(moduleName);
const {
meta,
headers
} = (0, _helperModuleTransforms.rewriteModuleStatementsAndPrepareHeader)(path, {
loose,
constantReexports,
enumerableModuleMeta,
strict,
strictMode,
allowTopLevelThis,
noInterop
noInterop,
importInterop,
filename: this.file.opts.filename
});
const amdArgs = [];
const commonjsArgs = [];
@@ -142,7 +150,7 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
}
}
headers.push(...(0, _helperModuleTransforms.buildNamespaceInitStatements)(meta, metadata, loose));
headers.push(...(0, _helperModuleTransforms.buildNamespaceInitStatements)(meta, metadata, constantReexports));
}
(0, _helperModuleTransforms.ensureStatementsHoisted)(headers);
@@ -154,12 +162,12 @@ var _default = (0, _helperPluginUtils.declare)((api, options) => {
path.node.directives = [];
path.node.body = [];
const umdWrapper = path.pushContainer("body", [buildWrapper({
MODULE_NAME: moduleName,
MODULE_NAME: moduleNameLiteral,
AMD_ARGUMENTS: _core.types.arrayExpression(amdArgs),
COMMONJS_ARGUMENTS: commonjsArgs,
BROWSER_ARGUMENTS: browserArgs,
IMPORT_NAMES: importNames,
GLOBAL_TO_ASSIGN: buildBrowserInit(browserGlobals, exactGlobals, this.filename || "unknown", moduleName)
GLOBAL_TO_ASSIGN: buildBrowserInit(browserGlobals, exactGlobals, this.filename || "unknown", moduleNameLiteral)
})])[0];
const umdFactory = umdWrapper.get("expression.arguments")[1].get("body");
umdFactory.pushContainer("directives", directives);