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
package/lib/ProvidePlugin.js
CHANGED
@@ -5,12 +5,19 @@
|
|
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 ConstDependency = require("./dependencies/ConstDependency");
|
9
14
|
const ProvidedDependency = require("./dependencies/ProvidedDependency");
|
10
15
|
const { approve } = require("./javascript/JavascriptParserHelpers");
|
11
16
|
|
12
17
|
/** @typedef {import("./Compiler")} Compiler */
|
13
18
|
|
19
|
+
const PLUGIN_NAME = "ProvidePlugin";
|
20
|
+
|
14
21
|
class ProvidePlugin {
|
15
22
|
/**
|
16
23
|
* @param {Record<string, string | string[]>} definitions the provided identifiers
|
@@ -27,7 +34,7 @@ class ProvidePlugin {
|
|
27
34
|
apply(compiler) {
|
28
35
|
const definitions = this.definitions;
|
29
36
|
compiler.hooks.compilation.tap(
|
30
|
-
|
37
|
+
PLUGIN_NAME,
|
31
38
|
(compilation, { normalModuleFactory }) => {
|
32
39
|
compilation.dependencyTemplates.set(
|
33
40
|
ConstDependency,
|
@@ -48,11 +55,11 @@ class ProvidePlugin {
|
|
48
55
|
if (splittedName.length > 0) {
|
49
56
|
splittedName.slice(1).forEach((_, i) => {
|
50
57
|
const name = splittedName.slice(0, i + 1).join(".");
|
51
|
-
parser.hooks.canRename.for(name).tap(
|
58
|
+
parser.hooks.canRename.for(name).tap(PLUGIN_NAME, approve);
|
52
59
|
});
|
53
60
|
}
|
54
61
|
|
55
|
-
parser.hooks.expression.for(name).tap(
|
62
|
+
parser.hooks.expression.for(name).tap(PLUGIN_NAME, expr => {
|
56
63
|
const nameIdentifier = name.includes(".")
|
57
64
|
? `__webpack_provided_${name.replace(/\./g, "_dot_")}`
|
58
65
|
: name;
|
@@ -67,7 +74,7 @@ class ProvidePlugin {
|
|
67
74
|
return true;
|
68
75
|
});
|
69
76
|
|
70
|
-
parser.hooks.call.for(name).tap(
|
77
|
+
parser.hooks.call.for(name).tap(PLUGIN_NAME, expr => {
|
71
78
|
const nameIdentifier = name.includes(".")
|
72
79
|
? `__webpack_provided_${name.replace(/\./g, "_dot_")}`
|
73
80
|
: name;
|
@@ -85,14 +92,14 @@ class ProvidePlugin {
|
|
85
92
|
});
|
86
93
|
};
|
87
94
|
normalModuleFactory.hooks.parser
|
88
|
-
.for(
|
89
|
-
.tap(
|
95
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
96
|
+
.tap(PLUGIN_NAME, handler);
|
90
97
|
normalModuleFactory.hooks.parser
|
91
|
-
.for(
|
92
|
-
.tap(
|
98
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
99
|
+
.tap(PLUGIN_NAME, handler);
|
93
100
|
normalModuleFactory.hooks.parser
|
94
|
-
.for(
|
95
|
-
.tap(
|
101
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
102
|
+
.tap(PLUGIN_NAME, handler);
|
96
103
|
}
|
97
104
|
);
|
98
105
|
}
|
package/lib/RawModule.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
9
9
|
const Module = require("./Module");
|
10
|
+
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
10
11
|
const makeSerializable = require("./util/makeSerializable");
|
11
12
|
|
12
13
|
/** @typedef {import("webpack-sources").Source} Source */
|
@@ -35,7 +36,7 @@ class RawModule extends Module {
|
|
35
36
|
* @param {ReadonlySet<string>=} runtimeRequirements runtime requirements needed for the source code
|
36
37
|
*/
|
37
38
|
constructor(source, identifier, readableIdentifier, runtimeRequirements) {
|
38
|
-
super(
|
39
|
+
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
39
40
|
this.sourceStr = source;
|
40
41
|
this.identifierStr = identifier || this.sourceStr;
|
41
42
|
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
@@ -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 ConstDependency = require("./dependencies/ConstDependency");
|
10
14
|
const {
|
@@ -13,6 +17,8 @@ const {
|
|
13
17
|
|
14
18
|
/** @typedef {import("./Compiler")} Compiler */
|
15
19
|
|
20
|
+
const PLUGIN_NAME = "RequireJsStuffPlugin";
|
21
|
+
|
16
22
|
module.exports = class RequireJsStuffPlugin {
|
17
23
|
/**
|
18
24
|
* Apply the plugin
|
@@ -21,7 +27,7 @@ module.exports = class RequireJsStuffPlugin {
|
|
21
27
|
*/
|
22
28
|
apply(compiler) {
|
23
29
|
compiler.hooks.compilation.tap(
|
24
|
-
|
30
|
+
PLUGIN_NAME,
|
25
31
|
(compilation, { normalModuleFactory }) => {
|
26
32
|
compilation.dependencyTemplates.set(
|
27
33
|
ConstDependency,
|
@@ -37,27 +43,21 @@ module.exports = class RequireJsStuffPlugin {
|
|
37
43
|
|
38
44
|
parser.hooks.call
|
39
45
|
.for("require.config")
|
40
|
-
.tap(
|
41
|
-
"RequireJsStuffPlugin",
|
42
|
-
toConstantDependency(parser, "undefined")
|
43
|
-
);
|
46
|
+
.tap(PLUGIN_NAME, toConstantDependency(parser, "undefined"));
|
44
47
|
parser.hooks.call
|
45
48
|
.for("requirejs.config")
|
46
|
-
.tap(
|
47
|
-
"RequireJsStuffPlugin",
|
48
|
-
toConstantDependency(parser, "undefined")
|
49
|
-
);
|
49
|
+
.tap(PLUGIN_NAME, toConstantDependency(parser, "undefined"));
|
50
50
|
|
51
51
|
parser.hooks.expression
|
52
52
|
.for("require.version")
|
53
53
|
.tap(
|
54
|
-
|
54
|
+
PLUGIN_NAME,
|
55
55
|
toConstantDependency(parser, JSON.stringify("0.0.0"))
|
56
56
|
);
|
57
57
|
parser.hooks.expression
|
58
58
|
.for("requirejs.onError")
|
59
59
|
.tap(
|
60
|
-
|
60
|
+
PLUGIN_NAME,
|
61
61
|
toConstantDependency(
|
62
62
|
parser,
|
63
63
|
RuntimeGlobals.uncaughtErrorHandler,
|
@@ -66,11 +66,11 @@ module.exports = class RequireJsStuffPlugin {
|
|
66
66
|
);
|
67
67
|
};
|
68
68
|
normalModuleFactory.hooks.parser
|
69
|
-
.for(
|
70
|
-
.tap(
|
69
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
70
|
+
.tap(PLUGIN_NAME, handler);
|
71
71
|
normalModuleFactory.hooks.parser
|
72
|
-
.for(
|
73
|
-
.tap(
|
72
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
73
|
+
.tap(PLUGIN_NAME, handler);
|
74
74
|
}
|
75
75
|
);
|
76
76
|
}
|
package/lib/UseStrictPlugin.js
CHANGED
@@ -5,10 +5,17 @@
|
|
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 ConstDependency = require("./dependencies/ConstDependency");
|
9
14
|
|
10
15
|
/** @typedef {import("./Compiler")} Compiler */
|
11
16
|
|
17
|
+
const PLUGIN_NAME = "UseStrictPlugin";
|
18
|
+
|
12
19
|
class UseStrictPlugin {
|
13
20
|
/**
|
14
21
|
* Apply the plugin
|
@@ -17,10 +24,10 @@ class UseStrictPlugin {
|
|
17
24
|
*/
|
18
25
|
apply(compiler) {
|
19
26
|
compiler.hooks.compilation.tap(
|
20
|
-
|
27
|
+
PLUGIN_NAME,
|
21
28
|
(compilation, { normalModuleFactory }) => {
|
22
29
|
const handler = parser => {
|
23
|
-
parser.hooks.program.tap(
|
30
|
+
parser.hooks.program.tap(PLUGIN_NAME, ast => {
|
24
31
|
const firstNode = ast.body[0];
|
25
32
|
if (
|
26
33
|
firstNode &&
|
@@ -40,14 +47,14 @@ class UseStrictPlugin {
|
|
40
47
|
};
|
41
48
|
|
42
49
|
normalModuleFactory.hooks.parser
|
43
|
-
.for(
|
44
|
-
.tap(
|
50
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
51
|
+
.tap(PLUGIN_NAME, handler);
|
45
52
|
normalModuleFactory.hooks.parser
|
46
|
-
.for(
|
47
|
-
.tap(
|
53
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
54
|
+
.tap(PLUGIN_NAME, handler);
|
48
55
|
normalModuleFactory.hooks.parser
|
49
|
-
.for(
|
50
|
-
.tap(
|
56
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
57
|
+
.tap(PLUGIN_NAME, handler);
|
51
58
|
}
|
52
59
|
);
|
53
60
|
}
|
@@ -6,6 +6,11 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const IgnoreErrorModuleFactory = require("./IgnoreErrorModuleFactory");
|
9
|
+
const {
|
10
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
11
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
12
|
+
JAVASCRIPT_MODULE_TYPE_ESM
|
13
|
+
} = require("./ModuleTypeConstants");
|
9
14
|
const WebpackIsIncludedDependency = require("./dependencies/WebpackIsIncludedDependency");
|
10
15
|
const {
|
11
16
|
toConstantDependency
|
@@ -16,6 +21,8 @@ const {
|
|
16
21
|
/** @typedef {import("./Module")} Module */
|
17
22
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
18
23
|
|
24
|
+
const PLUGIN_NAME = "WebpackIsIncludedPlugin";
|
25
|
+
|
19
26
|
class WebpackIsIncludedPlugin {
|
20
27
|
/**
|
21
28
|
* @param {Compiler} compiler the compiler instance
|
@@ -23,7 +30,7 @@ class WebpackIsIncludedPlugin {
|
|
23
30
|
*/
|
24
31
|
apply(compiler) {
|
25
32
|
compiler.hooks.compilation.tap(
|
26
|
-
|
33
|
+
PLUGIN_NAME,
|
27
34
|
(compilation, { normalModuleFactory }) => {
|
28
35
|
compilation.dependencyFactories.set(
|
29
36
|
WebpackIsIncludedDependency,
|
@@ -41,7 +48,7 @@ class WebpackIsIncludedPlugin {
|
|
41
48
|
const handler = parser => {
|
42
49
|
parser.hooks.call
|
43
50
|
.for("__webpack_is_included__")
|
44
|
-
.tap(
|
51
|
+
.tap(PLUGIN_NAME, expr => {
|
45
52
|
if (
|
46
53
|
expr.type !== "CallExpression" ||
|
47
54
|
expr.arguments.length !== 1 ||
|
@@ -64,19 +71,19 @@ class WebpackIsIncludedPlugin {
|
|
64
71
|
parser.hooks.typeof
|
65
72
|
.for("__webpack_is_included__")
|
66
73
|
.tap(
|
67
|
-
|
74
|
+
PLUGIN_NAME,
|
68
75
|
toConstantDependency(parser, JSON.stringify("function"))
|
69
76
|
);
|
70
77
|
};
|
71
78
|
normalModuleFactory.hooks.parser
|
72
|
-
.for(
|
73
|
-
.tap(
|
79
|
+
.for(JAVASCRIPT_MODULE_TYPE_AUTO)
|
80
|
+
.tap(PLUGIN_NAME, handler);
|
74
81
|
normalModuleFactory.hooks.parser
|
75
|
-
.for(
|
76
|
-
.tap(
|
82
|
+
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
|
83
|
+
.tap(PLUGIN_NAME, handler);
|
77
84
|
normalModuleFactory.hooks.parser
|
78
|
-
.for(
|
79
|
-
.tap(
|
85
|
+
.for(JAVASCRIPT_MODULE_TYPE_ESM)
|
86
|
+
.tap(PLUGIN_NAME, handler);
|
80
87
|
}
|
81
88
|
);
|
82
89
|
}
|
package/lib/config/defaults.js
CHANGED
@@ -7,6 +7,14 @@
|
|
7
7
|
|
8
8
|
const fs = require("fs");
|
9
9
|
const path = require("path");
|
10
|
+
const {
|
11
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
12
|
+
JSON_MODULE_TYPE,
|
13
|
+
WEBASSEMBLY_MODULE_TYPE_ASYNC,
|
14
|
+
JAVASCRIPT_MODULE_TYPE_ESM,
|
15
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
16
|
+
WEBASSEMBLY_MODULE_TYPE_SYNC
|
17
|
+
} = require("../ModuleTypeConstants");
|
10
18
|
const Template = require("../Template");
|
11
19
|
const { cleverMerge } = require("../util/cleverMerge");
|
12
20
|
const {
|
@@ -517,7 +525,7 @@ const applyModuleDefaults = (
|
|
517
525
|
|
518
526
|
A(module, "defaultRules", () => {
|
519
527
|
const esm = {
|
520
|
-
type:
|
528
|
+
type: JAVASCRIPT_MODULE_TYPE_ESM,
|
521
529
|
resolve: {
|
522
530
|
byDependency: {
|
523
531
|
esm: {
|
@@ -527,21 +535,21 @@ const applyModuleDefaults = (
|
|
527
535
|
}
|
528
536
|
};
|
529
537
|
const commonjs = {
|
530
|
-
type:
|
538
|
+
type: JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
531
539
|
};
|
532
540
|
/** @type {RuleSetRules} */
|
533
541
|
const rules = [
|
534
542
|
{
|
535
543
|
mimetype: "application/node",
|
536
|
-
type:
|
544
|
+
type: JAVASCRIPT_MODULE_TYPE_AUTO
|
537
545
|
},
|
538
546
|
{
|
539
547
|
test: /\.json$/i,
|
540
|
-
type:
|
548
|
+
type: JSON_MODULE_TYPE
|
541
549
|
},
|
542
550
|
{
|
543
551
|
mimetype: "application/json",
|
544
|
-
type:
|
552
|
+
type: JSON_MODULE_TYPE
|
545
553
|
},
|
546
554
|
{
|
547
555
|
test: /\.mjs$/i,
|
@@ -574,7 +582,7 @@ const applyModuleDefaults = (
|
|
574
582
|
];
|
575
583
|
if (asyncWebAssembly) {
|
576
584
|
const wasm = {
|
577
|
-
type:
|
585
|
+
type: WEBASSEMBLY_MODULE_TYPE_ASYNC,
|
578
586
|
rules: [
|
579
587
|
{
|
580
588
|
descriptionData: {
|
@@ -596,7 +604,7 @@ const applyModuleDefaults = (
|
|
596
604
|
});
|
597
605
|
} else if (syncWebAssembly) {
|
598
606
|
const wasm = {
|
599
|
-
type:
|
607
|
+
type: WEBASSEMBLY_MODULE_TYPE_SYNC,
|
600
608
|
rules: [
|
601
609
|
{
|
602
610
|
descriptionData: {
|
@@ -667,7 +675,7 @@ const applyModuleDefaults = (
|
|
667
675
|
},
|
668
676
|
{
|
669
677
|
assert: { type: "json" },
|
670
|
-
type:
|
678
|
+
type: JSON_MODULE_TYPE
|
671
679
|
}
|
672
680
|
);
|
673
681
|
return rules;
|
@@ -340,6 +340,10 @@ const getNormalizedWebpackOptions = config => {
|
|
340
340
|
output.auxiliaryComment !== undefined
|
341
341
|
? output.auxiliaryComment
|
342
342
|
: libraryBase.auxiliaryComment,
|
343
|
+
amdContainer:
|
344
|
+
output.amdContainer !== undefined
|
345
|
+
? output.amdContainer
|
346
|
+
: libraryBase.amdContainer,
|
343
347
|
export:
|
344
348
|
output.libraryExport !== undefined
|
345
349
|
? output.libraryExport
|
@@ -8,6 +8,7 @@
|
|
8
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
9
9
|
const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
10
10
|
const Module = require("../Module");
|
11
|
+
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants");
|
11
12
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
12
13
|
const Template = require("../Template");
|
13
14
|
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
@@ -44,7 +45,7 @@ class ContainerEntryModule extends Module {
|
|
44
45
|
* @param {string} shareScope name of the share scope
|
45
46
|
*/
|
46
47
|
constructor(name, exposes, shareScope) {
|
47
|
-
super(
|
48
|
+
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
48
49
|
this._name = name;
|
49
50
|
this._exposes = exposes;
|
50
51
|
this._shareScope = shareScope;
|
@@ -111,7 +111,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
111
111
|
? crossOriginLoading === "use-credentials"
|
112
112
|
? 'link.crossOrigin = "use-credentials";'
|
113
113
|
: Template.asString([
|
114
|
-
"if (link.
|
114
|
+
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
|
115
115
|
Template.indent(
|
116
116
|
`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
|
117
117
|
),
|
package/lib/css/CssParser.js
CHANGED
@@ -138,6 +138,7 @@ class CssParser extends Parser {
|
|
138
138
|
let singleClassSelector = undefined;
|
139
139
|
let lastIdentifier = undefined;
|
140
140
|
const modeStack = [];
|
141
|
+
let awaitRightParenthesis = false;
|
141
142
|
const isTopLevelLocal = () =>
|
142
143
|
modeData === "local" ||
|
143
144
|
(this.defaultMode === "local" && modeData === undefined);
|
@@ -278,8 +279,8 @@ class CssParser extends Parser {
|
|
278
279
|
module.addDependency(dep);
|
279
280
|
declaredCssVariables.add(name);
|
280
281
|
} else if (
|
281
|
-
propertyName === "animation-name" ||
|
282
|
-
propertyName === "animation"
|
282
|
+
propertyName.toLowerCase() === "animation-name" ||
|
283
|
+
propertyName.toLowerCase() === "animation"
|
283
284
|
) {
|
284
285
|
modeData = "animation";
|
285
286
|
lastIdentifier = undefined;
|
@@ -296,6 +297,7 @@ class CssParser extends Parser {
|
|
296
297
|
module.addDependency(dep);
|
297
298
|
}
|
298
299
|
};
|
300
|
+
const eatAtRuleNested = eatUntil("{};/");
|
299
301
|
const eatKeyframes = eatUntil("{};/");
|
300
302
|
const eatNameInVar = eatUntil(",)};/");
|
301
303
|
walkCssTokens(source, {
|
@@ -341,7 +343,7 @@ class CssParser extends Parser {
|
|
341
343
|
return end;
|
342
344
|
},
|
343
345
|
atKeyword: (input, start, end) => {
|
344
|
-
const name = input.slice(start, end);
|
346
|
+
const name = input.slice(start, end).toLowerCase();
|
345
347
|
if (name === "@namespace") {
|
346
348
|
throw new Error("@namespace is not supported in bundled CSS");
|
347
349
|
}
|
@@ -380,6 +382,18 @@ class CssParser extends Parser {
|
|
380
382
|
modeNestingLevel = 1;
|
381
383
|
return pos + 1;
|
382
384
|
}
|
385
|
+
if (name === "@media" || name === "@supports") {
|
386
|
+
let pos = end;
|
387
|
+
const [newPos] = eatText(input, pos, eatAtRuleNested);
|
388
|
+
pos = newPos;
|
389
|
+
if (pos === input.length) return pos;
|
390
|
+
if (input.charCodeAt(pos) !== CC_LEFT_CURLY) {
|
391
|
+
throw new Error(
|
392
|
+
`Unexpected ${input[pos]} at ${pos} during parsing of @media or @supports (expected '{')`
|
393
|
+
);
|
394
|
+
}
|
395
|
+
return pos + 1;
|
396
|
+
}
|
383
397
|
return end;
|
384
398
|
},
|
385
399
|
semicolon: (input, start, end) => {
|
@@ -511,6 +525,9 @@ class CssParser extends Parser {
|
|
511
525
|
rightParenthesis: (input, start, end) => {
|
512
526
|
switch (mode) {
|
513
527
|
case CSS_MODE_TOP_LEVEL: {
|
528
|
+
if (awaitRightParenthesis) {
|
529
|
+
awaitRightParenthesis = false;
|
530
|
+
}
|
514
531
|
const newModeData = modeStack.pop();
|
515
532
|
if (newModeData !== false) {
|
516
533
|
modeData = newModeData;
|
@@ -526,7 +543,7 @@ class CssParser extends Parser {
|
|
526
543
|
singleClassSelector = false;
|
527
544
|
switch (mode) {
|
528
545
|
case CSS_MODE_TOP_LEVEL: {
|
529
|
-
const name = input.slice(start, end);
|
546
|
+
const name = input.slice(start, end).toLowerCase();
|
530
547
|
if (this.allowModeSwitch && name === ":global") {
|
531
548
|
modeData = "global";
|
532
549
|
const dep = new ConstDependency("", [start, end]);
|
@@ -549,7 +566,7 @@ class CssParser extends Parser {
|
|
549
566
|
pseudoFunction: (input, start, end) => {
|
550
567
|
switch (mode) {
|
551
568
|
case CSS_MODE_TOP_LEVEL: {
|
552
|
-
const name = input.slice(start, end - 1);
|
569
|
+
const name = input.slice(start, end - 1).toLowerCase();
|
553
570
|
if (this.allowModeSwitch && name === ":global") {
|
554
571
|
modeStack.push(modeData);
|
555
572
|
modeData = "global";
|
@@ -561,6 +578,7 @@ class CssParser extends Parser {
|
|
561
578
|
const dep = new ConstDependency("", [start, end]);
|
562
579
|
module.addPresentationalDependency(dep);
|
563
580
|
} else {
|
581
|
+
awaitRightParenthesis = true;
|
564
582
|
modeStack.push(false);
|
565
583
|
}
|
566
584
|
break;
|
@@ -571,7 +589,7 @@ class CssParser extends Parser {
|
|
571
589
|
function: (input, start, end) => {
|
572
590
|
switch (mode) {
|
573
591
|
case CSS_MODE_IN_LOCAL_RULE: {
|
574
|
-
const name = input.slice(start, end - 1);
|
592
|
+
const name = input.slice(start, end - 1).toLowerCase();
|
575
593
|
if (name === "var") {
|
576
594
|
let pos = walkCssTokens.eatWhitespaceAndComments(input, end);
|
577
595
|
if (pos === input.length) return pos;
|
@@ -597,8 +615,10 @@ class CssParser extends Parser {
|
|
597
615
|
comma: (input, start, end) => {
|
598
616
|
switch (mode) {
|
599
617
|
case CSS_MODE_TOP_LEVEL:
|
600
|
-
|
601
|
-
|
618
|
+
if (!awaitRightParenthesis) {
|
619
|
+
modeData = undefined;
|
620
|
+
modeStack.length = 0;
|
621
|
+
}
|
602
622
|
break;
|
603
623
|
case CSS_MODE_IN_LOCAL_RULE:
|
604
624
|
processDeclarationValueDone(input, start);
|
package/lib/css/walkCssTokens.js
CHANGED
@@ -62,6 +62,7 @@ const CC_LOWER_E = "e".charCodeAt(0);
|
|
62
62
|
const CC_LOWER_Z = "z".charCodeAt(0);
|
63
63
|
const CC_UPPER_A = "A".charCodeAt(0);
|
64
64
|
const CC_UPPER_E = "E".charCodeAt(0);
|
65
|
+
const CC_UPPER_U = "U".charCodeAt(0);
|
65
66
|
const CC_UPPER_Z = "Z".charCodeAt(0);
|
66
67
|
const CC_0 = "0".charCodeAt(0);
|
67
68
|
const CC_9 = "9".charCodeAt(0);
|
@@ -288,7 +289,10 @@ const consumeOtherIdentifier = (input, pos, callbacks) => {
|
|
288
289
|
const consumePotentialUrl = (input, pos, callbacks) => {
|
289
290
|
const start = pos;
|
290
291
|
pos = _consumeIdentifier(input, pos);
|
291
|
-
if (
|
292
|
+
if (
|
293
|
+
pos === start + 3 &&
|
294
|
+
input.slice(start, pos + 1).toLowerCase() === "url("
|
295
|
+
) {
|
292
296
|
pos++;
|
293
297
|
let cc = input.charCodeAt(pos);
|
294
298
|
while (_isWhiteSpace(cc)) {
|
@@ -569,6 +573,7 @@ const CHAR_MAP = Array.from({ length: 0x80 }, (_, cc) => {
|
|
569
573
|
case CC_AT_SIGN:
|
570
574
|
return consumeAt;
|
571
575
|
case CC_LOWER_U:
|
576
|
+
case CC_UPPER_U:
|
572
577
|
return consumePotentialUrl;
|
573
578
|
case CC_LOW_LINE:
|
574
579
|
return consumeOtherIdentifier;
|
@@ -5,6 +5,14 @@
|
|
5
5
|
"use strict";
|
6
6
|
|
7
7
|
const { Tracer } = require("chrome-trace-event");
|
8
|
+
const {
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
11
|
+
JAVASCRIPT_MODULE_TYPE_ESM,
|
12
|
+
WEBASSEMBLY_MODULE_TYPE_ASYNC,
|
13
|
+
WEBASSEMBLY_MODULE_TYPE_SYNC,
|
14
|
+
JSON_MODULE_TYPE
|
15
|
+
} = require("../ModuleTypeConstants");
|
8
16
|
const createSchemaValidation = require("../util/create-schema-validation");
|
9
17
|
const { dirname, mkdirpSync } = require("../util/fs");
|
10
18
|
|
@@ -182,7 +190,7 @@ const createTrace = (fs, outputPath) => {
|
|
182
190
|
};
|
183
191
|
};
|
184
192
|
|
185
|
-
const
|
193
|
+
const PLUGIN_NAME = "ProfilingPlugin";
|
186
194
|
|
187
195
|
class ProfilingPlugin {
|
188
196
|
/**
|
@@ -216,7 +224,7 @@ class ProfilingPlugin {
|
|
216
224
|
});
|
217
225
|
|
218
226
|
compiler.hooks.compilation.tap(
|
219
|
-
|
227
|
+
PLUGIN_NAME,
|
220
228
|
(compilation, { normalModuleFactory, contextModuleFactory }) => {
|
221
229
|
interceptAllHooksFor(compilation, tracer, "Compilation");
|
222
230
|
interceptAllHooksFor(
|
@@ -237,7 +245,7 @@ class ProfilingPlugin {
|
|
237
245
|
// We need to write out the CPU profile when we are all done.
|
238
246
|
compiler.hooks.done.tapAsync(
|
239
247
|
{
|
240
|
-
name:
|
248
|
+
name: PLUGIN_NAME,
|
241
249
|
stage: Infinity
|
242
250
|
},
|
243
251
|
(stats, callback) => {
|
@@ -312,18 +320,18 @@ const interceptAllHooksFor = (instance, tracer, logLabel) => {
|
|
312
320
|
|
313
321
|
const interceptAllParserHooks = (moduleFactory, tracer) => {
|
314
322
|
const moduleTypes = [
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
323
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
324
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
325
|
+
JAVASCRIPT_MODULE_TYPE_ESM,
|
326
|
+
JSON_MODULE_TYPE,
|
327
|
+
WEBASSEMBLY_MODULE_TYPE_ASYNC,
|
328
|
+
WEBASSEMBLY_MODULE_TYPE_SYNC
|
321
329
|
];
|
322
330
|
|
323
331
|
moduleTypes.forEach(moduleType => {
|
324
332
|
moduleFactory.hooks.parser
|
325
333
|
.for(moduleType)
|
326
|
-
.tap(
|
334
|
+
.tap(PLUGIN_NAME, (parser, parserOpts) => {
|
327
335
|
interceptAllHooksFor(parser, tracer, "Parser");
|
328
336
|
});
|
329
337
|
});
|
@@ -347,7 +355,7 @@ const makeInterceptorFor = (instance, tracer) => hookName => ({
|
|
347
355
|
const { name, type, fn } = tapInfo;
|
348
356
|
const newFn =
|
349
357
|
// Don't tap our own hooks to ensure stream can close cleanly
|
350
|
-
name ===
|
358
|
+
name === PLUGIN_NAME
|
351
359
|
? fn
|
352
360
|
: makeNewProfiledTapFn(hookName, tracer, {
|
353
361
|
name,
|
@@ -418,7 +426,7 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
|
|
418
426
|
const id = ++tracer.counter;
|
419
427
|
// Do not instrument ourself due to the CPU
|
420
428
|
// profile needing to be the last event in the trace.
|
421
|
-
if (name ===
|
429
|
+
if (name === PLUGIN_NAME) {
|
422
430
|
return fn(...args);
|
423
431
|
}
|
424
432
|
|