webpack 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/webpack.js +69 -10
- package/lib/APIPlugin.js +2 -2
- package/lib/AmdMainTemplatePlugin.js +4 -6
- package/lib/AsyncDependencyToInitialChunkError.js +1 -3
- package/lib/Compilation.js +8 -4
- package/lib/Compiler.js +7 -10
- package/lib/ContextModule.js +19 -7
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +53 -52
- package/lib/EnvironmentPlugin.js +1 -3
- package/lib/ExternalModule.js +3 -3
- package/lib/HotUpdateChunkTemplate.js +1 -1
- package/lib/JavascriptGenerator.js +7 -7
- package/lib/JavascriptModulesPlugin.js +6 -6
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +343 -340
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/MultiModule.js +4 -1
- package/lib/NoModeWarning.js +23 -21
- package/lib/NormalModule.js +9 -0
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/Parser.js +7 -3
- package/lib/ProgressPlugin.js +231 -231
- package/lib/RecordIdsPlugin.js +2 -2
- package/lib/RuntimeTemplate.js +15 -45
- package/lib/Stats.js +2 -0
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +1 -3
- package/lib/UmdMainTemplatePlugin.js +41 -45
- package/lib/WebAssemblyParser.js +1 -5
- package/lib/WebpackOptionsApply.js +2 -2
- package/lib/WebpackOptionsDefaulter.js +10 -8
- package/lib/WebpackOptionsValidationError.js +6 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +13 -13
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +5 -11
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -6
- package/lib/dependencies/ImportParserPlugin.js +2 -6
- package/lib/dependencies/RequireIncludeDependency.js +1 -1
- package/lib/dependencies/WebpackMissingModule.js +1 -3
- package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +1 -3
- package/lib/optimize/ConcatenatedModule.js +19 -20
- package/lib/optimize/SplitChunksPlugin.js +30 -14
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/web/JsonpChunkTemplatePlugin.js +5 -5
- package/lib/web/JsonpMainTemplatePlugin.js +2 -2
- package/package.json +7 -6
- package/schemas/WebpackOptions.json +23 -16
- package/schemas/ajv.absolutePath.js +1 -1
package/lib/RuntimeTemplate.js
CHANGED
@@ -86,15 +86,11 @@ module.exports = class RuntimeTemplate {
|
|
86
86
|
if (exportsType === "namespace") {
|
87
87
|
return rawModule;
|
88
88
|
} else if (exportsType === "named") {
|
89
|
-
return `Object.assign({/* fake namespace object */}, ${
|
90
|
-
rawModule
|
91
|
-
}, { "default": ${rawModule} })`;
|
89
|
+
return `Object.assign({/* fake namespace object */}, ${rawModule}, { "default": ${rawModule} })`;
|
92
90
|
} else if (strict) {
|
93
91
|
return `Object({ /* fake namespace object */ "default": ${rawModule} })`;
|
94
92
|
} else {
|
95
|
-
return `Object(function() { var module = ${
|
96
|
-
rawModule
|
97
|
-
}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }())`;
|
93
|
+
return `Object(function() { var module = ${rawModule}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }())`;
|
98
94
|
}
|
99
95
|
}
|
100
96
|
|
@@ -120,11 +116,7 @@ module.exports = class RuntimeTemplate {
|
|
120
116
|
header += `var id = ${idExpr}; `;
|
121
117
|
idExpr = "id";
|
122
118
|
}
|
123
|
-
header += `if(!__webpack_require__.m[${
|
124
|
-
idExpr
|
125
|
-
}]) { var e = new Error("Module '" + ${
|
126
|
-
idExpr
|
127
|
-
} + "' is not available (weak dependency)"); e.code = 'MODULE_NOT_FOUND'; throw e; } `;
|
119
|
+
header += `if(!__webpack_require__.m[${idExpr}]) { var e = new Error("Module '" + ${idExpr} + "' is not available (weak dependency)"); e.code = 'MODULE_NOT_FOUND'; throw e; } `;
|
128
120
|
}
|
129
121
|
const rawModule = this.moduleRaw({
|
130
122
|
module,
|
@@ -135,22 +127,14 @@ module.exports = class RuntimeTemplate {
|
|
135
127
|
if (header) {
|
136
128
|
getModuleFunction = `function() { ${header}return ${rawModule}; }`;
|
137
129
|
} else {
|
138
|
-
getModuleFunction = `__webpack_require__.bind(null, ${comment}${
|
139
|
-
idExpr
|
140
|
-
})`;
|
130
|
+
getModuleFunction = `__webpack_require__.bind(null, ${comment}${idExpr})`;
|
141
131
|
}
|
142
132
|
} else if (exportsType === "named") {
|
143
|
-
getModuleFunction = `function() { ${header}var module = ${
|
144
|
-
rawModule
|
145
|
-
}; return Object.assign({/* fake namespace object */}, module, { "default": module }); }`;
|
133
|
+
getModuleFunction = `function() { ${header}var module = ${rawModule}; return Object.assign({/* fake namespace object */}, module, { "default": module }); }`;
|
146
134
|
} else if (strict) {
|
147
|
-
getModuleFunction = `function() { ${
|
148
|
-
header
|
149
|
-
}return { /* fake namespace object */ "default": ${rawModule} }; }`;
|
135
|
+
getModuleFunction = `function() { ${header}return { /* fake namespace object */ "default": ${rawModule} }; }`;
|
150
136
|
} else {
|
151
|
-
getModuleFunction = `function() { ${header}var module = ${
|
152
|
-
rawModule
|
153
|
-
}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }`;
|
137
|
+
getModuleFunction = `function() { ${header}var module = ${rawModule}; return typeof module === "object" && module && module.__esModule ? module : Object.assign({/* fake namespace object */}, typeof module === "object" && module, { "default": module }); }`;
|
154
138
|
}
|
155
139
|
|
156
140
|
return `${promise || "Promise.resolve()"}.then(${getModuleFunction})`;
|
@@ -167,28 +151,18 @@ module.exports = class RuntimeTemplate {
|
|
167
151
|
const optDeclaration = update ? "" : "var ";
|
168
152
|
|
169
153
|
const exportsType = module.buildMeta && module.buildMeta.exportsType;
|
170
|
-
let content = `/* harmony import */ ${optDeclaration}${
|
171
|
-
|
172
|
-
|
154
|
+
let content = `/* harmony import */ ${optDeclaration}${importVar} = __webpack_require__(${comment}${JSON.stringify(
|
155
|
+
module.id
|
156
|
+
)});\n`;
|
173
157
|
|
174
158
|
if (!exportsType && !originModule.buildMeta.strictHarmonyModule) {
|
175
|
-
content += `/* harmony import */ ${optDeclaration}${
|
176
|
-
importVar
|
177
|
-
}_default = /*#__PURE__*/__webpack_require__.n(${importVar});\n`;
|
159
|
+
content += `/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/__webpack_require__.n(${importVar});\n`;
|
178
160
|
}
|
179
161
|
if (exportsType === "named") {
|
180
162
|
if (Array.isArray(module.buildMeta.providedExports))
|
181
|
-
content += `${optDeclaration}${
|
182
|
-
importVar
|
183
|
-
}_namespace = /*#__PURE__*/Object.assign({}, ${
|
184
|
-
importVar
|
185
|
-
}, {"default": ${importVar}});\n`;
|
163
|
+
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/Object.assign({}, ${importVar}, {"default": ${importVar}});\n`;
|
186
164
|
else
|
187
|
-
content += `${optDeclaration}${
|
188
|
-
importVar
|
189
|
-
}_namespace = /*#__PURE__*/{ /* fake namespace object */ "default": ${
|
190
|
-
importVar
|
191
|
-
} };\n`;
|
165
|
+
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/{ /* fake namespace object */ "default": ${importVar} };\n`;
|
192
166
|
}
|
193
167
|
return content;
|
194
168
|
}
|
@@ -223,13 +197,9 @@ module.exports = class RuntimeTemplate {
|
|
223
197
|
return "/* non-default import from non-esm module */undefined";
|
224
198
|
} else if (!exportName) {
|
225
199
|
if (asiSafe) {
|
226
|
-
return `/*#__PURE__*/{ /* fake namespace object */ "default": ${
|
227
|
-
importVar
|
228
|
-
} }`;
|
200
|
+
return `/*#__PURE__*/{ /* fake namespace object */ "default": ${importVar} }`;
|
229
201
|
} else {
|
230
|
-
return `/*#__PURE__*/Object({ /* fake namespace object */ "default": ${
|
231
|
-
importVar
|
232
|
-
} })`;
|
202
|
+
return `/*#__PURE__*/Object({ /* fake namespace object */ "default": ${importVar} })`;
|
233
203
|
}
|
234
204
|
}
|
235
205
|
}
|
package/lib/Stats.js
CHANGED
package/lib/Template.js
CHANGED
@@ -118,7 +118,7 @@ module.exports = class Template {
|
|
118
118
|
if (minId > module.id) minId = module.id;
|
119
119
|
}
|
120
120
|
if (minId < 16 + ("" + minId).length) {
|
121
|
-
// add minId x ',' instead of 'Array(minId).concat(
|
121
|
+
// add minId x ',' instead of 'Array(minId).concat(…)'
|
122
122
|
minId = 0;
|
123
123
|
}
|
124
124
|
var objectOverhead = modules
|
@@ -81,9 +81,7 @@ const replacePathVariables = (path, data) => {
|
|
81
81
|
REGEXP_CONTENTHASH_FOR_TEST.test(path))
|
82
82
|
) {
|
83
83
|
throw new Error(
|
84
|
-
`Cannot use [chunkhash] or [contenthash] for chunk in '${
|
85
|
-
path
|
86
|
-
}' (use [hash] instead)`
|
84
|
+
`Cannot use [chunkhash] or [contenthash] for chunk in '${path}' (use [hash] instead)`
|
87
85
|
);
|
88
86
|
}
|
89
87
|
|
@@ -114,9 +114,7 @@ class UmdMainTemplatePlugin {
|
|
114
114
|
)})${accessorToObjectAccess(request.slice(1))}`;
|
115
115
|
} else expr = `require(${JSON.stringify(request)})`;
|
116
116
|
if (m.optional) {
|
117
|
-
expr = `(function webpackLoadOptionalExternalModule() { try { return ${
|
118
|
-
expr
|
119
|
-
}; } catch(e) {} }())`;
|
117
|
+
expr = `(function webpackLoadOptionalExternalModule() { try { return ${expr}; } catch(e) {} }())`;
|
120
118
|
}
|
121
119
|
return expr;
|
122
120
|
})
|
@@ -143,13 +141,11 @@ class UmdMainTemplatePlugin {
|
|
143
141
|
const factoryArguments =
|
144
142
|
requiredExternals.length > 0
|
145
143
|
? externalsArguments(requiredExternals) +
|
146
|
-
|
147
|
-
|
144
|
+
", " +
|
145
|
+
externalsRootArray(optionalExternals)
|
148
146
|
: externalsRootArray(optionalExternals);
|
149
147
|
amdFactory =
|
150
|
-
`function webpackLoadOptionalExternalModuleAmd(${
|
151
|
-
wrapperArguments
|
152
|
-
}) {\n` +
|
148
|
+
`function webpackLoadOptionalExternalModuleAmd(${wrapperArguments}) {\n` +
|
153
149
|
` return factory(${factoryArguments});\n` +
|
154
150
|
" }";
|
155
151
|
} else {
|
@@ -177,61 +173,61 @@ class UmdMainTemplatePlugin {
|
|
177
173
|
(requiredExternals.length > 0
|
178
174
|
? this.names.amd && this.namedDefine === true
|
179
175
|
? " define(" +
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
176
|
+
libraryName(this.names.amd) +
|
177
|
+
", " +
|
178
|
+
externalsDepsArray(requiredExternals) +
|
179
|
+
", " +
|
180
|
+
amdFactory +
|
181
|
+
");\n"
|
186
182
|
: " define(" +
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
183
|
+
externalsDepsArray(requiredExternals) +
|
184
|
+
", " +
|
185
|
+
amdFactory +
|
186
|
+
");\n"
|
191
187
|
: this.names.amd && this.namedDefine === true
|
192
188
|
? " define(" +
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
189
|
+
libraryName(this.names.amd) +
|
190
|
+
", [], " +
|
191
|
+
amdFactory +
|
192
|
+
");\n"
|
197
193
|
: " define([], " + amdFactory + ");\n") +
|
198
194
|
(this.names.root || this.names.commonjs
|
199
195
|
? (this.auxiliaryComment &&
|
200
|
-
|
196
|
+
typeof this.auxiliaryComment === "string"
|
201
197
|
? " //" + this.auxiliaryComment + "\n"
|
202
198
|
: this.auxiliaryComment.commonjs
|
203
199
|
? " //" + this.auxiliaryComment.commonjs + "\n"
|
204
200
|
: "") +
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
201
|
+
" else if(typeof exports === 'object')\n" +
|
202
|
+
" exports[" +
|
203
|
+
libraryName(this.names.commonjs || this.names.root) +
|
204
|
+
"] = factory(" +
|
205
|
+
externalsRequireArray("commonjs") +
|
206
|
+
");\n" +
|
207
|
+
(this.auxiliaryComment &&
|
208
|
+
typeof this.auxiliaryComment === "string"
|
213
209
|
? " //" + this.auxiliaryComment + "\n"
|
214
210
|
: this.auxiliaryComment.root
|
215
211
|
? " //" + this.auxiliaryComment.root + "\n"
|
216
212
|
: "") +
|
217
|
-
|
218
|
-
|
219
|
-
|
213
|
+
" else\n" +
|
214
|
+
" " +
|
215
|
+
replaceKeys(
|
220
216
|
accessorAccess("root", this.names.root || this.names.commonjs)
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
217
|
+
) +
|
218
|
+
" = factory(" +
|
219
|
+
externalsRootArray(externals) +
|
220
|
+
");\n"
|
225
221
|
: " else {\n" +
|
226
|
-
|
222
|
+
(externals.length > 0
|
227
223
|
? " var a = typeof exports === 'object' ? factory(" +
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
224
|
+
externalsRequireArray("commonjs") +
|
225
|
+
") : factory(" +
|
226
|
+
externalsRootArray(externals) +
|
227
|
+
");\n"
|
232
228
|
: " var a = factory();\n") +
|
233
|
-
|
234
|
-
|
229
|
+
" for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
|
230
|
+
" }\n") +
|
235
231
|
`})(${
|
236
232
|
runtimeTemplate.outputOptions.globalObject
|
237
233
|
}, function(${externalsArguments(externals)}) {\nreturn `,
|
package/lib/WebAssemblyParser.js
CHANGED
@@ -34,11 +34,7 @@ class WebAssemblyParser extends Tapable {
|
|
34
34
|
module
|
35
35
|
).map(exp => exp.name);
|
36
36
|
for (const imp of WebAssembly.Module.imports(module)) {
|
37
|
-
const dep = new WebAssemblyImportDependency(
|
38
|
-
imp.module,
|
39
|
-
imp.name,
|
40
|
-
imp.kind
|
41
|
-
);
|
37
|
+
const dep = new WebAssemblyImportDependency(imp.module, imp.name);
|
42
38
|
state.module.addDependency(dep);
|
43
39
|
}
|
44
40
|
})
|
@@ -231,8 +231,8 @@ class WebpackOptionsApply extends OptionsApply {
|
|
231
231
|
comment =
|
232
232
|
legacy && modern
|
233
233
|
? "\n/*\n//@ source" +
|
234
|
-
|
235
|
-
|
234
|
+
"MappingURL=[url]\n//# source" +
|
235
|
+
"MappingURL=[url]\n*/"
|
236
236
|
: legacy
|
237
237
|
? "\n/*\n//@ source" + "MappingURL=[url]\n*/"
|
238
238
|
: modern ? "\n//# source" + "MappingURL=[url]" : null;
|
@@ -91,14 +91,16 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
|
|
91
91
|
this.set("output.filename", "[name].js");
|
92
92
|
this.set("output.chunkFilename", "make", options => {
|
93
93
|
const filename = options.output.filename;
|
94
|
-
if (typeof filename
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
94
|
+
if (typeof filename !== "function") {
|
95
|
+
const hasName = filename.includes("[name]");
|
96
|
+
const hasId = filename.includes("[id]");
|
97
|
+
const hasChunkHash = filename.includes("[chunkhash]");
|
98
|
+
// Anything changing depending on chunk is fine
|
99
|
+
if (hasChunkHash || hasName || hasId) return filename;
|
100
|
+
// Elsewise prefix "[id]." in front of the basename to make it changing
|
101
|
+
return filename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2");
|
102
|
+
}
|
103
|
+
return "[id].js";
|
102
104
|
});
|
103
105
|
this.set("output.webassemblyModuleFilename", "[modulehash].module.wasm");
|
104
106
|
this.set("output.library", "");
|
@@ -116,7 +116,7 @@ class WebpackOptionsValidationError extends WebpackError {
|
|
116
116
|
if (!required.includes(property)) return property + "?";
|
117
117
|
return property;
|
118
118
|
})
|
119
|
-
.concat(schema.additionalProperties ? ["
|
119
|
+
.concat(schema.additionalProperties ? ["…"] : [])
|
120
120
|
.join(", ")} }`;
|
121
121
|
}
|
122
122
|
if (schema.additionalProperties) {
|
@@ -175,7 +175,7 @@ class WebpackOptionsValidationError extends WebpackError {
|
|
175
175
|
" new webpack.LoaderOptionsPlugin({\n" +
|
176
176
|
" // test: /\\.xxx$/, // may apply this only for some modules\n" +
|
177
177
|
" options: {\n" +
|
178
|
-
` ${err.params.additionalProperty}:
|
178
|
+
` ${err.params.additionalProperty}: …\n` +
|
179
179
|
" }\n" +
|
180
180
|
" })\n" +
|
181
181
|
" ]"
|
@@ -266,12 +266,10 @@ class WebpackOptionsValidationError extends WebpackError {
|
|
266
266
|
)}`;
|
267
267
|
} else if (err.keyword === "required") {
|
268
268
|
const missingProperty = err.params.missingProperty.replace(/^\./, "");
|
269
|
-
return `${dataPath} misses the property '${
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
missingProperty
|
274
|
-
])}`;
|
269
|
+
return `${dataPath} misses the property '${missingProperty}'.\n${getSchemaPartText(
|
270
|
+
err.parentSchema,
|
271
|
+
["properties", missingProperty]
|
272
|
+
)}`;
|
275
273
|
} else if (err.keyword === "minimum") {
|
276
274
|
return `${dataPath} ${err.message}.${getSchemaPartDescription(
|
277
275
|
err.parentSchema
|
@@ -152,10 +152,10 @@ class AMDDefineDependencyParserPlugin {
|
|
152
152
|
switch (expr.arguments.length) {
|
153
153
|
case 1:
|
154
154
|
if (isCallable(expr.arguments[0])) {
|
155
|
-
// define(f() {
|
155
|
+
// define(f() {…})
|
156
156
|
fn = expr.arguments[0];
|
157
157
|
} else if (expr.arguments[0].type === "ObjectExpression") {
|
158
|
-
// define({
|
158
|
+
// define({…})
|
159
159
|
obj = expr.arguments[0];
|
160
160
|
} else {
|
161
161
|
// define(expr)
|
@@ -166,45 +166,45 @@ class AMDDefineDependencyParserPlugin {
|
|
166
166
|
case 2:
|
167
167
|
if (expr.arguments[0].type === "Literal") {
|
168
168
|
namedModule = expr.arguments[0].value;
|
169
|
-
// define("
|
169
|
+
// define("…", …)
|
170
170
|
if (isCallable(expr.arguments[1])) {
|
171
|
-
// define("
|
171
|
+
// define("…", f() {…})
|
172
172
|
fn = expr.arguments[1];
|
173
173
|
} else if (expr.arguments[1].type === "ObjectExpression") {
|
174
|
-
// define("
|
174
|
+
// define("…", {…})
|
175
175
|
obj = expr.arguments[1];
|
176
176
|
} else {
|
177
|
-
// define("
|
177
|
+
// define("…", expr)
|
178
178
|
// unclear if function or object
|
179
179
|
obj = fn = expr.arguments[1];
|
180
180
|
}
|
181
181
|
} else {
|
182
182
|
array = expr.arguments[0];
|
183
183
|
if (isCallable(expr.arguments[1])) {
|
184
|
-
// define([
|
184
|
+
// define([…], f() {})
|
185
185
|
fn = expr.arguments[1];
|
186
186
|
} else if (expr.arguments[1].type === "ObjectExpression") {
|
187
|
-
// define([
|
187
|
+
// define([…], {…})
|
188
188
|
obj = expr.arguments[1];
|
189
189
|
} else {
|
190
|
-
// define([
|
190
|
+
// define([…], expr)
|
191
191
|
// unclear if function or object
|
192
192
|
obj = fn = expr.arguments[1];
|
193
193
|
}
|
194
194
|
}
|
195
195
|
break;
|
196
196
|
case 3:
|
197
|
-
// define("
|
197
|
+
// define("…", […], f() {…})
|
198
198
|
namedModule = expr.arguments[0].value;
|
199
199
|
array = expr.arguments[1];
|
200
200
|
if (isCallable(expr.arguments[2])) {
|
201
|
-
// define("
|
201
|
+
// define("…", […], f() {})
|
202
202
|
fn = expr.arguments[2];
|
203
203
|
} else if (expr.arguments[2].type === "ObjectExpression") {
|
204
|
-
// define("
|
204
|
+
// define("…", […], {…})
|
205
205
|
obj = expr.arguments[2];
|
206
206
|
} else {
|
207
|
-
// define("
|
207
|
+
// define("…", […], expr)
|
208
208
|
// unclear if function or object
|
209
209
|
obj = fn = expr.arguments[2];
|
210
210
|
}
|
@@ -216,7 +216,7 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|
216
216
|
parser.state.module.errors.push(
|
217
217
|
new UnsupportedFeatureWarning(
|
218
218
|
parser.state.module,
|
219
|
-
"Cannot statically analyse 'require(
|
219
|
+
"Cannot statically analyse 'require(…, …)' in line " +
|
220
220
|
expr.loc.start.line
|
221
221
|
)
|
222
222
|
);
|
@@ -341,9 +341,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
341
341
|
? `the named export '${this.id}'`
|
342
342
|
: "the namespace object";
|
343
343
|
const err = new Error(
|
344
|
-
`Can't reexport ${
|
345
|
-
exportName
|
346
|
-
} from non EcmaScript module (only default export is available)`
|
344
|
+
`Can't reexport ${exportName} from non EcmaScript module (only default export is available)`
|
347
345
|
);
|
348
346
|
err.hideStack = true;
|
349
347
|
return [err];
|
@@ -363,9 +361,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
363
361
|
// We are sure that it's not provided
|
364
362
|
const idIsNotNameMessage =
|
365
363
|
this.id !== this.name ? ` (reexported as '${this.name}')` : "";
|
366
|
-
const errorMessage = `"export '${
|
367
|
-
|
368
|
-
} was not found in '${this.userRequest}'`;
|
364
|
+
const errorMessage = `"export '${
|
365
|
+
this.id
|
366
|
+
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
369
367
|
const err = new Error(errorMessage);
|
370
368
|
err.hideStack = true;
|
371
369
|
return [err];
|
@@ -578,11 +576,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
578
576
|
const exportsName = dep.originModule.exportsArgument;
|
579
577
|
return (
|
580
578
|
content +
|
581
|
-
`(function(key) { __webpack_require__.d(${
|
582
|
-
exportsName
|
583
|
-
}, key, function() { return ${
|
584
|
-
importVar
|
585
|
-
}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`
|
579
|
+
`(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${importVar}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`
|
586
580
|
);
|
587
581
|
}
|
588
582
|
|
@@ -44,9 +44,9 @@ HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependen
|
|
44
44
|
|
45
45
|
const exportsName = dep.originModule.exportsArgument;
|
46
46
|
|
47
|
-
return `/* harmony export (binding) */ __webpack_require__.d(${
|
48
|
-
|
49
|
-
|
47
|
+
return `/* harmony export (binding) */ __webpack_require__.d(${exportsName}, ${JSON.stringify(
|
48
|
+
used
|
49
|
+
)}, function() { return ${dep.id}; });\n`;
|
50
50
|
}
|
51
51
|
};
|
52
52
|
|
@@ -77,9 +77,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
77
77
|
? `the named export '${this.id}'`
|
78
78
|
: "the namespace object";
|
79
79
|
const err = new Error(
|
80
|
-
`Can't import ${
|
81
|
-
exportName
|
82
|
-
} from non EcmaScript module (only default export is available)`
|
80
|
+
`Can't import ${exportName} from non EcmaScript module (only default export is available)`
|
83
81
|
);
|
84
82
|
err.hideStack = true;
|
85
83
|
return [err];
|
@@ -99,9 +97,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
99
97
|
// We are sure that it's not provided
|
100
98
|
const idIsNotNameMessage =
|
101
99
|
this.id !== this.name ? ` (imported as '${this.name}')` : "";
|
102
|
-
const errorMessage = `"export '${
|
103
|
-
|
104
|
-
} was not found in '${this.userRequest}'`;
|
100
|
+
const errorMessage = `"export '${
|
101
|
+
this.id
|
102
|
+
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
|
105
103
|
const err = new Error(errorMessage);
|
106
104
|
err.hideStack = true;
|
107
105
|
return [err];
|
@@ -97,9 +97,7 @@ class ImportParserPlugin {
|
|
97
97
|
parser.state.module.warnings.push(
|
98
98
|
new UnsupportedFeatureWarning(
|
99
99
|
parser.state.module,
|
100
|
-
`\`webpackMode\` expected 'lazy', 'eager' or 'weak', but received: ${
|
101
|
-
mode
|
102
|
-
}.`
|
100
|
+
`\`webpackMode\` expected 'lazy', 'eager' or 'weak', but received: ${mode}.`
|
103
101
|
)
|
104
102
|
);
|
105
103
|
}
|
@@ -140,9 +138,7 @@ class ImportParserPlugin {
|
|
140
138
|
parser.state.module.warnings.push(
|
141
139
|
new UnsupportedFeatureWarning(
|
142
140
|
parser.state.module,
|
143
|
-
`\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${
|
144
|
-
mode
|
145
|
-
}.`
|
141
|
+
`\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${mode}.`
|
146
142
|
)
|
147
143
|
);
|
148
144
|
mode = "lazy";
|
@@ -31,7 +31,7 @@ RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate {
|
|
31
31
|
const comment = runtime.outputOptions.pathinfo
|
32
32
|
? Template.toComment(
|
33
33
|
`require.include ${runtime.requestShortener.shorten(dep.request)}`
|
34
|
-
|
34
|
+
)
|
35
35
|
: "";
|
36
36
|
source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
|
37
37
|
}
|
@@ -11,9 +11,7 @@ exports.module = request =>
|
|
11
11
|
|
12
12
|
exports.promise = request => {
|
13
13
|
const errorCode = toErrorCode(`Cannot find module "${request}"`);
|
14
|
-
return `Promise.reject(function webpackMissingModule() { ${
|
15
|
-
errorCode
|
16
|
-
} return e; }())`;
|
14
|
+
return `Promise.reject(function webpackMissingModule() { ${errorCode} return e; }())`;
|
17
15
|
};
|
18
16
|
|
19
17
|
exports.moduleCode = request => {
|
@@ -72,9 +72,7 @@ class ReadFileCompileWasmMainTemplatePlugin {
|
|
72
72
|
Template.indent([
|
73
73
|
"(installedWasmModules[wasmModuleId] = new Promise(function(resolve, reject) {",
|
74
74
|
Template.indent([
|
75
|
-
`require('fs').readFile(require('path').resolve(__dirname, ${
|
76
|
-
wasmModuleSrcPath
|
77
|
-
}), function(err, buffer) {`,
|
75
|
+
`require('fs').readFile(require('path').resolve(__dirname, ${wasmModuleSrcPath}), function(err, buffer) {`,
|
78
76
|
Template.indent([
|
79
77
|
"if(err) return reject(err);",
|
80
78
|
"resolve(WebAssembly.compile(buffer));"
|
@@ -146,9 +146,9 @@ const getFinalName = (
|
|
146
146
|
}
|
147
147
|
}
|
148
148
|
const problem =
|
149
|
-
`Cannot get final name for export "${
|
150
|
-
|
151
|
-
|
149
|
+
`Cannot get final name for export "${exportName}" in "${info.module.readableIdentifier(
|
150
|
+
requestShortener
|
151
|
+
)}"` +
|
152
152
|
` (known exports: ${Array.from(info.exportMap.keys())
|
153
153
|
.filter(name => name !== true)
|
154
154
|
.join(" ")}, ` +
|
@@ -550,8 +550,7 @@ class ConcatenatedModule extends Module {
|
|
550
550
|
HarmonyExportExpressionDependency,
|
551
551
|
new HarmonyExportExpressionDependencyConcatenatedTemplate(
|
552
552
|
dependencyTemplates.get(HarmonyExportExpressionDependency),
|
553
|
-
this.rootModule
|
554
|
-
moduleToInfoMap
|
553
|
+
this.rootModule
|
555
554
|
)
|
556
555
|
);
|
557
556
|
innerDependencyTemplates.set(
|
@@ -1134,14 +1133,14 @@ class HarmonyImportSpecifierDependencyConcatenatedTemplate {
|
|
1134
1133
|
if (dep.id === null) {
|
1135
1134
|
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
1136
1135
|
} else if (dep.namespaceObjectAsContext) {
|
1137
|
-
content = `__WEBPACK_MODULE_REFERENCE__${
|
1138
|
-
|
1139
|
-
}__[${JSON.stringify(dep.id)}]`;
|
1136
|
+
content = `__WEBPACK_MODULE_REFERENCE__${
|
1137
|
+
info.index
|
1138
|
+
}_ns${strictFlag}__[${JSON.stringify(dep.id)}]`;
|
1140
1139
|
} else {
|
1141
1140
|
const exportData = Buffer.from(dep.id, "utf-8").toString("hex");
|
1142
|
-
content = `__WEBPACK_MODULE_REFERENCE__${
|
1143
|
-
|
1144
|
-
}${strictFlag}__`;
|
1141
|
+
content = `__WEBPACK_MODULE_REFERENCE__${
|
1142
|
+
info.index
|
1143
|
+
}_${exportData}${callFlag}${strictFlag}__`;
|
1145
1144
|
}
|
1146
1145
|
if (dep.shorthand) {
|
1147
1146
|
content = dep.name + ": " + content;
|
@@ -1328,19 +1327,19 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
|
|
1328
1327
|
? "_strict"
|
1329
1328
|
: "";
|
1330
1329
|
if (def.id === true) {
|
1331
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
1332
|
-
|
1333
|
-
}__`;
|
1330
|
+
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
1331
|
+
info.index
|
1332
|
+
}_ns${strictFlag}__`;
|
1334
1333
|
} else {
|
1335
1334
|
const exportData = Buffer.from(def.id, "utf-8").toString("hex");
|
1336
|
-
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
1337
|
-
|
1338
|
-
}${strictFlag}__`;
|
1335
|
+
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
1336
|
+
info.index
|
1337
|
+
}_${exportData}${strictFlag}__`;
|
1339
1338
|
}
|
1340
1339
|
const exportsName = this.rootModule.exportsArgument;
|
1341
|
-
const content = `/* concated harmony reexport */__webpack_require__.d(${
|
1342
|
-
|
1343
|
-
|
1340
|
+
const content = `/* concated harmony reexport */__webpack_require__.d(${exportsName}, ${JSON.stringify(
|
1341
|
+
used
|
1342
|
+
)}, function() { return ${finalName}; });\n`;
|
1344
1343
|
source.insert(-1, content);
|
1345
1344
|
}
|
1346
1345
|
} else {
|