webpack 4.17.2 → 4.19.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/README.md +1 -1
- package/bin/webpack.js +13 -22
- package/lib/ChunkTemplate.js +5 -1
- package/lib/Compilation.js +8 -2
- package/lib/JavascriptModulesPlugin.js +6 -1
- package/lib/MainTemplate.js +32 -5
- package/lib/node/NodeMainTemplatePlugin.js +1 -3
- package/lib/wasm/WasmMainTemplatePlugin.js +1 -16
- package/lib/wasm/WebAssemblyGenerator.js +0 -13
- package/lib/web/JsonpMainTemplatePlugin.js +1 -5
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +1 -6
- package/package.json +6 -7
package/README.md
CHANGED
@@ -221,7 +221,7 @@ or are automatically applied via regex from your webpack configuration.
|
|
221
221
|
|<a href="https://github.com/webpack/style-loader">`<style>`</a>|![style-npm]|![style-size]|Add exports of a module as style to DOM|
|
222
222
|
|<a href="https://github.com/webpack/css-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/css-3.svg"></a>|![css-npm]|![css-size]|Loads CSS file with resolved imports and returns CSS code|
|
223
223
|
|<a href="https://github.com/webpack/less-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/less-63.svg"></a>|![less-npm]|![less-size]|Loads and compiles a LESS file|
|
224
|
-
|<a href="https://github.com/jtangelder/sass-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/sass-1.svg"></a>|![sass-npm]|![sass-size]|Loads and compiles a
|
224
|
+
|<a href="https://github.com/jtangelder/sass-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/sass-1.svg"></a>|![sass-npm]|![sass-size]|Loads and compiles a Sass/SCSS file|
|
225
225
|
|<a href="https://github.com/shama/stylus-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/stylus.svg"></a>|![stylus-npm]|![stylus-size]|Loads and compiles a Stylus file|
|
226
226
|
|<a href="https://github.com/postcss/postcss-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/postcss.svg"></a>|![postcss-npm]|![postcss-size]|Loads and transforms a CSS/SSS file using [PostCSS](http://postcss.org)|
|
227
227
|
|
package/bin/webpack.js
CHANGED
@@ -50,6 +50,7 @@ const isInstalled = packageName => {
|
|
50
50
|
* @property {string} binName name of the executable file
|
51
51
|
* @property {string} alias shortcut for choice
|
52
52
|
* @property {boolean} installed currently installed?
|
53
|
+
* @property {boolean} recommended is recommended
|
53
54
|
* @property {string} url homepage
|
54
55
|
* @property {string} description description
|
55
56
|
*/
|
@@ -62,6 +63,7 @@ const CLIs = [
|
|
62
63
|
binName: "webpack-cli",
|
63
64
|
alias: "cli",
|
64
65
|
installed: isInstalled("webpack-cli"),
|
66
|
+
recommended: true,
|
65
67
|
url: "https://github.com/webpack/webpack-cli",
|
66
68
|
description: "The original webpack full-featured CLI."
|
67
69
|
},
|
@@ -71,6 +73,7 @@ const CLIs = [
|
|
71
73
|
binName: "webpack-command",
|
72
74
|
alias: "command",
|
73
75
|
installed: isInstalled("webpack-command"),
|
76
|
+
recommended: false,
|
74
77
|
url: "https://github.com/webpack-contrib/webpack-command",
|
75
78
|
description: "A lightweight, opinionated webpack CLI."
|
76
79
|
}
|
@@ -87,7 +90,9 @@ if (installedClis.length === 0) {
|
|
87
90
|
"One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:";
|
88
91
|
|
89
92
|
for (const item of CLIs) {
|
90
|
-
|
93
|
+
if (item.recommended) {
|
94
|
+
notify += `\n - ${item.name} (${item.url})\n ${item.description}`;
|
95
|
+
}
|
91
96
|
}
|
92
97
|
|
93
98
|
console.error(notify);
|
@@ -103,9 +108,7 @@ if (installedClis.length === 0) {
|
|
103
108
|
)}".`
|
104
109
|
);
|
105
110
|
|
106
|
-
let question = `
|
107
|
-
item => item.name
|
108
|
-
).join("/")}):\n`;
|
111
|
+
let question = `Do you want to install 'webpack-cli' (yes/no): `;
|
109
112
|
|
110
113
|
const questionInterface = readLine.createInterface({
|
111
114
|
input: process.stdin,
|
@@ -114,35 +117,22 @@ if (installedClis.length === 0) {
|
|
114
117
|
questionInterface.question(question, answer => {
|
115
118
|
questionInterface.close();
|
116
119
|
|
117
|
-
const normalizedAnswer = answer.toLowerCase();
|
118
|
-
const selectedPackage = CLIs.find(item => {
|
119
|
-
return item.name === normalizedAnswer || item.alias === normalizedAnswer;
|
120
|
-
});
|
120
|
+
const normalizedAnswer = answer.toLowerCase().startsWith("y");
|
121
121
|
|
122
122
|
if (!normalizedAnswer) {
|
123
123
|
console.error(
|
124
|
-
"
|
125
|
-
|
126
|
-
process.exitCode = 1;
|
127
|
-
|
128
|
-
return;
|
129
|
-
} else if (!selectedPackage) {
|
130
|
-
console.error(
|
131
|
-
"No matching choice.\n" +
|
132
|
-
"One CLI needs to be installed alongside webpack to use the CLI.\n" +
|
133
|
-
"Try to installing your CLI of choice manually."
|
124
|
+
"You need to install 'webpack-cli' to use webpack via CLI.\n" +
|
125
|
+
"You can also install the CLI manually."
|
134
126
|
);
|
135
127
|
process.exitCode = 1;
|
136
128
|
|
137
129
|
return;
|
138
130
|
}
|
139
131
|
|
140
|
-
const packageName =
|
132
|
+
const packageName = "webpack-cli";
|
141
133
|
|
142
134
|
console.log(
|
143
|
-
`Installing '${
|
144
|
-
selectedPackage.name
|
145
|
-
}' (running '${packageManager} ${installOptions.join(
|
135
|
+
`Installing '${packageName}' (running '${packageManager} ${installOptions.join(
|
146
136
|
" "
|
147
137
|
)} ${packageName}')...`
|
148
138
|
);
|
@@ -174,4 +164,5 @@ if (installedClis.length === 0) {
|
|
174
164
|
" and "
|
175
165
|
)} together. To work with the "webpack" command you need only one CLI package, please remove one of them or use them directly via their binary.`
|
176
166
|
);
|
167
|
+
process.exitCode = 1;
|
177
168
|
}
|
package/lib/ChunkTemplate.js
CHANGED
@@ -9,6 +9,7 @@ const { Tapable, SyncWaterfallHook, SyncHook } = require("tapable");
|
|
9
9
|
/** @typedef {import("./ModuleTemplate")} ModuleTemplate */
|
10
10
|
/** @typedef {import("./Chunk")} Chunk */
|
11
11
|
/** @typedef {import("./Module")} Module} */
|
12
|
+
/** @typedef {import("./Dependency").DependencyTemplate} DependencyTemplate} */
|
12
13
|
/** @typedef {import("./util/createHash").Hash} Hash} */
|
13
14
|
|
14
15
|
/**
|
@@ -71,12 +72,15 @@ module.exports = class ChunkTemplate extends Tapable {
|
|
71
72
|
}
|
72
73
|
|
73
74
|
/**
|
75
|
+
* TODO webpack 5: remove moduleTemplate and dependencyTemplates
|
74
76
|
* Updates hash with chunk-specific information from this template
|
75
77
|
* @param {Hash} hash the hash to update
|
76
78
|
* @param {Chunk} chunk the chunk
|
79
|
+
* @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
|
80
|
+
* @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
|
77
81
|
* @returns {void}
|
78
82
|
*/
|
79
|
-
updateHashForChunk(hash, chunk) {
|
83
|
+
updateHashForChunk(hash, chunk, moduleTemplate, dependencyTemplates) {
|
80
84
|
this.updateHash(hash);
|
81
85
|
this.hooks.hashForChunk.call(hash, chunk);
|
82
86
|
}
|
package/lib/Compilation.js
CHANGED
@@ -455,9 +455,10 @@ class Compilation extends Tapable {
|
|
455
455
|
this.children = [];
|
456
456
|
/** @type {Map<DepConstructor, ModuleFactory>} */
|
457
457
|
this.dependencyFactories = new Map();
|
458
|
-
/** @type {Map<DepConstructor
|
458
|
+
/** @type {Map<DepConstructor, DependencyTemplate>} */
|
459
459
|
this.dependencyTemplates = new Map();
|
460
460
|
// TODO refactor this in webpack 5 to a custom DependencyTemplates class with a hash property
|
461
|
+
// @ts-ignore
|
461
462
|
this.dependencyTemplates.set("hash", "");
|
462
463
|
this.childrenCounters = {};
|
463
464
|
/** @type {Set<number|string>} */
|
@@ -2259,7 +2260,12 @@ class Compilation extends Tapable {
|
|
2259
2260
|
const template = chunk.hasRuntime()
|
2260
2261
|
? this.mainTemplate
|
2261
2262
|
: this.chunkTemplate;
|
2262
|
-
template.updateHashForChunk(
|
2263
|
+
template.updateHashForChunk(
|
2264
|
+
chunkHash,
|
2265
|
+
chunk,
|
2266
|
+
this.moduleTemplates.javascript,
|
2267
|
+
this.dependencyTemplates
|
2268
|
+
);
|
2263
2269
|
this.hooks.chunkHash.call(chunk, chunkHash);
|
2264
2270
|
chunk.hash = chunkHash.digest(hashDigest);
|
2265
2271
|
hash.update(chunk.hash);
|
@@ -137,7 +137,12 @@ class JavascriptModulesPlugin {
|
|
137
137
|
: compilation.chunkTemplate;
|
138
138
|
hash.update(`${chunk.id} `);
|
139
139
|
hash.update(chunk.ids ? chunk.ids.join(",") : "");
|
140
|
-
template.updateHashForChunk(
|
140
|
+
template.updateHashForChunk(
|
141
|
+
hash,
|
142
|
+
chunk,
|
143
|
+
compilation.moduleTemplates.javascript,
|
144
|
+
compilation.dependencyTemplates
|
145
|
+
);
|
141
146
|
for (const m of chunk.modulesIterable) {
|
142
147
|
if (typeof m.source === "function") {
|
143
148
|
hash.update(m.hash);
|
package/lib/MainTemplate.js
CHANGED
@@ -361,14 +361,14 @@ module.exports = class MainTemplate extends Tapable {
|
|
361
361
|
}
|
362
362
|
|
363
363
|
/**
|
364
|
-
*
|
364
|
+
* TODO webpack 5: remove moduleTemplate and dependencyTemplates
|
365
365
|
* @param {string} hash hash to be used for render call
|
366
366
|
* @param {Chunk} chunk Chunk instance
|
367
367
|
* @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
|
368
368
|
* @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
|
369
|
-
* @returns {
|
369
|
+
* @returns {string[]} the generated source of the bootstrap code
|
370
370
|
*/
|
371
|
-
|
371
|
+
renderBootstrap(hash, chunk, moduleTemplate, dependencyTemplates) {
|
372
372
|
const buf = [];
|
373
373
|
buf.push(
|
374
374
|
this.hooks.bootstrap.call(
|
@@ -392,6 +392,23 @@ module.exports = class MainTemplate extends Tapable {
|
|
392
392
|
buf.push("");
|
393
393
|
buf.push(Template.asString(this.hooks.beforeStartup.call("", chunk, hash)));
|
394
394
|
buf.push(Template.asString(this.hooks.startup.call("", chunk, hash)));
|
395
|
+
return buf;
|
396
|
+
}
|
397
|
+
|
398
|
+
/**
|
399
|
+
* @param {string} hash hash to be used for render call
|
400
|
+
* @param {Chunk} chunk Chunk instance
|
401
|
+
* @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
|
402
|
+
* @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
|
403
|
+
* @returns {ConcatSource} the newly generated source from rendering
|
404
|
+
*/
|
405
|
+
render(hash, chunk, moduleTemplate, dependencyTemplates) {
|
406
|
+
const buf = this.renderBootstrap(
|
407
|
+
hash,
|
408
|
+
chunk,
|
409
|
+
moduleTemplate,
|
410
|
+
dependencyTemplates
|
411
|
+
);
|
395
412
|
let source = this.hooks.render.call(
|
396
413
|
new OriginalSource(
|
397
414
|
Template.prefix(buf, " \t") + "\n",
|
@@ -486,19 +503,29 @@ module.exports = class MainTemplate extends Tapable {
|
|
486
503
|
updateHash(hash) {
|
487
504
|
hash.update("maintemplate");
|
488
505
|
hash.update("3");
|
489
|
-
hash.update(this.outputOptions.publicPath + "");
|
490
506
|
this.hooks.hash.call(hash);
|
491
507
|
}
|
492
508
|
|
493
509
|
/**
|
510
|
+
* TODO webpack 5: remove moduleTemplate and dependencyTemplates
|
494
511
|
* Updates hash with chunk-specific information from this template
|
495
512
|
* @param {Hash} hash the hash to update
|
496
513
|
* @param {Chunk} chunk the chunk
|
514
|
+
* @param {ModuleTemplate} moduleTemplate ModuleTemplate instance for render
|
515
|
+
* @param {Map<Function, DependencyTemplate>} dependencyTemplates dependency templates
|
497
516
|
* @returns {void}
|
498
517
|
*/
|
499
|
-
updateHashForChunk(hash, chunk) {
|
518
|
+
updateHashForChunk(hash, chunk, moduleTemplate, dependencyTemplates) {
|
500
519
|
this.updateHash(hash);
|
501
520
|
this.hooks.hashForChunk.call(hash, chunk);
|
521
|
+
for (const line of this.renderBootstrap(
|
522
|
+
"0000",
|
523
|
+
chunk,
|
524
|
+
moduleTemplate,
|
525
|
+
dependencyTemplates
|
526
|
+
)) {
|
527
|
+
hash.update(line);
|
528
|
+
}
|
502
529
|
}
|
503
530
|
|
504
531
|
useChunkHash(chunk) {
|
@@ -315,9 +315,7 @@ module.exports = class NodeMainTemplatePlugin {
|
|
315
315
|
);
|
316
316
|
mainTemplate.hooks.hash.tap("NodeMainTemplatePlugin", hash => {
|
317
317
|
hash.update("node");
|
318
|
-
hash.update("
|
319
|
-
hash.update(mainTemplate.outputOptions.filename + "");
|
320
|
-
hash.update(mainTemplate.outputOptions.chunkFilename + "");
|
318
|
+
hash.update("4");
|
321
319
|
});
|
322
320
|
}
|
323
321
|
};
|
@@ -335,23 +335,8 @@ class WasmMainTemplatePlugin {
|
|
335
335
|
);
|
336
336
|
mainTemplate.hooks.hash.tap("WasmMainTemplatePlugin", hash => {
|
337
337
|
hash.update("WasmMainTemplatePlugin");
|
338
|
-
hash.update("
|
339
|
-
hash.update(`${mainTemplate.outputOptions.webassemblyModuleFilename}`);
|
340
|
-
hash.update(`${this.mangleImports}`);
|
338
|
+
hash.update("2");
|
341
339
|
});
|
342
|
-
mainTemplate.hooks.hashForChunk.tap(
|
343
|
-
"WasmMainTemplatePlugin",
|
344
|
-
(hash, chunk) => {
|
345
|
-
const chunkModuleMaps = chunk.getChunkModuleMaps(m =>
|
346
|
-
m.type.startsWith("webassembly")
|
347
|
-
);
|
348
|
-
hash.update(JSON.stringify(chunkModuleMaps.id));
|
349
|
-
const wasmModules = getAllWasmModules(chunk);
|
350
|
-
for (const module of wasmModules) {
|
351
|
-
hash.update(module.hash);
|
352
|
-
}
|
353
|
-
}
|
354
|
-
);
|
355
340
|
}
|
356
341
|
}
|
357
342
|
|
@@ -9,7 +9,6 @@ const Template = require("../Template");
|
|
9
9
|
const WebAssemblyUtils = require("./WebAssemblyUtils");
|
10
10
|
const { RawSource } = require("webpack-sources");
|
11
11
|
|
12
|
-
const { shrinkPaddedLEB128 } = require("@webassemblyjs/wasm-opt");
|
13
12
|
const { editWithAST, addWithAST } = require("@webassemblyjs/wasm-edit");
|
14
13
|
const { decode } = require("@webassemblyjs/wasm-parser");
|
15
14
|
const t = require("@webassemblyjs/ast");
|
@@ -30,17 +29,6 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
|
|
30
29
|
* @typedef {(ArrayBuffer) => ArrayBuffer} ArrayBufferTransform
|
31
30
|
*/
|
32
31
|
|
33
|
-
/**
|
34
|
-
* Run some preprocessing on the binary before wasm-edit
|
35
|
-
*
|
36
|
-
* @param {ArrayBuffer} ab - original binary
|
37
|
-
* @returns {ArrayBufferTransform} transform
|
38
|
-
*/
|
39
|
-
const preprocess = ab => {
|
40
|
-
const optBin = shrinkPaddedLEB128(new Uint8Array(ab));
|
41
|
-
return optBin.buffer;
|
42
|
-
};
|
43
|
-
|
44
32
|
/**
|
45
33
|
* @template T
|
46
34
|
* @param {Function[]} fns transforms
|
@@ -382,7 +370,6 @@ class WebAssemblyGenerator extends Generator {
|
|
382
370
|
*/
|
383
371
|
generate(module, dependencyTemplates, runtimeTemplate, type) {
|
384
372
|
let bin = module.originalSource().source();
|
385
|
-
bin = preprocess(bin);
|
386
373
|
|
387
374
|
const initFuncId = t.identifier(
|
388
375
|
Array.isArray(module.usedExports)
|
@@ -581,11 +581,7 @@ ${globalObject}[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
|
|
581
581
|
);
|
582
582
|
mainTemplate.hooks.hash.tap("JsonpMainTemplatePlugin", hash => {
|
583
583
|
hash.update("jsonp");
|
584
|
-
hash.update("
|
585
|
-
hash.update(`${mainTemplate.outputOptions.globalObject}`);
|
586
|
-
hash.update(`${mainTemplate.outputOptions.chunkFilename}`);
|
587
|
-
hash.update(`${mainTemplate.outputOptions.jsonpFunction}`);
|
588
|
-
hash.update(`${mainTemplate.outputOptions.hotUpdateFunction}`);
|
584
|
+
hash.update("6");
|
589
585
|
});
|
590
586
|
}
|
591
587
|
}
|
@@ -184,12 +184,7 @@ class WebWorkerMainTemplatePlugin {
|
|
184
184
|
);
|
185
185
|
mainTemplate.hooks.hash.tap("WebWorkerMainTemplatePlugin", hash => {
|
186
186
|
hash.update("webworker");
|
187
|
-
hash.update("
|
188
|
-
hash.update(`${mainTemplate.outputOptions.publicPath}`);
|
189
|
-
hash.update(`${mainTemplate.outputOptions.filename}`);
|
190
|
-
hash.update(`${mainTemplate.outputOptions.chunkFilename}`);
|
191
|
-
hash.update(`${mainTemplate.outputOptions.chunkCallbackName}`);
|
192
|
-
hash.update(`${mainTemplate.outputOptions.globalObject}`);
|
187
|
+
hash.update("4");
|
193
188
|
});
|
194
189
|
}
|
195
190
|
}
|
package/package.json
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.19.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",
|
7
7
|
"dependencies": {
|
8
|
-
"@webassemblyjs/ast": "1.
|
9
|
-
"@webassemblyjs/helper-module-context": "1.
|
10
|
-
"@webassemblyjs/wasm-edit": "1.
|
11
|
-
"@webassemblyjs/wasm-
|
12
|
-
"@webassemblyjs/wasm-parser": "1.5.13",
|
8
|
+
"@webassemblyjs/ast": "1.7.6",
|
9
|
+
"@webassemblyjs/helper-module-context": "1.7.6",
|
10
|
+
"@webassemblyjs/wasm-edit": "1.7.6",
|
11
|
+
"@webassemblyjs/wasm-parser": "1.7.6",
|
13
12
|
"acorn": "^5.6.2",
|
14
13
|
"acorn-dynamic-import": "^3.0.0",
|
15
14
|
"ajv": "^6.1.0",
|
@@ -26,7 +25,7 @@
|
|
26
25
|
"neo-async": "^2.5.0",
|
27
26
|
"node-libs-browser": "^2.0.0",
|
28
27
|
"schema-utils": "^0.4.4",
|
29
|
-
"tapable": "^1.
|
28
|
+
"tapable": "^1.1.0",
|
30
29
|
"uglifyjs-webpack-plugin": "^1.2.4",
|
31
30
|
"watchpack": "^1.5.0",
|
32
31
|
"webpack-sources": "^1.2.0"
|