webpack 5.96.1 → 5.97.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/lib/CssModule.js +5 -0
- package/lib/DependencyTemplate.js +2 -2
- package/lib/EvalSourceMapDevToolPlugin.js +5 -0
- package/lib/FalseIIFEUmdWarning.js +19 -0
- package/lib/HotModuleReplacementPlugin.js +4 -0
- package/lib/Module.js +6 -0
- package/lib/ModuleSourceTypesConstants.js +12 -0
- package/lib/NormalModule.js +1 -0
- package/lib/RuntimeTemplate.js +7 -0
- package/lib/SourceMapDevToolPlugin.js +8 -0
- package/lib/WebpackOptionsApply.js +3 -1
- package/lib/asset/AssetModulesPlugin.js +7 -2
- package/lib/config/defaults.js +52 -36
- package/lib/config/normalization.js +0 -1
- package/lib/config/target.js +8 -8
- package/lib/css/CssGenerator.js +139 -35
- package/lib/css/CssLoadingRuntimeModule.js +108 -198
- package/lib/css/CssModulesPlugin.js +78 -124
- package/lib/css/CssParser.js +545 -121
- package/lib/css/walkCssTokens.js +41 -19
- package/lib/dependencies/CachedConstDependency.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +3 -2
- package/lib/dependencies/{CssExportDependency.js → CssIcssExportDependency.js} +35 -35
- package/lib/dependencies/CssIcssImportDependency.js +118 -0
- package/lib/dependencies/CssIcssSymbolDependency.js +132 -0
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +69 -73
- package/lib/dependencies/CssUrlDependency.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +8 -4
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +17 -10
- package/lib/index.js +9 -3
- package/lib/javascript/EnableChunkLoadingPlugin.js +2 -4
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/EnableLibraryPlugin.js +17 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +81 -78
- package/lib/node/ReadFileCompileWasmPlugin.js +76 -57
- package/lib/optimize/MergeDuplicateChunksPlugin.js +22 -2
- package/lib/sharing/ConsumeSharedPlugin.js +35 -12
- package/lib/sharing/utils.js +35 -4
- package/lib/stats/DefaultStatsFactoryPlugin.js +0 -5
- package/lib/util/Queue.js +52 -24
- package/lib/util/generateDebugId.js +33 -0
- package/lib/util/internalSerializables.js +6 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +36 -25
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +26 -2
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +103 -0
- package/lib/wasm-sync/WebAssemblyParser.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +43 -44
- package/lib/web/FetchCompileWasmPlugin.js +4 -4
- package/package.json +4 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +34 -12
- package/schemas/plugins/BannerPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
- package/schemas/plugins/css/CssAutoParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +7 -0
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +6 -0
- package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.json +11 -0
- package/types.d.ts +84 -23
- package/lib/css/CssExportsGenerator.js +0 -207
@@ -0,0 +1,103 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Alexander Akait @alexander-akait
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
|
9
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
10
|
+
const Template = require("../Template");
|
11
|
+
const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
|
12
|
+
|
13
|
+
/** @typedef {import("../Chunk")} Chunk */
|
14
|
+
/** @typedef {import("../Compiler")} Compiler */
|
15
|
+
|
16
|
+
const PLUGIN_NAME = "UniversalCompileAsyncWasmPlugin";
|
17
|
+
|
18
|
+
class UniversalCompileAsyncWasmPlugin {
|
19
|
+
/**
|
20
|
+
* Apply the plugin
|
21
|
+
* @param {Compiler} compiler the compiler instance
|
22
|
+
* @returns {void}
|
23
|
+
*/
|
24
|
+
apply(compiler) {
|
25
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
26
|
+
const globalWasmLoading = compilation.outputOptions.wasmLoading;
|
27
|
+
/**
|
28
|
+
* @param {Chunk} chunk chunk
|
29
|
+
* @returns {boolean} true, if wasm loading is enabled for the chunk
|
30
|
+
*/
|
31
|
+
const isEnabledForChunk = chunk => {
|
32
|
+
const options = chunk.getEntryOptions();
|
33
|
+
const wasmLoading =
|
34
|
+
options && options.wasmLoading !== undefined
|
35
|
+
? options.wasmLoading
|
36
|
+
: globalWasmLoading;
|
37
|
+
return wasmLoading === "universal";
|
38
|
+
};
|
39
|
+
const generateBeforeInstantiateStreaming = () =>
|
40
|
+
Template.asString([
|
41
|
+
"if (!useFetch) {",
|
42
|
+
Template.indent(["return fallback();"]),
|
43
|
+
"}"
|
44
|
+
]);
|
45
|
+
const generateBeforeLoadBinaryCode = path =>
|
46
|
+
Template.asString([
|
47
|
+
"var useFetch = typeof document !== 'undefined' || typeof self !== 'undefined';",
|
48
|
+
`var wasmUrl = ${path};`
|
49
|
+
]);
|
50
|
+
/**
|
51
|
+
* @type {(path: string) => string}
|
52
|
+
*/
|
53
|
+
const generateLoadBinaryCode = () =>
|
54
|
+
Template.asString([
|
55
|
+
"(useFetch",
|
56
|
+
Template.indent([
|
57
|
+
`? fetch(new URL(wasmUrl, ${compilation.outputOptions.importMetaName}.url))`
|
58
|
+
]),
|
59
|
+
Template.indent([
|
60
|
+
": Promise.all([import('fs'), import('url')]).then(([{ readFile }, { URL }]) => new Promise((resolve, reject) => {",
|
61
|
+
Template.indent([
|
62
|
+
`readFile(new URL(wasmUrl, ${compilation.outputOptions.importMetaName}.url), (err, buffer) => {`,
|
63
|
+
Template.indent([
|
64
|
+
"if (err) return reject(err);",
|
65
|
+
"",
|
66
|
+
"// Fake fetch response",
|
67
|
+
"resolve({",
|
68
|
+
Template.indent(["arrayBuffer() { return buffer; }"]),
|
69
|
+
"});"
|
70
|
+
]),
|
71
|
+
"});"
|
72
|
+
]),
|
73
|
+
"})))"
|
74
|
+
])
|
75
|
+
]);
|
76
|
+
|
77
|
+
compilation.hooks.runtimeRequirementInTree
|
78
|
+
.for(RuntimeGlobals.instantiateWasm)
|
79
|
+
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
80
|
+
if (!isEnabledForChunk(chunk)) return;
|
81
|
+
if (
|
82
|
+
!chunkGraph.hasModuleInGraph(
|
83
|
+
chunk,
|
84
|
+
m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
|
85
|
+
)
|
86
|
+
) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
compilation.addRuntimeModule(
|
90
|
+
chunk,
|
91
|
+
new AsyncWasmLoadingRuntimeModule({
|
92
|
+
generateBeforeLoadBinaryCode,
|
93
|
+
generateLoadBinaryCode,
|
94
|
+
generateBeforeInstantiateStreaming,
|
95
|
+
supportsStreaming: true
|
96
|
+
})
|
97
|
+
);
|
98
|
+
});
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
module.exports = UniversalCompileAsyncWasmPlugin;
|
@@ -19,7 +19,7 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDe
|
|
19
19
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
20
20
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
21
21
|
|
22
|
-
const JS_COMPAT_TYPES = new Set(["i32", "i64", "f32", "f64"]);
|
22
|
+
const JS_COMPAT_TYPES = new Set(["i32", "i64", "f32", "f64", "externref"]);
|
23
23
|
|
24
24
|
/**
|
25
25
|
* @param {t.Signature} signature the func signature
|
@@ -12,6 +12,8 @@ const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRun
|
|
12
12
|
/** @typedef {import("../Chunk")} Chunk */
|
13
13
|
/** @typedef {import("../Compiler")} Compiler */
|
14
14
|
|
15
|
+
const PLUGIN_NAME = "FetchCompileAsyncWasmPlugin";
|
16
|
+
|
15
17
|
class FetchCompileAsyncWasmPlugin {
|
16
18
|
/**
|
17
19
|
* Apply the plugin
|
@@ -19,52 +21,49 @@ class FetchCompileAsyncWasmPlugin {
|
|
19
21
|
* @returns {void}
|
20
22
|
*/
|
21
23
|
apply(compiler) {
|
22
|
-
compiler.hooks.thisCompilation.tap(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
const
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
const generateLoadBinaryCode = path =>
|
43
|
-
`fetch(${RuntimeGlobals.publicPath} + ${path})`;
|
24
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
25
|
+
const globalWasmLoading = compilation.outputOptions.wasmLoading;
|
26
|
+
/**
|
27
|
+
* @param {Chunk} chunk chunk
|
28
|
+
* @returns {boolean} true, if wasm loading is enabled for the chunk
|
29
|
+
*/
|
30
|
+
const isEnabledForChunk = chunk => {
|
31
|
+
const options = chunk.getEntryOptions();
|
32
|
+
const wasmLoading =
|
33
|
+
options && options.wasmLoading !== undefined
|
34
|
+
? options.wasmLoading
|
35
|
+
: globalWasmLoading;
|
36
|
+
return wasmLoading === "fetch";
|
37
|
+
};
|
38
|
+
/**
|
39
|
+
* @param {string} path path to the wasm file
|
40
|
+
* @returns {string} code to load the wasm file
|
41
|
+
*/
|
42
|
+
const generateLoadBinaryCode = path =>
|
43
|
+
`fetch(${RuntimeGlobals.publicPath} + ${path})`;
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
chunk,
|
52
|
-
m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
|
53
|
-
)
|
54
|
-
) {
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
set.add(RuntimeGlobals.publicPath);
|
58
|
-
compilation.addRuntimeModule(
|
45
|
+
compilation.hooks.runtimeRequirementInTree
|
46
|
+
.for(RuntimeGlobals.instantiateWasm)
|
47
|
+
.tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
|
48
|
+
if (!isEnabledForChunk(chunk)) return;
|
49
|
+
if (
|
50
|
+
!chunkGraph.hasModuleInGraph(
|
59
51
|
chunk,
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
52
|
+
m => m.type === WEBASSEMBLY_MODULE_TYPE_ASYNC
|
53
|
+
)
|
54
|
+
) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
set.add(RuntimeGlobals.publicPath);
|
58
|
+
compilation.addRuntimeModule(
|
59
|
+
chunk,
|
60
|
+
new AsyncWasmLoadingRuntimeModule({
|
61
|
+
generateLoadBinaryCode,
|
62
|
+
supportsStreaming: true
|
63
|
+
})
|
64
|
+
);
|
65
|
+
});
|
66
|
+
});
|
68
67
|
}
|
69
68
|
}
|
70
69
|
|
@@ -12,15 +12,15 @@ const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRunt
|
|
12
12
|
/** @typedef {import("../Chunk")} Chunk */
|
13
13
|
/** @typedef {import("../Compiler")} Compiler */
|
14
14
|
|
15
|
-
// TODO webpack 6 remove
|
16
|
-
|
17
|
-
const PLUGIN_NAME = "FetchCompileWasmPlugin";
|
18
|
-
|
19
15
|
/**
|
20
16
|
* @typedef {object} FetchCompileWasmPluginOptions
|
21
17
|
* @property {boolean} [mangleImports] mangle imports
|
22
18
|
*/
|
23
19
|
|
20
|
+
// TODO webpack 6 remove
|
21
|
+
|
22
|
+
const PLUGIN_NAME = "FetchCompileWasmPlugin";
|
23
|
+
|
24
24
|
class FetchCompileWasmPlugin {
|
25
25
|
/**
|
26
26
|
* @param {FetchCompileWasmPluginOptions} [options] options
|
package/package.json
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.97.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
7
7
|
"dependencies": {
|
8
8
|
"@types/eslint-scope": "^3.7.7",
|
9
9
|
"@types/estree": "^1.0.6",
|
10
|
-
"@webassemblyjs/ast": "^1.
|
11
|
-
"@webassemblyjs/wasm-edit": "^1.
|
12
|
-
"@webassemblyjs/wasm-parser": "^1.
|
10
|
+
"@webassemblyjs/ast": "^1.14.1",
|
11
|
+
"@webassemblyjs/wasm-edit": "^1.14.1",
|
12
|
+
"@webassemblyjs/wasm-parser": "^1.14.1",
|
13
13
|
"acorn": "^8.14.0",
|
14
14
|
"browserslist": "^4.24.0",
|
15
15
|
"chrome-trace-event": "^1.0.2",
|