webpack 5.5.1 → 5.9.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/bin/webpack.js +10 -3
- package/lib/Compilation.js +132 -17
- package/lib/Compiler.js +2 -2
- package/lib/ExportsInfo.js +1 -1
- package/lib/FlagDependencyUsagePlugin.js +4 -2
- package/lib/HotModuleReplacementPlugin.js +170 -36
- package/lib/NormalModule.js +13 -1
- package/lib/RuntimeTemplate.js +0 -3
- package/lib/SourceMapDevToolPlugin.js +2 -1
- package/lib/Template.js +0 -1
- package/lib/TemplatedPathPlugin.js +8 -0
- package/lib/Watching.js +0 -1
- package/lib/cache/ResolverCachePlugin.js +0 -1
- package/lib/config/defaults.js +1 -1
- package/lib/dependencies/AMDDefineDependency.js +3 -1
- package/lib/dependencies/AMDRequireArrayDependency.js +3 -1
- package/lib/dependencies/AMDRequireDependency.js +3 -1
- package/lib/dependencies/CachedConstDependency.js +3 -1
- package/lib/dependencies/CommonJsExportRequireDependency.js +3 -2
- package/lib/dependencies/CommonJsExportsDependency.js +3 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +3 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +3 -1
- package/lib/dependencies/ConstDependency.js +3 -1
- package/lib/dependencies/ExportsInfoDependency.js +3 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +3 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -1
- package/lib/dependencies/HarmonyCompatibilityDependency.js +3 -1
- package/lib/dependencies/HarmonyExportExpressionDependency.js +3 -1
- package/lib/dependencies/HarmonyExportHeaderDependency.js +3 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +11 -2
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +3 -1
- package/lib/dependencies/HarmonyImportDependency.js +50 -46
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +11 -1
- package/lib/dependencies/ImportDependency.js +3 -2
- package/lib/dependencies/ImportEagerDependency.js +3 -1
- package/lib/dependencies/ImportWeakDependency.js +3 -1
- package/lib/dependencies/LocalModuleDependency.js +3 -1
- package/lib/dependencies/ModuleDecoratorDependency.js +3 -2
- package/lib/dependencies/NullDependency.js +3 -2
- package/lib/dependencies/PureExpressionDependency.js +3 -1
- package/lib/dependencies/RequireEnsureDependency.js +3 -1
- package/lib/dependencies/RequireHeaderDependency.js +3 -1
- package/lib/dependencies/RequireIncludeDependency.js +3 -2
- package/lib/dependencies/RequireResolveHeaderDependency.js +3 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +3 -1
- package/lib/dependencies/URLDependency.js +3 -1
- package/lib/dependencies/UnsupportedDependency.js +3 -1
- package/lib/dependencies/WorkerDependency.js +3 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
- package/lib/index.js +3 -0
- package/lib/javascript/JavascriptParser.js +29 -11
- package/lib/optimize/RealContentHashPlugin.js +127 -32
- package/lib/optimize/SideEffectsFlagPlugin.js +224 -204
- package/lib/optimize/SplitChunksPlugin.js +0 -1
- package/lib/runtime/GetMainFilenameRuntimeModule.js +4 -2
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -1
- package/lib/serialization/FileMiddleware.js +4 -2
- package/lib/util/runtime.js +4 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +0 -1
- package/lib/webpack.js +0 -2
- package/package.json +14 -14
- package/types.d.ts +179 -149
@@ -9,6 +9,7 @@ const glob2regexp = require("glob-to-regexp");
|
|
9
9
|
const { STAGE_DEFAULT } = require("../OptimizationStages");
|
10
10
|
const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency");
|
11
11
|
const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency");
|
12
|
+
const formatLocation = require("../formatLocation");
|
12
13
|
|
13
14
|
/** @typedef {import("../Compiler")} Compiler */
|
14
15
|
/** @typedef {import("../Dependency")} Dependency */
|
@@ -67,223 +68,242 @@ class SideEffectsFlagPlugin {
|
|
67
68
|
cache = new Map();
|
68
69
|
globToRegexpCache.set(compiler.root, cache);
|
69
70
|
}
|
70
|
-
compiler.hooks.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
71
|
+
compiler.hooks.compilation.tap(
|
72
|
+
"SideEffectsFlagPlugin",
|
73
|
+
(compilation, { normalModuleFactory }) => {
|
74
|
+
const moduleGraph = compilation.moduleGraph;
|
75
|
+
normalModuleFactory.hooks.module.tap(
|
76
|
+
"SideEffectsFlagPlugin",
|
77
|
+
(module, data) => {
|
78
|
+
const resolveData = data.resourceResolveData;
|
79
|
+
if (
|
80
|
+
resolveData &&
|
81
|
+
resolveData.descriptionFileData &&
|
82
|
+
resolveData.relativePath
|
83
|
+
) {
|
84
|
+
const sideEffects = resolveData.descriptionFileData.sideEffects;
|
85
|
+
const hasSideEffects = SideEffectsFlagPlugin.moduleHasSideEffects(
|
86
|
+
resolveData.relativePath,
|
87
|
+
sideEffects,
|
88
|
+
cache
|
89
|
+
);
|
90
|
+
if (!hasSideEffects) {
|
91
|
+
if (module.factoryMeta === undefined) {
|
92
|
+
module.factoryMeta = {};
|
93
|
+
}
|
94
|
+
module.factoryMeta.sideEffectFree = true;
|
95
|
+
}
|
87
96
|
}
|
88
|
-
module.factoryMeta.sideEffectFree = true;
|
89
|
-
}
|
90
|
-
}
|
91
97
|
|
92
|
-
|
93
|
-
});
|
94
|
-
nmf.hooks.module.tap("SideEffectsFlagPlugin", (module, data) => {
|
95
|
-
if (data.settings.sideEffects === false) {
|
96
|
-
if (module.factoryMeta === undefined) {
|
97
|
-
module.factoryMeta = {};
|
98
|
-
}
|
99
|
-
module.factoryMeta.sideEffectFree = true;
|
100
|
-
} else if (data.settings.sideEffects === true) {
|
101
|
-
if (module.factoryMeta !== undefined) {
|
102
|
-
module.factoryMeta.sideEffectFree = false;
|
98
|
+
return module;
|
103
99
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
});
|
117
|
-
parser.hooks.statement.tap(
|
118
|
-
{ name: "SideEffectsFlagPlugin", stage: -100 },
|
119
|
-
statement => {
|
120
|
-
if (hasSideEffects) return;
|
121
|
-
if (parser.scope.topLevelScope !== true) return;
|
122
|
-
switch (statement.type) {
|
123
|
-
case "ExpressionStatement":
|
124
|
-
if (
|
125
|
-
!parser.isPure(statement.expression, statement.range[0])
|
126
|
-
) {
|
127
|
-
hasSideEffects = true;
|
128
|
-
}
|
129
|
-
break;
|
130
|
-
case "IfStatement":
|
131
|
-
case "WhileStatement":
|
132
|
-
case "DoWhileStatement":
|
133
|
-
if (!parser.isPure(statement.test, statement.range[0])) {
|
134
|
-
hasSideEffects = true;
|
135
|
-
}
|
136
|
-
// statement hook will be called for child statements too
|
137
|
-
break;
|
138
|
-
case "ForStatement":
|
139
|
-
if (
|
140
|
-
!parser.isPure(statement.init, statement.range[0]) ||
|
141
|
-
!parser.isPure(
|
142
|
-
statement.test,
|
143
|
-
statement.init
|
144
|
-
? statement.init.range[1]
|
145
|
-
: statement.range[0]
|
146
|
-
) ||
|
147
|
-
!parser.isPure(
|
148
|
-
statement.update,
|
149
|
-
statement.test
|
150
|
-
? statement.test.range[1]
|
151
|
-
: statement.init
|
152
|
-
? statement.init.range[1]
|
153
|
-
: statement.range[0]
|
154
|
-
)
|
155
|
-
) {
|
156
|
-
hasSideEffects = true;
|
157
|
-
}
|
158
|
-
// statement hook will be called for child statements too
|
159
|
-
break;
|
160
|
-
case "SwitchStatement":
|
161
|
-
if (
|
162
|
-
!parser.isPure(statement.discriminant, statement.range[0])
|
163
|
-
) {
|
164
|
-
hasSideEffects = true;
|
165
|
-
}
|
166
|
-
// statement hook will be called for child statements too
|
167
|
-
break;
|
168
|
-
case "VariableDeclaration":
|
169
|
-
case "ClassDeclaration":
|
170
|
-
case "FunctionDeclaration":
|
171
|
-
if (!parser.isPure(statement, statement.range[0])) {
|
172
|
-
hasSideEffects = true;
|
173
|
-
}
|
174
|
-
break;
|
175
|
-
case "ExportDefaultDeclaration":
|
176
|
-
if (
|
177
|
-
!parser.isPure(statement.declaration, statement.range[0])
|
178
|
-
) {
|
179
|
-
hasSideEffects = true;
|
180
|
-
}
|
181
|
-
break;
|
182
|
-
case "ExportNamedDeclaration":
|
183
|
-
if (statement.source) {
|
184
|
-
hasSideEffects = true;
|
185
|
-
}
|
186
|
-
break;
|
187
|
-
case "LabeledStatement":
|
188
|
-
case "BlockStatement":
|
189
|
-
// statement hook will be called for child statements too
|
190
|
-
break;
|
191
|
-
case "EmptyStatement":
|
192
|
-
break;
|
193
|
-
case "ImportDeclaration":
|
194
|
-
// imports will be handled by the dependencies
|
195
|
-
break;
|
196
|
-
default:
|
197
|
-
hasSideEffects = true;
|
198
|
-
break;
|
100
|
+
);
|
101
|
+
normalModuleFactory.hooks.module.tap(
|
102
|
+
"SideEffectsFlagPlugin",
|
103
|
+
(module, data) => {
|
104
|
+
if (data.settings.sideEffects === false) {
|
105
|
+
if (module.factoryMeta === undefined) {
|
106
|
+
module.factoryMeta = {};
|
107
|
+
}
|
108
|
+
module.factoryMeta.sideEffectFree = true;
|
109
|
+
} else if (data.settings.sideEffects === true) {
|
110
|
+
if (module.factoryMeta !== undefined) {
|
111
|
+
module.factoryMeta.sideEffectFree = false;
|
199
112
|
}
|
200
113
|
}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
114
|
+
return module;
|
115
|
+
}
|
116
|
+
);
|
117
|
+
if (this._analyseSource) {
|
118
|
+
/**
|
119
|
+
* @param {JavascriptParser} parser the parser
|
120
|
+
* @returns {void}
|
121
|
+
*/
|
122
|
+
const parserHandler = parser => {
|
123
|
+
let sideEffectsStatement;
|
124
|
+
parser.hooks.program.tap("SideEffectsFlagPlugin", () => {
|
125
|
+
sideEffectsStatement = undefined;
|
126
|
+
});
|
127
|
+
parser.hooks.statement.tap(
|
128
|
+
{ name: "SideEffectsFlagPlugin", stage: -100 },
|
129
|
+
statement => {
|
130
|
+
if (sideEffectsStatement) return;
|
131
|
+
if (parser.scope.topLevelScope !== true) return;
|
132
|
+
switch (statement.type) {
|
133
|
+
case "ExpressionStatement":
|
134
|
+
if (
|
135
|
+
!parser.isPure(statement.expression, statement.range[0])
|
136
|
+
) {
|
137
|
+
sideEffectsStatement = statement;
|
138
|
+
}
|
139
|
+
break;
|
140
|
+
case "IfStatement":
|
141
|
+
case "WhileStatement":
|
142
|
+
case "DoWhileStatement":
|
143
|
+
if (!parser.isPure(statement.test, statement.range[0])) {
|
144
|
+
sideEffectsStatement = statement;
|
145
|
+
}
|
146
|
+
// statement hook will be called for child statements too
|
147
|
+
break;
|
148
|
+
case "ForStatement":
|
149
|
+
if (
|
150
|
+
!parser.isPure(statement.init, statement.range[0]) ||
|
151
|
+
!parser.isPure(
|
152
|
+
statement.test,
|
153
|
+
statement.init
|
154
|
+
? statement.init.range[1]
|
155
|
+
: statement.range[0]
|
156
|
+
) ||
|
157
|
+
!parser.isPure(
|
158
|
+
statement.update,
|
159
|
+
statement.test
|
160
|
+
? statement.test.range[1]
|
161
|
+
: statement.init
|
162
|
+
? statement.init.range[1]
|
163
|
+
: statement.range[0]
|
164
|
+
)
|
165
|
+
) {
|
166
|
+
sideEffectsStatement = statement;
|
167
|
+
}
|
168
|
+
// statement hook will be called for child statements too
|
169
|
+
break;
|
170
|
+
case "SwitchStatement":
|
171
|
+
if (
|
172
|
+
!parser.isPure(statement.discriminant, statement.range[0])
|
173
|
+
) {
|
174
|
+
sideEffectsStatement = statement;
|
175
|
+
}
|
176
|
+
// statement hook will be called for child statements too
|
177
|
+
break;
|
178
|
+
case "VariableDeclaration":
|
179
|
+
case "ClassDeclaration":
|
180
|
+
case "FunctionDeclaration":
|
181
|
+
if (!parser.isPure(statement, statement.range[0])) {
|
182
|
+
sideEffectsStatement = statement;
|
183
|
+
}
|
184
|
+
break;
|
185
|
+
case "ExportNamedDeclaration":
|
186
|
+
case "ExportDefaultDeclaration":
|
187
|
+
if (
|
188
|
+
!parser.isPure(statement.declaration, statement.range[0])
|
189
|
+
) {
|
190
|
+
sideEffectsStatement = statement;
|
191
|
+
}
|
192
|
+
break;
|
193
|
+
case "LabeledStatement":
|
194
|
+
case "BlockStatement":
|
195
|
+
// statement hook will be called for child statements too
|
196
|
+
break;
|
197
|
+
case "EmptyStatement":
|
198
|
+
break;
|
199
|
+
case "ExportAllDeclaration":
|
200
|
+
case "ImportDeclaration":
|
201
|
+
// imports will be handled by the dependencies
|
202
|
+
break;
|
203
|
+
default:
|
204
|
+
sideEffectsStatement = statement;
|
205
|
+
break;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
);
|
209
|
+
parser.hooks.finish.tap("SideEffectsFlagPlugin", () => {
|
210
|
+
if (sideEffectsStatement === undefined) {
|
211
|
+
parser.state.module.buildMeta.sideEffectFree = true;
|
212
|
+
} else {
|
213
|
+
const { loc, type } = sideEffectsStatement;
|
214
|
+
moduleGraph
|
215
|
+
.getOptimizationBailout(parser.state.module)
|
216
|
+
.push(
|
217
|
+
() =>
|
218
|
+
`Statement (${type}) with side effects in source code at ${formatLocation(
|
219
|
+
loc
|
220
|
+
)}`
|
221
|
+
);
|
222
|
+
}
|
223
|
+
});
|
224
|
+
};
|
225
|
+
for (const key of [
|
226
|
+
"javascript/auto",
|
227
|
+
"javascript/esm",
|
228
|
+
"javascript/dynamic"
|
229
|
+
]) {
|
230
|
+
normalModuleFactory.hooks.parser
|
231
|
+
.for(key)
|
232
|
+
.tap("SideEffectsFlagPlugin", parserHandler);
|
233
|
+
}
|
214
234
|
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
modules => {
|
225
|
-
const logger = compilation.getLogger("webpack.SideEffectsFlagPlugin");
|
235
|
+
compilation.hooks.optimizeDependencies.tap(
|
236
|
+
{
|
237
|
+
name: "SideEffectsFlagPlugin",
|
238
|
+
stage: STAGE_DEFAULT
|
239
|
+
},
|
240
|
+
modules => {
|
241
|
+
const logger = compilation.getLogger(
|
242
|
+
"webpack.SideEffectsFlagPlugin"
|
243
|
+
);
|
226
244
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
module
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
module
|
263
|
-
|
264
|
-
|
265
|
-
|
245
|
+
logger.time("update dependencies");
|
246
|
+
for (const module of modules) {
|
247
|
+
if (module.getSideEffectsConnectionState(moduleGraph) === false) {
|
248
|
+
const exportsInfo = moduleGraph.getExportsInfo(module);
|
249
|
+
for (const connection of moduleGraph.getIncomingConnections(
|
250
|
+
module
|
251
|
+
)) {
|
252
|
+
const dep = connection.dependency;
|
253
|
+
let isReexport;
|
254
|
+
if (
|
255
|
+
(isReexport =
|
256
|
+
dep instanceof
|
257
|
+
HarmonyExportImportedSpecifierDependency) ||
|
258
|
+
(dep instanceof HarmonyImportSpecifierDependency &&
|
259
|
+
!dep.namespaceObjectAsContext)
|
260
|
+
) {
|
261
|
+
// TODO improve for export *
|
262
|
+
if (isReexport && dep.name) {
|
263
|
+
const exportInfo = moduleGraph.getExportInfo(
|
264
|
+
connection.originModule,
|
265
|
+
dep.name
|
266
|
+
);
|
267
|
+
exportInfo.moveTarget(
|
268
|
+
moduleGraph,
|
269
|
+
({ module }) =>
|
270
|
+
module.getSideEffectsConnectionState(moduleGraph) ===
|
271
|
+
false
|
272
|
+
);
|
273
|
+
}
|
274
|
+
// TODO improve for nested imports
|
275
|
+
const ids = dep.getIds(moduleGraph);
|
276
|
+
if (ids.length > 0) {
|
277
|
+
const exportInfo = exportsInfo.getExportInfo(ids[0]);
|
278
|
+
const target = exportInfo.moveTarget(
|
279
|
+
moduleGraph,
|
280
|
+
({ module }) =>
|
281
|
+
module.getSideEffectsConnectionState(moduleGraph) ===
|
282
|
+
false
|
283
|
+
);
|
284
|
+
if (!target) continue;
|
266
285
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
286
|
+
moduleGraph.updateModule(dep, target.module);
|
287
|
+
moduleGraph.addExplanation(
|
288
|
+
dep,
|
289
|
+
"(skipped side-effect-free modules)"
|
290
|
+
);
|
291
|
+
dep.setIds(
|
292
|
+
moduleGraph,
|
293
|
+
target.export
|
294
|
+
? [...target.export, ...ids.slice(1)]
|
295
|
+
: ids.slice(1)
|
296
|
+
);
|
297
|
+
}
|
278
298
|
}
|
279
299
|
}
|
280
300
|
}
|
281
301
|
}
|
302
|
+
logger.timeEnd("update dependencies");
|
282
303
|
}
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
});
|
304
|
+
);
|
305
|
+
}
|
306
|
+
);
|
287
307
|
}
|
288
308
|
|
289
309
|
static moduleHasSideEffects(moduleName, flagValue, cache) {
|
@@ -26,7 +26,6 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|
26
26
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
|
27
27
|
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
|
28
28
|
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
|
29
|
-
/** @typedef {import("../Chunk")} Chunk */
|
30
29
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
31
30
|
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
32
31
|
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
|
@@ -26,12 +26,14 @@ class GetMainFilenameRuntimeModule extends RuntimeModule {
|
|
26
26
|
* @returns {string} runtime code
|
27
27
|
*/
|
28
28
|
generate() {
|
29
|
-
const { global, filename, compilation } = this;
|
29
|
+
const { global, filename, compilation, chunk } = this;
|
30
30
|
const { runtimeTemplate } = compilation;
|
31
31
|
const url = compilation.getPath(JSON.stringify(filename), {
|
32
32
|
hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
|
33
33
|
hashWithLength: length =>
|
34
|
-
`" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "
|
34
|
+
`" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
|
35
|
+
chunk,
|
36
|
+
runtime: chunk.runtime
|
35
37
|
});
|
36
38
|
return Template.asString([
|
37
39
|
`${global} = ${runtimeTemplate.returningFunction(url)};`
|
@@ -11,7 +11,6 @@ const Template = require("../Template");
|
|
11
11
|
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
12
12
|
|
13
13
|
/** @typedef {import("../Chunk")} Chunk */
|
14
|
-
/** @typedef {import("../Compilation")} Compilation */
|
15
14
|
/** @typedef {import("../Compiler")} Compiler */
|
16
15
|
|
17
16
|
/**
|
@@ -233,7 +233,8 @@ class FileMiddleware extends SerializerMiddleware {
|
|
233
233
|
* @param {Object} context context object
|
234
234
|
* @returns {SerializedType|Promise<SerializedType>} serialized data
|
235
235
|
*/
|
236
|
-
serialize(data,
|
236
|
+
serialize(data, context) {
|
237
|
+
const { filename, extension = "" } = context;
|
237
238
|
return new Promise((resolve, reject) => {
|
238
239
|
mkdirp(this.fs, dirname(this.fs, filename), err => {
|
239
240
|
if (err) return reject(err);
|
@@ -301,7 +302,8 @@ class FileMiddleware extends SerializerMiddleware {
|
|
301
302
|
* @param {Object} context context object
|
302
303
|
* @returns {DeserializedType|Promise<DeserializedType>} deserialized data
|
303
304
|
*/
|
304
|
-
deserialize(data,
|
305
|
+
deserialize(data, context) {
|
306
|
+
const { filename, extension = "" } = context;
|
305
307
|
const readFile = name =>
|
306
308
|
new Promise((resolve, reject) => {
|
307
309
|
const file = name
|
package/lib/util/runtime.js
CHANGED
@@ -17,7 +17,6 @@ const memorize = require("../util/memorize");
|
|
17
17
|
/** @typedef {import("../Chunk")} Chunk */
|
18
18
|
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
19
19
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
20
|
-
/** @typedef {import("../Compilation")} Compilation */
|
21
20
|
/** @typedef {import("../Compiler")} Compiler */
|
22
21
|
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
23
22
|
/** @typedef {import("../Module")} Module */
|
package/lib/webpack.js
CHANGED
@@ -19,9 +19,7 @@ const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
|
|
19
19
|
const validateSchema = require("./validateSchema");
|
20
20
|
|
21
21
|
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
|
22
|
-
/** @typedef {import("./Compiler")} Compiler */
|
23
22
|
/** @typedef {import("./Compiler").WatchOptions} WatchOptions */
|
24
|
-
/** @typedef {import("./MultiCompiler")} MultiCompiler */
|
25
23
|
/** @typedef {import("./MultiStats")} MultiStats */
|
26
24
|
/** @typedef {import("./Stats")} Stats */
|
27
25
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.9.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"neo-async": "^2.6.2",
|
26
26
|
"pkg-dir": "^4.2.0",
|
27
27
|
"schema-utils": "^3.0.0",
|
28
|
-
"tapable": "^2.
|
28
|
+
"tapable": "^2.1.1",
|
29
29
|
"terser-webpack-plugin": "^5.0.3",
|
30
30
|
"watchpack": "^2.0.0",
|
31
31
|
"webpack-sources": "^2.1.1"
|
@@ -38,8 +38,8 @@
|
|
38
38
|
"devDependencies": {
|
39
39
|
"@babel/core": "^7.11.1",
|
40
40
|
"@babel/preset-react": "^7.10.4",
|
41
|
-
"@types/jest": "^
|
42
|
-
"@types/node": "^
|
41
|
+
"@types/jest": "^26.0.15",
|
42
|
+
"@types/node": "^14.14.10",
|
43
43
|
"babel-loader": "^8.1.0",
|
44
44
|
"benchmark": "^2.1.4",
|
45
45
|
"bundle-loader": "^0.5.6",
|
@@ -52,10 +52,10 @@
|
|
52
52
|
"date-fns": "^2.15.0",
|
53
53
|
"es5-ext": "^0.10.53",
|
54
54
|
"es6-promise-polyfill": "^1.2.0",
|
55
|
-
"eslint": "^
|
55
|
+
"eslint": "^7.14.0",
|
56
56
|
"eslint-config-prettier": "^6.11.0",
|
57
|
-
"eslint-plugin-jest": "^
|
58
|
-
"eslint-plugin-jsdoc": "^
|
57
|
+
"eslint-plugin-jest": "^24.1.3",
|
58
|
+
"eslint-plugin-jsdoc": "^30.7.8",
|
59
59
|
"eslint-plugin-node": "^11.0.0",
|
60
60
|
"eslint-plugin-prettier": "^3.1.4",
|
61
61
|
"file-loader": "^6.0.0",
|
@@ -63,9 +63,9 @@
|
|
63
63
|
"husky": "^4.2.5",
|
64
64
|
"is-ci": "^2.0.0",
|
65
65
|
"istanbul": "^0.4.5",
|
66
|
-
"jest": "^
|
67
|
-
"jest-diff": "^
|
68
|
-
"jest-junit": "^
|
66
|
+
"jest": "^26.6.3",
|
67
|
+
"jest-diff": "^26.6.2",
|
68
|
+
"jest-junit": "^12.0.0",
|
69
69
|
"json-loader": "^0.5.7",
|
70
70
|
"json5": "^2.1.3",
|
71
71
|
"less": "^3.12.2",
|
@@ -78,7 +78,7 @@
|
|
78
78
|
"mini-css-extract-plugin": "^1.0.0",
|
79
79
|
"mini-svg-data-uri": "^1.2.3",
|
80
80
|
"open-cli": "^6.0.1",
|
81
|
-
"prettier": "^2.0
|
81
|
+
"prettier": "^2.2.0",
|
82
82
|
"pretty-format": "^26.3.0",
|
83
83
|
"pug": "^3.0.0",
|
84
84
|
"pug-loader": "^2.4.0",
|
@@ -90,9 +90,9 @@
|
|
90
90
|
"simple-git": "^2.17.0",
|
91
91
|
"strip-ansi": "^6.0.0",
|
92
92
|
"style-loader": "^1.1.4",
|
93
|
-
"terser": "^
|
93
|
+
"terser": "^5.5.0",
|
94
94
|
"toml": "^3.0.0",
|
95
|
-
"tooling": "webpack/tooling#v1.
|
95
|
+
"tooling": "webpack/tooling#v1.10.0",
|
96
96
|
"ts-loader": "^8.0.2",
|
97
97
|
"typescript": "^3.9.7",
|
98
98
|
"url-loader": "^4.1.0",
|
@@ -100,7 +100,7 @@
|
|
100
100
|
"webassembly-feature": "1.3.0",
|
101
101
|
"xxhashjs": "^0.2.2",
|
102
102
|
"yamljs": "^0.3.0",
|
103
|
-
"yarn-deduplicate": "^
|
103
|
+
"yarn-deduplicate": "^3.1.0"
|
104
104
|
},
|
105
105
|
"engines": {
|
106
106
|
"node": ">=10.13.0"
|