pr comments
This commit is contained in:
parent
4b499b0429
commit
f212d3c30e
|
@ -439,7 +439,7 @@ class RuntimeTemplate {
|
|||
});
|
||||
getModuleFunction = this.basicFunction(
|
||||
"",
|
||||
`${header}return ${rawModule}`
|
||||
`${header}return ${rawModule};`
|
||||
);
|
||||
} else {
|
||||
runtimeRequirements.add(RuntimeGlobals.require);
|
||||
|
@ -450,7 +450,7 @@ class RuntimeTemplate {
|
|||
if (header) {
|
||||
const returnExpression = `${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, 1)`;
|
||||
getModuleFunction = header
|
||||
? this.basicFunction("", `${header}return ${returnExpression}`)
|
||||
? this.basicFunction("", `${header}return ${returnExpression};`)
|
||||
: this.returningFunction(returnExpression);
|
||||
} else {
|
||||
getModuleFunction = `${RuntimeGlobals.createFakeNamespaceObject}.bind(__webpack_require__, ${comment}${idExpr}, 1)`;
|
||||
|
@ -460,7 +460,7 @@ class RuntimeTemplate {
|
|||
if (header) {
|
||||
const returnExpression = `${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, 3)`;
|
||||
getModuleFunction = header
|
||||
? this.basicFunction("", `${header}return ${returnExpression}`)
|
||||
? this.basicFunction("", `${header}return ${returnExpression};`)
|
||||
: this.returningFunction(returnExpression);
|
||||
} else {
|
||||
getModuleFunction = `${RuntimeGlobals.createFakeNamespaceObject}.bind(__webpack_require__, ${comment}${idExpr}, 3)`;
|
||||
|
@ -470,7 +470,7 @@ class RuntimeTemplate {
|
|||
if (header) {
|
||||
const returnExpression = `${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, 7)`;
|
||||
getModuleFunction = header
|
||||
? this.basicFunction("", `${header}return ${returnExpression}`)
|
||||
? this.basicFunction("", `${header}return ${returnExpression};`)
|
||||
: this.returningFunction(returnExpression);
|
||||
} else {
|
||||
getModuleFunction = `${RuntimeGlobals.createFakeNamespaceObject}.bind(__webpack_require__, ${comment}${idExpr}, 7)`;
|
||||
|
|
|
@ -578,10 +578,7 @@ class JavascriptModulesPlugin {
|
|||
const innerStrict = !allStrict && m.buildInfo.strict;
|
||||
const iife = innerStrict || inlinedModules.size > 1 || chunkModules;
|
||||
if (iife) {
|
||||
if (
|
||||
!runtimeRequirements.has(RuntimeGlobals.thisAsExports) &&
|
||||
runtimeTemplate.supportsArrowFunction()
|
||||
) {
|
||||
if (runtimeTemplate.supportsArrowFunction()) {
|
||||
source.add("(() => {\n");
|
||||
if (innerStrict) source.add('"use strict";\n');
|
||||
source.add(renderedModule);
|
||||
|
|
|
@ -60,6 +60,7 @@ class NodeTemplatePlugin {
|
|||
if (onceForChunkSet.has(chunk)) return;
|
||||
onceForChunkSet.add(chunk);
|
||||
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
||||
set.add(RuntimeGlobals.hasOwnProperty);
|
||||
compilation.addRuntimeModule(chunk, new ChunkLoadingRuntimeModule(set));
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
|||
constructor(runtimeRequirements) {
|
||||
super("readFile chunk loading", 10);
|
||||
this.runtimeRequirements = runtimeRequirements;
|
||||
this.runtimeRequirements.add(RuntimeGlobals.hasOwnProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,6 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
|||
constructor(runtimeRequirements) {
|
||||
super("require chunk loading", 10);
|
||||
this.runtimeRequirements = runtimeRequirements;
|
||||
this.runtimeRequirements.add(RuntimeGlobals.hasOwnProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,9 +17,9 @@ class GlobalRuntimeModule extends RuntimeModule {
|
|||
* @returns {string} runtime code
|
||||
*/
|
||||
generate() {
|
||||
const { runtimeTemplate } = this.compilation;
|
||||
return Template.asString([
|
||||
`${RuntimeGlobals.global} = ${runtimeTemplate.iife("", [
|
||||
`${RuntimeGlobals.global} = (function() {`,
|
||||
Template.indent([
|
||||
"if (typeof globalThis === 'object') return globalThis;",
|
||||
"try {",
|
||||
Template.indent(
|
||||
|
@ -38,7 +38,8 @@ class GlobalRuntimeModule extends RuntimeModule {
|
|||
// We return `undefined`, instead of nothing here, so it's
|
||||
// easier to handle this case:
|
||||
// if (!global) { … }
|
||||
])};`
|
||||
]),
|
||||
"})();"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue