webpack 5.77.0 → 5.79.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 +0 -0
- package/lib/APIPlugin.js +25 -18
- package/lib/CompatibilityPlugin.js +80 -62
- package/lib/Compiler.js +7 -4
- package/lib/ConstPlugin.js +22 -15
- package/lib/ContextModule.js +3 -2
- package/lib/DefinePlugin.js +62 -42
- package/lib/DelegatedModule.js +2 -1
- package/lib/DllModule.js +2 -1
- package/lib/ErrorHelpers.js +61 -22
- package/lib/ExportsInfoApiPlugin.js +16 -9
- package/lib/ExternalModule.js +2 -1
- package/lib/FlagAllModulesAsUsedPlugin.js +22 -27
- package/lib/FlagDependencyExportsPlugin.js +336 -348
- package/lib/FlagDependencyUsagePlugin.js +6 -8
- package/lib/FlagEntryExportAsUsedPlugin.js +22 -23
- package/lib/HotModuleReplacementPlugin.js +50 -45
- package/lib/JavascriptMetaInfoPlugin.js +16 -9
- package/lib/LibManifestPlugin.js +2 -1
- package/lib/ModuleTypeConstants.js +50 -0
- package/lib/NodeStuffPlugin.js +35 -31
- package/lib/NormalModule.js +2 -1
- package/lib/NormalModuleFactory.js +7 -1
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/ProvidePlugin.js +17 -10
- package/lib/RawModule.js +2 -1
- package/lib/RequireJsStuffPlugin.js +15 -15
- package/lib/UseStrictPlugin.js +15 -8
- package/lib/WebpackIsIncludedPlugin.js +16 -9
- package/lib/config/defaults.js +16 -8
- package/lib/config/normalization.js +4 -0
- package/lib/container/ContainerEntryModule.js +2 -1
- package/lib/css/CssLoadingRuntimeModule.js +1 -1
- package/lib/css/CssParser.js +28 -8
- package/lib/css/walkCssTokens.js +6 -1
- package/lib/debug/ProfilingPlugin.js +20 -12
- package/lib/dependencies/AMDPlugin.js +26 -20
- package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -4
- package/lib/dependencies/CommonJsPlugin.js +29 -25
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +28 -3
- package/lib/dependencies/HarmonyModulesPlugin.js +11 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +11 -5
- package/lib/dependencies/ImportMetaPlugin.js +26 -20
- package/lib/dependencies/ImportPlugin.js +14 -7
- package/lib/dependencies/RequireContextPlugin.js +12 -6
- package/lib/dependencies/RequireEnsurePlugin.js +13 -7
- package/lib/dependencies/RequireIncludePlugin.js +11 -5
- package/lib/dependencies/SystemPlugin.js +21 -15
- package/lib/dependencies/URLPlugin.js +15 -9
- package/lib/dependencies/WorkerPlugin.js +14 -8
- package/lib/index.js +5 -0
- package/lib/javascript/JavascriptModulesPlugin.js +157 -164
- package/lib/javascript/JavascriptParser.js +88 -0
- package/lib/json/JsonModulesPlugin.js +13 -5
- package/lib/library/AmdLibraryPlugin.js +22 -6
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +2 -1
- package/lib/optimize/ConcatenatedModule.js +2 -1
- package/lib/optimize/InnerGraphPlugin.js +47 -46
- package/lib/optimize/SideEffectsFlagPlugin.js +43 -43
- package/lib/sharing/ConsumeSharedPlugin.js +4 -0
- package/lib/stats/DefaultStatsPrinterPlugin.js +14 -0
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +9 -6
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +42 -43
- package/lib/web/FetchCompileAsyncWasmPlugin.js +2 -1
- package/lib/web/FetchCompileWasmPlugin.js +40 -40
- package/lib/webpack.js +1 -1
- package/package.json +41 -36
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +18 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +8 -0
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +8 -0
- package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
- package/types.d.ts +152 -122
@@ -5,6 +5,11 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
11
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
12
|
+
} = require("../ModuleTypeConstants");
|
8
13
|
const ImportContextDependency = require("./ImportContextDependency");
|
9
14
|
const ImportDependency = require("./ImportDependency");
|
10
15
|
const ImportEagerDependency = require("./ImportEagerDependency");
|
@@ -13,6 +18,8 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
|
13
18
|
|
14
19
|
/** @typedef {import("../Compiler")} Compiler */
|
15
20
|
|
21
|
+
const PLUGIN_NAME = "ImportPlugin";
|
22
|
+
|
16
23
|
class ImportPlugin {
|
17
24
|
/**
|
18
25
|
* Apply the plugin
|
@@ -21,7 +28,7 @@ class ImportPlugin {
|
|
21
28
|
*/
|
22
29
|
apply(compiler) {
|
23
30
|
compiler.hooks.compilation.tap(
|
24
|
-
|
31
|
+
PLUGIN_NAME,
|
25
32
|
(compilation, { contextModuleFactory, normalModuleFactory }) => {
|
26
33
|
compilation.dependencyFactories.set(
|
27
34
|
ImportDependency,
|
@@ -67,14 +74,14 @@ class ImportPlugin {
|
|
67
74
|
};
|
68
75
|
|
69
76
|
normalModuleFactory.hooks.parser
|
70
|
-
.for(
|
71
|
-
.tap(
|
77
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
78
|
+
.tap(PLUGIN_NAME, handler);
|
72
79
|
normalModuleFactory.hooks.parser
|
73
|
-
.for(
|
74
|
-
.tap(
|
80
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
81
|
+
.tap(PLUGIN_NAME, handler);
|
75
82
|
normalModuleFactory.hooks.parser
|
76
|
-
.for(
|
77
|
-
.tap(
|
83
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
84
|
+
.tap(PLUGIN_NAME, handler);
|
78
85
|
}
|
79
86
|
);
|
80
87
|
}
|
@@ -5,6 +5,10 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
11
|
+
} = require("../ModuleTypeConstants");
|
8
12
|
const { cachedSetProperty } = require("../util/cleverMerge");
|
9
13
|
const ContextElementDependency = require("./ContextElementDependency");
|
10
14
|
const RequireContextDependency = require("./RequireContextDependency");
|
@@ -16,6 +20,8 @@ const RequireContextDependencyParserPlugin = require("./RequireContextDependency
|
|
16
20
|
/** @type {ResolveOptions} */
|
17
21
|
const EMPTY_RESOLVE_OPTIONS = {};
|
18
22
|
|
23
|
+
const PLUGIN_NAME = "RequireContextPlugin";
|
24
|
+
|
19
25
|
class RequireContextPlugin {
|
20
26
|
/**
|
21
27
|
* Apply the plugin
|
@@ -24,7 +30,7 @@ class RequireContextPlugin {
|
|
24
30
|
*/
|
25
31
|
apply(compiler) {
|
26
32
|
compiler.hooks.compilation.tap(
|
27
|
-
|
33
|
+
PLUGIN_NAME,
|
28
34
|
(compilation, { contextModuleFactory, normalModuleFactory }) => {
|
29
35
|
compilation.dependencyFactories.set(
|
30
36
|
RequireContextDependency,
|
@@ -51,14 +57,14 @@ class RequireContextPlugin {
|
|
51
57
|
};
|
52
58
|
|
53
59
|
normalModuleFactory.hooks.parser
|
54
|
-
.for(
|
55
|
-
.tap(
|
60
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
61
|
+
.tap(PLUGIN_NAME, handler);
|
56
62
|
normalModuleFactory.hooks.parser
|
57
|
-
.for(
|
58
|
-
.tap(
|
63
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
64
|
+
.tap(PLUGIN_NAME, handler);
|
59
65
|
|
60
66
|
contextModuleFactory.hooks.alternativeRequests.tap(
|
61
|
-
|
67
|
+
PLUGIN_NAME,
|
62
68
|
(items, options) => {
|
63
69
|
if (items.length === 0) return items;
|
64
70
|
|
@@ -10,15 +10,21 @@ const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
|
10
10
|
|
11
11
|
const RequireEnsureDependenciesBlockParserPlugin = require("./RequireEnsureDependenciesBlockParserPlugin");
|
12
12
|
|
13
|
+
const {
|
14
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
15
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
16
|
+
} = require("../ModuleTypeConstants");
|
13
17
|
const {
|
14
18
|
evaluateToString,
|
15
19
|
toConstantDependency
|
16
20
|
} = require("../javascript/JavascriptParserHelpers");
|
17
21
|
|
22
|
+
const PLUGIN_NAME = "RequireEnsurePlugin";
|
23
|
+
|
18
24
|
class RequireEnsurePlugin {
|
19
25
|
apply(compiler) {
|
20
26
|
compiler.hooks.compilation.tap(
|
21
|
-
|
27
|
+
PLUGIN_NAME,
|
22
28
|
(compilation, { normalModuleFactory }) => {
|
23
29
|
compilation.dependencyFactories.set(
|
24
30
|
RequireEnsureItemDependency,
|
@@ -44,21 +50,21 @@ class RequireEnsurePlugin {
|
|
44
50
|
new RequireEnsureDependenciesBlockParserPlugin().apply(parser);
|
45
51
|
parser.hooks.evaluateTypeof
|
46
52
|
.for("require.ensure")
|
47
|
-
.tap(
|
53
|
+
.tap(PLUGIN_NAME, evaluateToString("function"));
|
48
54
|
parser.hooks.typeof
|
49
55
|
.for("require.ensure")
|
50
56
|
.tap(
|
51
|
-
|
57
|
+
PLUGIN_NAME,
|
52
58
|
toConstantDependency(parser, JSON.stringify("function"))
|
53
59
|
);
|
54
60
|
};
|
55
61
|
|
56
62
|
normalModuleFactory.hooks.parser
|
57
|
-
.for(
|
58
|
-
.tap(
|
63
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
64
|
+
.tap(PLUGIN_NAME, handler);
|
59
65
|
normalModuleFactory.hooks.parser
|
60
|
-
.for(
|
61
|
-
.tap(
|
66
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
67
|
+
.tap(PLUGIN_NAME, handler);
|
62
68
|
}
|
63
69
|
);
|
64
70
|
}
|
@@ -5,13 +5,19 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
11
|
+
} = require("../ModuleTypeConstants");
|
8
12
|
const RequireIncludeDependency = require("./RequireIncludeDependency");
|
9
13
|
const RequireIncludeDependencyParserPlugin = require("./RequireIncludeDependencyParserPlugin");
|
10
14
|
|
15
|
+
const PLUGIN_NAME = "RequireIncludePlugin";
|
16
|
+
|
11
17
|
class RequireIncludePlugin {
|
12
18
|
apply(compiler) {
|
13
19
|
compiler.hooks.compilation.tap(
|
14
|
-
|
20
|
+
PLUGIN_NAME,
|
15
21
|
(compilation, { normalModuleFactory }) => {
|
16
22
|
compilation.dependencyFactories.set(
|
17
23
|
RequireIncludeDependency,
|
@@ -30,11 +36,11 @@ class RequireIncludePlugin {
|
|
30
36
|
};
|
31
37
|
|
32
38
|
normalModuleFactory.hooks.parser
|
33
|
-
.for(
|
34
|
-
.tap(
|
39
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
40
|
+
.tap(PLUGIN_NAME, handler);
|
35
41
|
normalModuleFactory.hooks.parser
|
36
|
-
.for(
|
37
|
-
.tap(
|
42
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
43
|
+
.tap(PLUGIN_NAME, handler);
|
38
44
|
}
|
39
45
|
);
|
40
46
|
}
|
@@ -5,6 +5,10 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
11
|
+
} = require("../ModuleTypeConstants");
|
8
12
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
13
|
const WebpackError = require("../WebpackError");
|
10
14
|
const {
|
@@ -18,6 +22,8 @@ const SystemRuntimeModule = require("./SystemRuntimeModule");
|
|
18
22
|
|
19
23
|
/** @typedef {import("../Compiler")} Compiler */
|
20
24
|
|
25
|
+
const PLUGIN_NAME = "SystemPlugin";
|
26
|
+
|
21
27
|
class SystemPlugin {
|
22
28
|
/**
|
23
29
|
* Apply the plugin
|
@@ -26,17 +32,17 @@ class SystemPlugin {
|
|
26
32
|
*/
|
27
33
|
apply(compiler) {
|
28
34
|
compiler.hooks.compilation.tap(
|
29
|
-
|
35
|
+
PLUGIN_NAME,
|
30
36
|
(compilation, { normalModuleFactory }) => {
|
31
37
|
compilation.hooks.runtimeRequirementInModule
|
32
38
|
.for(RuntimeGlobals.system)
|
33
|
-
.tap(
|
39
|
+
.tap(PLUGIN_NAME, (module, set) => {
|
34
40
|
set.add(RuntimeGlobals.requireScope);
|
35
41
|
});
|
36
42
|
|
37
43
|
compilation.hooks.runtimeRequirementInTree
|
38
44
|
.for(RuntimeGlobals.system)
|
39
|
-
.tap(
|
45
|
+
.tap(PLUGIN_NAME, (chunk, set) => {
|
40
46
|
compilation.addRuntimeModule(chunk, new SystemRuntimeModule());
|
41
47
|
});
|
42
48
|
|
@@ -48,11 +54,11 @@ class SystemPlugin {
|
|
48
54
|
const setNotSupported = name => {
|
49
55
|
parser.hooks.evaluateTypeof
|
50
56
|
.for(name)
|
51
|
-
.tap(
|
57
|
+
.tap(PLUGIN_NAME, evaluateToString("undefined"));
|
52
58
|
parser.hooks.expression
|
53
59
|
.for(name)
|
54
60
|
.tap(
|
55
|
-
|
61
|
+
PLUGIN_NAME,
|
56
62
|
expressionIsUnsupported(
|
57
63
|
parser,
|
58
64
|
name + " is not supported by webpack."
|
@@ -63,27 +69,27 @@ class SystemPlugin {
|
|
63
69
|
parser.hooks.typeof
|
64
70
|
.for("System.import")
|
65
71
|
.tap(
|
66
|
-
|
72
|
+
PLUGIN_NAME,
|
67
73
|
toConstantDependency(parser, JSON.stringify("function"))
|
68
74
|
);
|
69
75
|
parser.hooks.evaluateTypeof
|
70
76
|
.for("System.import")
|
71
|
-
.tap(
|
77
|
+
.tap(PLUGIN_NAME, evaluateToString("function"));
|
72
78
|
parser.hooks.typeof
|
73
79
|
.for("System")
|
74
80
|
.tap(
|
75
|
-
|
81
|
+
PLUGIN_NAME,
|
76
82
|
toConstantDependency(parser, JSON.stringify("object"))
|
77
83
|
);
|
78
84
|
parser.hooks.evaluateTypeof
|
79
85
|
.for("System")
|
80
|
-
.tap(
|
86
|
+
.tap(PLUGIN_NAME, evaluateToString("object"));
|
81
87
|
|
82
88
|
setNotSupported("System.set");
|
83
89
|
setNotSupported("System.get");
|
84
90
|
setNotSupported("System.register");
|
85
91
|
|
86
|
-
parser.hooks.expression.for("System").tap(
|
92
|
+
parser.hooks.expression.for("System").tap(PLUGIN_NAME, expr => {
|
87
93
|
const dep = new ConstDependency(RuntimeGlobals.system, expr.range, [
|
88
94
|
RuntimeGlobals.system
|
89
95
|
]);
|
@@ -92,7 +98,7 @@ class SystemPlugin {
|
|
92
98
|
return true;
|
93
99
|
});
|
94
100
|
|
95
|
-
parser.hooks.call.for("System.import").tap(
|
101
|
+
parser.hooks.call.for("System.import").tap(PLUGIN_NAME, expr => {
|
96
102
|
parser.state.module.addWarning(
|
97
103
|
new SystemImportDeprecationWarning(expr.loc)
|
98
104
|
);
|
@@ -107,11 +113,11 @@ class SystemPlugin {
|
|
107
113
|
};
|
108
114
|
|
109
115
|
normalModuleFactory.hooks.parser
|
110
|
-
.for(
|
111
|
-
.tap(
|
116
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
117
|
+
.tap(PLUGIN_NAME, handler);
|
112
118
|
normalModuleFactory.hooks.parser
|
113
|
-
.for(
|
114
|
-
.tap(
|
119
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
120
|
+
.tap(PLUGIN_NAME, handler);
|
115
121
|
}
|
116
122
|
);
|
117
123
|
}
|
@@ -6,6 +6,10 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const { pathToFileURL } = require("url");
|
9
|
+
const {
|
10
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
11
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
12
|
+
} = require("../ModuleTypeConstants");
|
9
13
|
const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression");
|
10
14
|
const { approve } = require("../javascript/JavascriptParserHelpers");
|
11
15
|
const InnerGraph = require("../optimize/InnerGraph");
|
@@ -16,13 +20,15 @@ const URLDependency = require("./URLDependency");
|
|
16
20
|
/** @typedef {import("../NormalModule")} NormalModule */
|
17
21
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
18
22
|
|
23
|
+
const PLUGIN_NAME = "URLPlugin";
|
24
|
+
|
19
25
|
class URLPlugin {
|
20
26
|
/**
|
21
27
|
* @param {Compiler} compiler compiler
|
22
28
|
*/
|
23
29
|
apply(compiler) {
|
24
30
|
compiler.hooks.compilation.tap(
|
25
|
-
|
31
|
+
PLUGIN_NAME,
|
26
32
|
(compilation, { normalModuleFactory }) => {
|
27
33
|
compilation.dependencyFactories.set(URLDependency, normalModuleFactory);
|
28
34
|
compilation.dependencyTemplates.set(
|
@@ -76,10 +82,10 @@ class URLPlugin {
|
|
76
82
|
return request;
|
77
83
|
};
|
78
84
|
|
79
|
-
parser.hooks.canRename.for("URL").tap(
|
85
|
+
parser.hooks.canRename.for("URL").tap(PLUGIN_NAME, approve);
|
80
86
|
parser.hooks.evaluateNewExpression
|
81
87
|
.for("URL")
|
82
|
-
.tap(
|
88
|
+
.tap(PLUGIN_NAME, expr => {
|
83
89
|
const request = getUrlRequest(expr);
|
84
90
|
if (!request) return;
|
85
91
|
const url = new URL(request, getUrl(parser.state.module));
|
@@ -88,7 +94,7 @@ class URLPlugin {
|
|
88
94
|
.setString(url.toString())
|
89
95
|
.setRange(expr.range);
|
90
96
|
});
|
91
|
-
parser.hooks.new.for("URL").tap(
|
97
|
+
parser.hooks.new.for("URL").tap(PLUGIN_NAME, _expr => {
|
92
98
|
const expr = /** @type {NewExpressionNode} */ (_expr);
|
93
99
|
|
94
100
|
const request = getUrlRequest(expr);
|
@@ -107,7 +113,7 @@ class URLPlugin {
|
|
107
113
|
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e));
|
108
114
|
return true;
|
109
115
|
});
|
110
|
-
parser.hooks.isPure.for("NewExpression").tap(
|
116
|
+
parser.hooks.isPure.for("NewExpression").tap(PLUGIN_NAME, _expr => {
|
111
117
|
const expr = /** @type {NewExpressionNode} */ (_expr);
|
112
118
|
const { callee } = expr;
|
113
119
|
if (callee.type !== "Identifier") return;
|
@@ -121,12 +127,12 @@ class URLPlugin {
|
|
121
127
|
};
|
122
128
|
|
123
129
|
normalModuleFactory.hooks.parser
|
124
|
-
.for(
|
125
|
-
.tap(
|
130
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
131
|
+
.tap(PLUGIN_NAME, parserCallback);
|
126
132
|
|
127
133
|
normalModuleFactory.hooks.parser
|
128
|
-
.for(
|
129
|
-
.tap(
|
134
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
135
|
+
.tap(PLUGIN_NAME, parserCallback);
|
130
136
|
}
|
131
137
|
);
|
132
138
|
}
|
@@ -8,6 +8,10 @@
|
|
8
8
|
const { pathToFileURL } = require("url");
|
9
9
|
const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
10
10
|
const CommentCompilationWarning = require("../CommentCompilationWarning");
|
11
|
+
const {
|
12
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
13
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
14
|
+
} = require("../ModuleTypeConstants");
|
11
15
|
const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
|
12
16
|
const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin");
|
13
17
|
const { equals } = require("../util/ArrayHelpers");
|
@@ -47,6 +51,8 @@ const DEFAULT_SYNTAX = [
|
|
47
51
|
/** @type {WeakMap<ParserState, number>} */
|
48
52
|
const workerIndexMap = new WeakMap();
|
49
53
|
|
54
|
+
const PLUGIN_NAME = "WorkerPlugin";
|
55
|
+
|
50
56
|
class WorkerPlugin {
|
51
57
|
constructor(chunkLoading, wasmLoading, module, workerPublicPath) {
|
52
58
|
this._chunkLoading = chunkLoading;
|
@@ -71,7 +77,7 @@ class WorkerPlugin {
|
|
71
77
|
compiler.root
|
72
78
|
);
|
73
79
|
compiler.hooks.thisCompilation.tap(
|
74
|
-
|
80
|
+
PLUGIN_NAME,
|
75
81
|
(compilation, { normalModuleFactory }) => {
|
76
82
|
compilation.dependencyFactories.set(
|
77
83
|
WorkerDependency,
|
@@ -375,7 +381,7 @@ class WorkerPlugin {
|
|
375
381
|
if (item.endsWith("()")) {
|
376
382
|
parser.hooks.call
|
377
383
|
.for(item.slice(0, -2))
|
378
|
-
.tap(
|
384
|
+
.tap(PLUGIN_NAME, handleNewWorker);
|
379
385
|
} else {
|
380
386
|
const match = /^(.+?)(\(\))?\s+from\s+(.+)$/.exec(item);
|
381
387
|
if (match) {
|
@@ -384,7 +390,7 @@ class WorkerPlugin {
|
|
384
390
|
const source = match[3];
|
385
391
|
(call ? parser.hooks.call : parser.hooks.new)
|
386
392
|
.for(harmonySpecifierTag)
|
387
|
-
.tap(
|
393
|
+
.tap(PLUGIN_NAME, expr => {
|
388
394
|
const settings = /** @type {HarmonySettings} */ (
|
389
395
|
parser.currentTagData
|
390
396
|
);
|
@@ -398,7 +404,7 @@ class WorkerPlugin {
|
|
398
404
|
return handleNewWorker(expr);
|
399
405
|
});
|
400
406
|
} else {
|
401
|
-
parser.hooks.new.for(item).tap(
|
407
|
+
parser.hooks.new.for(item).tap(PLUGIN_NAME, handleNewWorker);
|
402
408
|
}
|
403
409
|
}
|
404
410
|
};
|
@@ -409,11 +415,11 @@ class WorkerPlugin {
|
|
409
415
|
}
|
410
416
|
};
|
411
417
|
normalModuleFactory.hooks.parser
|
412
|
-
.for(
|
413
|
-
.tap(
|
418
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
419
|
+
.tap(PLUGIN_NAME, parserPlugin);
|
414
420
|
normalModuleFactory.hooks.parser
|
415
|
-
.for(
|
416
|
-
.tap(
|
421
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
422
|
+
.tap(PLUGIN_NAME, parserPlugin);
|
417
423
|
}
|
418
424
|
);
|
419
425
|
}
|
package/lib/index.js
CHANGED
@@ -11,6 +11,11 @@ const memoize = require("./util/memoize");
|
|
11
11
|
/** @typedef {import("../declarations/WebpackOptions").Entry} Entry */
|
12
12
|
/** @typedef {import("../declarations/WebpackOptions").EntryNormalized} EntryNormalized */
|
13
13
|
/** @typedef {import("../declarations/WebpackOptions").EntryObject} EntryObject */
|
14
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionData} ExternalItemFunctionData */
|
15
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */
|
16
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */
|
17
|
+
/** @typedef {import("../declarations/WebpackOptions").ExternalItemValue} ExternalItemValue */
|
18
|
+
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */
|
14
19
|
/** @typedef {import("../declarations/WebpackOptions").FileCacheOptions} FileCacheOptions */
|
15
20
|
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
|
16
21
|
/** @typedef {import("../declarations/WebpackOptions").ModuleOptions} ModuleOptions */
|