webpack 5.105.2 → 5.105.3
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/CleanPlugin.js +1 -0
- package/lib/Compilation.js +8 -6
- package/lib/ContextModule.js +14 -8
- package/lib/Dependency.js +1 -1
- package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
- package/lib/EvalDevToolModulePlugin.js +3 -0
- package/lib/EvalSourceMapDevToolPlugin.js +8 -1
- package/lib/ExportsInfo.js +0 -30
- package/lib/ExternalModule.js +2 -2
- package/lib/Module.js +30 -5
- package/lib/ModuleGraphConnection.js +0 -9
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +1 -0
- package/lib/SourceMapDevToolPlugin.js +10 -2
- package/lib/WebpackOptionsApply.js +13 -3
- package/lib/asset/AssetModulesPlugin.js +16 -1
- package/lib/asset/RawDataUrlModule.js +5 -1
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssModulesPlugin.js +7 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +314 -508
- package/lib/dependencies/CreateRequireParserPlugin.js +345 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -8
- package/lib/dependencies/HarmonyImportDependency.js +30 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +8 -20
- package/lib/dependencies/HarmonyModulesPlugin.js +4 -0
- package/lib/dependencies/ImportParserPlugin.js +1 -11
- package/lib/dependencies/ImportPhase.js +4 -0
- package/lib/javascript/JavascriptModulesPlugin.js +75 -22
- package/lib/javascript/JavascriptParser.js +2 -2
- package/lib/performance/AssetsOverSizeLimitWarning.js +1 -0
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +1 -0
- package/lib/performance/SizeLimitsPlugin.js +1 -0
- package/lib/runtime/ToBinaryRuntimeModule.js +14 -6
- package/lib/util/findGraphRoots.js +79 -109
- package/package.json +12 -9
- package/types.d.ts +147 -62
package/lib/CleanPlugin.js
CHANGED
package/lib/Compilation.js
CHANGED
|
@@ -4531,12 +4531,14 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|
|
4531
4531
|
(e) => e.chunks[e.chunks.length - 1]
|
|
4532
4532
|
)
|
|
4533
4533
|
)) {
|
|
4534
|
-
const otherInfo =
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
otherInfo
|
|
4538
|
-
|
|
4539
|
-
|
|
4534
|
+
const otherInfo = runtimeChunksMap.get(other);
|
|
4535
|
+
// other may be a non-runtime chunk (e.g. worker chunk)
|
|
4536
|
+
// when you have a worker chunk in your app.js (new Worker(...)) and as a separate entry point
|
|
4537
|
+
if (otherInfo) {
|
|
4538
|
+
otherInfo.referencedBy.push(info);
|
|
4539
|
+
info.remaining++;
|
|
4540
|
+
remaining++;
|
|
4541
|
+
}
|
|
4540
4542
|
}
|
|
4541
4543
|
}
|
|
4542
4544
|
/** @type {Chunk[]} */
|
package/lib/ContextModule.js
CHANGED
|
@@ -119,6 +119,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
119
119
|
|
|
120
120
|
/** @typedef {Record<ModuleId, FakeMapType>} FakeMap */
|
|
121
121
|
/** @typedef {Record<string, ModuleId>} UserRequestMap */
|
|
122
|
+
/** @typedef {Record<ModuleId, ModuleId[]>} UserRequestsMap */
|
|
122
123
|
|
|
123
124
|
class ContextModule extends Module {
|
|
124
125
|
/**
|
|
@@ -711,7 +712,7 @@ class ContextModule extends Module {
|
|
|
711
712
|
/**
|
|
712
713
|
* @param {Dependency[]} dependencies all dependencies
|
|
713
714
|
* @param {ChunkGraph} chunkGraph chunk graph
|
|
714
|
-
* @returns {
|
|
715
|
+
* @returns {UserRequestsMap} map with user requests
|
|
715
716
|
*/
|
|
716
717
|
getModuleDeferredAsyncDepsMap(dependencies, chunkGraph) {
|
|
717
718
|
const moduleGraph = chunkGraph.moduleGraph;
|
|
@@ -726,6 +727,7 @@ class ContextModule extends Module {
|
|
|
726
727
|
)
|
|
727
728
|
.filter(Boolean)
|
|
728
729
|
.sort(comparator);
|
|
730
|
+
/** @type {UserRequestsMap} */
|
|
729
731
|
const map = Object.create(null);
|
|
730
732
|
for (const module of sortedModules) {
|
|
731
733
|
if (!(/** @type {BuildMeta} */ (module.buildMeta).async)) {
|
|
@@ -740,7 +742,7 @@ class ContextModule extends Module {
|
|
|
740
742
|
}
|
|
741
743
|
|
|
742
744
|
/**
|
|
743
|
-
* @param {false |
|
|
745
|
+
* @param {false | UserRequestsMap} asyncDepsMap fake map
|
|
744
746
|
* @returns {string} async deps map init statement
|
|
745
747
|
*/
|
|
746
748
|
getModuleDeferredAsyncDepsMapInitStatement(asyncDepsMap) {
|
|
@@ -1168,12 +1170,16 @@ function webpackAsyncContext(req) {
|
|
|
1168
1170
|
])});
|
|
1169
1171
|
}`
|
|
1170
1172
|
: `function webpackAsyncContext(req) {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1173
|
+
try {
|
|
1174
|
+
if(!${RuntimeGlobals.hasOwnProperty}(map, req)) {
|
|
1175
|
+
return Promise.resolve().then(${runtimeTemplate.basicFunction("", [
|
|
1176
|
+
'var e = new Error("Cannot find module \'" + req + "\'");',
|
|
1177
|
+
"e.code = 'MODULE_NOT_FOUND';",
|
|
1178
|
+
"throw e;"
|
|
1179
|
+
])});
|
|
1180
|
+
}
|
|
1181
|
+
} catch(err) {
|
|
1182
|
+
return Promise.reject(err);
|
|
1177
1183
|
}
|
|
1178
1184
|
|
|
1179
1185
|
var ids = map[req], id = ids[0];
|
package/lib/Dependency.js
CHANGED
|
@@ -227,7 +227,7 @@ class Dependency {
|
|
|
227
227
|
*/
|
|
228
228
|
getReference(moduleGraph) {
|
|
229
229
|
throw new Error(
|
|
230
|
-
"Dependency.getReference was removed in favor of Dependency.getReferencedExports, ModuleGraph.getModule
|
|
230
|
+
"Dependency.getReference was removed in favor of Dependency.getReferencedExports, ModuleGraph.getModule, ModuleGraph.getConnection(), and ModuleGraphConnection.getActiveState(runtime)"
|
|
231
231
|
);
|
|
232
232
|
}
|
|
233
233
|
|
|
@@ -43,8 +43,11 @@ class EvalDevToolModulePlugin {
|
|
|
43
43
|
* @param {EvalDevToolModulePluginOptions=} options options
|
|
44
44
|
*/
|
|
45
45
|
constructor(options = {}) {
|
|
46
|
+
/** @type {DevtoolNamespace} */
|
|
46
47
|
this.namespace = options.namespace || "";
|
|
48
|
+
/** @type {string} */
|
|
47
49
|
this.sourceUrlComment = options.sourceUrlComment || "\n//# sourceURL=[url]";
|
|
50
|
+
/** @type {DevtoolModuleFilenameTemplate} */
|
|
48
51
|
this.moduleFilenameTemplate =
|
|
49
52
|
options.moduleFilenameTemplate ||
|
|
50
53
|
"webpack://[namespace]/[resourcePath]?[loaders]";
|
|
@@ -17,10 +17,13 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
|
|
19
19
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolNamespace} DevtoolNamespace */
|
|
21
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
|
|
20
22
|
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
|
21
23
|
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
|
|
22
|
-
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
|
|
23
24
|
/** @typedef {import("./Compiler")} Compiler */
|
|
25
|
+
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
|
|
26
|
+
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
24
27
|
|
|
25
28
|
/** @type {WeakMap<Source, Source>} */
|
|
26
29
|
const cache = new WeakMap();
|
|
@@ -51,14 +54,18 @@ class EvalSourceMapDevToolPlugin {
|
|
|
51
54
|
} else {
|
|
52
55
|
options = inputOptions;
|
|
53
56
|
}
|
|
57
|
+
/** @type {string} */
|
|
54
58
|
this.sourceMapComment =
|
|
55
59
|
options.append && typeof options.append !== "function"
|
|
56
60
|
? options.append
|
|
57
61
|
: "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
|
|
62
|
+
/** @type {DevtoolModuleFilenameTemplate} */
|
|
58
63
|
this.moduleFilenameTemplate =
|
|
59
64
|
options.moduleFilenameTemplate ||
|
|
60
65
|
"webpack://[namespace]/[resource-path]?[hash]";
|
|
66
|
+
/** @type {DevtoolNamespace} */
|
|
61
67
|
this.namespace = options.namespace || "";
|
|
68
|
+
/** @type {SourceMapDevToolPluginOptions} */
|
|
62
69
|
this.options = options;
|
|
63
70
|
}
|
|
64
71
|
|
package/lib/ExportsInfo.js
CHANGED
|
@@ -933,36 +933,6 @@ class ExportInfo {
|
|
|
933
933
|
this._maxTarget = undefined;
|
|
934
934
|
}
|
|
935
935
|
|
|
936
|
-
// TODO webpack 5 remove
|
|
937
|
-
/**
|
|
938
|
-
* @private
|
|
939
|
-
* @param {EXPECTED_ANY} v v
|
|
940
|
-
*/
|
|
941
|
-
set used(v) {
|
|
942
|
-
throw new Error("REMOVED");
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
// TODO webpack 5 remove
|
|
946
|
-
/** @private */
|
|
947
|
-
get used() {
|
|
948
|
-
throw new Error("REMOVED");
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// TODO webpack 5 remove
|
|
952
|
-
/**
|
|
953
|
-
* @private
|
|
954
|
-
* @param {EXPECTED_ANY} v v
|
|
955
|
-
*/
|
|
956
|
-
set usedName(v) {
|
|
957
|
-
throw new Error("REMOVED");
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
// TODO webpack 5 remove
|
|
961
|
-
/** @private */
|
|
962
|
-
get usedName() {
|
|
963
|
-
throw new Error("REMOVED");
|
|
964
|
-
}
|
|
965
|
-
|
|
966
936
|
get canMangle() {
|
|
967
937
|
switch (this.canMangleProvide) {
|
|
968
938
|
case undefined:
|
package/lib/ExternalModule.js
CHANGED
|
@@ -995,7 +995,7 @@ class ExternalModule extends Module {
|
|
|
995
995
|
);
|
|
996
996
|
/** @type {CodeGenerationResultData} */
|
|
997
997
|
const data = new Map();
|
|
998
|
-
data.set("url", { javascript: request });
|
|
998
|
+
data.set("url", { javascript: /** @type {string} */ (request) });
|
|
999
999
|
return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS, data };
|
|
1000
1000
|
}
|
|
1001
1001
|
case "css-url": {
|
|
@@ -1003,7 +1003,7 @@ class ExternalModule extends Module {
|
|
|
1003
1003
|
const sources = new Map();
|
|
1004
1004
|
/** @type {CodeGenerationResultData} */
|
|
1005
1005
|
const data = new Map();
|
|
1006
|
-
data.set("url", { "css-url": request });
|
|
1006
|
+
data.set("url", { "css-url": /** @type {string} */ (request) });
|
|
1007
1007
|
return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS, data };
|
|
1008
1008
|
}
|
|
1009
1009
|
case "css-import": {
|
package/lib/Module.js
CHANGED
|
@@ -104,11 +104,36 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
104
104
|
/** @typedef {Set<string>} RuntimeRequirements */
|
|
105
105
|
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
|
|
106
106
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
/**
|
|
108
|
+
* @typedef {object} AllCodeGenerationSchemas
|
|
109
|
+
* @property {Set<string>} topLevelDeclarations top level declarations for javascript modules
|
|
110
|
+
* @property {InitFragment<EXPECTED_ANY>[]} chunkInitFragments chunk init fragments for javascript modules
|
|
111
|
+
* @property {{ javascript?: string, ["css-url"]?: string }} url url for css and javascript modules
|
|
112
|
+
* @property {string} filename a filename for asset modules
|
|
113
|
+
* @property {AssetInfo} assetInfo an asset info for asset modules
|
|
114
|
+
* @property {string} fullContentHash a full content hash for asset modules
|
|
115
|
+
* @property {[{ shareScope: string, initStage: number, init: string }]} share-init share-init for modules federation
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/* eslint-disable jsdoc/type-formatting */
|
|
119
|
+
/**
|
|
120
|
+
* @template {string} K
|
|
121
|
+
* @typedef {K extends keyof AllCodeGenerationSchemas ? AllCodeGenerationSchemas[K] : EXPECTED_ANY} CodeGenValue
|
|
122
|
+
*/
|
|
123
|
+
/* eslint-enable jsdoc/type-formatting */
|
|
124
|
+
|
|
125
|
+
/* eslint-disable jsdoc/require-template */
|
|
126
|
+
/**
|
|
127
|
+
* @typedef {object} CodeGenMapOverloads
|
|
128
|
+
* @property {<K extends string>(key: K) => CodeGenValue<K> | undefined} get
|
|
129
|
+
* @property {<K extends string>(key: K, value: CodeGenValue<K>) => CodeGenerationResultData} set
|
|
130
|
+
* @property {<K extends string>(key: K) => boolean} has
|
|
131
|
+
* @property {<K extends string>(key: K) => boolean} delete
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @typedef {Omit<Map<string, EXPECTED_ANY>, "get" | "set" | "has" | "delete"> & CodeGenMapOverloads} CodeGenerationResultData
|
|
136
|
+
*/
|
|
112
137
|
|
|
113
138
|
/** @typedef {Map<SourceType, Source>} Sources */
|
|
114
139
|
|
|
@@ -184,15 +184,6 @@ class ModuleGraphConnection {
|
|
|
184
184
|
this.conditional = false;
|
|
185
185
|
this._active = value;
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
// TODO webpack 5 remove
|
|
189
|
-
get active() {
|
|
190
|
-
throw new Error("Use getActiveState instead");
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
set active(value) {
|
|
194
|
-
throw new Error("Use setActive instead");
|
|
195
|
-
}
|
|
196
187
|
}
|
|
197
188
|
|
|
198
189
|
/** @typedef {typeof TRANSITIVE_ONLY} TRANSITIVE_ONLY */
|
|
@@ -19,6 +19,9 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|
|
19
19
|
|
|
20
20
|
/** @typedef {import("webpack-sources").MapOptions} MapOptions */
|
|
21
21
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
22
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolNamespace} DevtoolNamespace */
|
|
23
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
|
|
24
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolFallbackModuleFilenameTemplate} DevtoolFallbackModuleFilenameTemplate */
|
|
22
25
|
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
|
23
26
|
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
|
|
24
27
|
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
|
|
@@ -140,19 +143,24 @@ class SourceMapDevToolPlugin {
|
|
|
140
143
|
constructor(options = {}) {
|
|
141
144
|
validate(options);
|
|
142
145
|
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
/** @type {undefined | null | false | string} */
|
|
147
|
+
this.sourceMapFilename = options.filename;
|
|
148
|
+
/** @type {false | TemplatePath} */
|
|
145
149
|
this.sourceMappingURLComment =
|
|
146
150
|
options.append === false
|
|
147
151
|
? false
|
|
148
152
|
: // eslint-disable-next-line no-useless-concat
|
|
149
153
|
options.append || "\n//# source" + "MappingURL=[url]";
|
|
154
|
+
/** @type {DevtoolModuleFilenameTemplate} */
|
|
150
155
|
this.moduleFilenameTemplate =
|
|
151
156
|
options.moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]";
|
|
157
|
+
/** @type {DevtoolFallbackModuleFilenameTemplate} */
|
|
152
158
|
this.fallbackModuleFilenameTemplate =
|
|
153
159
|
options.fallbackModuleFilenameTemplate ||
|
|
154
160
|
"webpack://[namespace]/[resourcePath]?[hash]";
|
|
161
|
+
/** @type {DevtoolNamespace} */
|
|
155
162
|
this.namespace = options.namespace || "";
|
|
163
|
+
/** @type {SourceMapDevToolPluginOptions} */
|
|
156
164
|
this.options = options;
|
|
157
165
|
}
|
|
158
166
|
|
|
@@ -60,6 +60,7 @@ const URLPlugin = require("./dependencies/URLPlugin");
|
|
|
60
60
|
const WorkerPlugin = require("./dependencies/WorkerPlugin");
|
|
61
61
|
|
|
62
62
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
|
63
|
+
const JavascriptParser = require("./javascript/JavascriptParser");
|
|
63
64
|
|
|
64
65
|
const JsonModulesPlugin = require("./json/JsonModulesPlugin");
|
|
65
66
|
|
|
@@ -371,7 +372,9 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
371
372
|
|
|
372
373
|
new JavascriptModulesPlugin().apply(compiler);
|
|
373
374
|
new JsonModulesPlugin().apply(compiler);
|
|
374
|
-
new AssetModulesPlugin(
|
|
375
|
+
new AssetModulesPlugin({
|
|
376
|
+
sideEffectFree: options.experiments.futureDefaults
|
|
377
|
+
}).apply(compiler);
|
|
375
378
|
|
|
376
379
|
if (!options.experiments.outputModule) {
|
|
377
380
|
if (options.output.module) {
|
|
@@ -483,11 +486,18 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
483
486
|
new HttpUriPlugin(httpOptions).apply(compiler);
|
|
484
487
|
}
|
|
485
488
|
|
|
486
|
-
if (
|
|
487
|
-
|
|
489
|
+
if (
|
|
490
|
+
options.experiments.deferImport &&
|
|
491
|
+
!(
|
|
492
|
+
/** @type {typeof JavascriptParser & { __importPhasesExtended?: true }} */
|
|
493
|
+
(JavascriptParser).__importPhasesExtended
|
|
494
|
+
)
|
|
495
|
+
) {
|
|
488
496
|
const importPhases = require("acorn-import-phases");
|
|
489
497
|
|
|
490
498
|
JavascriptParser.extend(importPhases({ source: false }));
|
|
499
|
+
/** @type {typeof JavascriptParser & { __importPhasesExtended?: true }} */
|
|
500
|
+
(JavascriptParser).__importPhasesExtended = true;
|
|
491
501
|
}
|
|
492
502
|
|
|
493
503
|
new EntryOptionPlugin().apply(compiler);
|
|
@@ -86,7 +86,19 @@ const getNormalModule = memoize(() => require("../NormalModule"));
|
|
|
86
86
|
const type = ASSET_MODULE_TYPE;
|
|
87
87
|
const PLUGIN_NAME = "AssetModulesPlugin";
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {object} AssetModulesPluginOptions
|
|
91
|
+
* @property {boolean=} sideEffectFree
|
|
92
|
+
*/
|
|
93
|
+
|
|
89
94
|
class AssetModulesPlugin {
|
|
95
|
+
/**
|
|
96
|
+
* @param {AssetModulesPluginOptions} options options
|
|
97
|
+
*/
|
|
98
|
+
constructor(options) {
|
|
99
|
+
this.options = options;
|
|
100
|
+
}
|
|
101
|
+
|
|
90
102
|
/**
|
|
91
103
|
* Apply the plugin
|
|
92
104
|
* @param {Compiler} compiler the compiler instance
|
|
@@ -112,7 +124,10 @@ class AssetModulesPlugin {
|
|
|
112
124
|
/** @type {NormalModuleCreateData} */
|
|
113
125
|
(createData)
|
|
114
126
|
);
|
|
115
|
-
|
|
127
|
+
if (this.options.sideEffectFree) {
|
|
128
|
+
module.factoryMeta = { sideEffectFree: true };
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
return module;
|
|
117
132
|
});
|
|
118
133
|
}
|
|
@@ -42,9 +42,13 @@ class RawDataUrlModule extends Module {
|
|
|
42
42
|
*/
|
|
43
43
|
constructor(url, identifier, readableIdentifier) {
|
|
44
44
|
super(ASSET_MODULE_TYPE_RAW_DATA_URL, null);
|
|
45
|
+
/** @type {string} */
|
|
45
46
|
this.url = url;
|
|
47
|
+
/** @type {Buffer | undefined} */
|
|
46
48
|
this.urlBuffer = url ? Buffer.from(url) : undefined;
|
|
47
|
-
|
|
49
|
+
/** @type {string} */
|
|
50
|
+
this.identifierStr = identifier;
|
|
51
|
+
/** @type {string} */
|
|
48
52
|
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
|
49
53
|
}
|
|
50
54
|
|
package/lib/css/CssGenerator.js
CHANGED
|
@@ -19,7 +19,6 @@ const {
|
|
|
19
19
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
20
20
|
const Template = require("../Template");
|
|
21
21
|
const CssImportDependency = require("../dependencies/CssImportDependency");
|
|
22
|
-
const EntryDependency = require("../dependencies/EntryDependency");
|
|
23
22
|
const { getUndoPath } = require("../util/identifier");
|
|
24
23
|
const memoize = require("../util/memoize");
|
|
25
24
|
|
|
@@ -472,11 +471,7 @@ class CssGenerator extends Generator {
|
|
|
472
471
|
const sourceTypes = new Set();
|
|
473
472
|
const connections = this._moduleGraph.getIncomingConnections(module);
|
|
474
473
|
|
|
475
|
-
let isEntryModule = false;
|
|
476
474
|
for (const connection of connections) {
|
|
477
|
-
if (connection.dependency instanceof EntryDependency) {
|
|
478
|
-
isEntryModule = true;
|
|
479
|
-
}
|
|
480
475
|
if (
|
|
481
476
|
exportType === "link" &&
|
|
482
477
|
connection.dependency instanceof CssImportDependency
|
|
@@ -503,7 +498,7 @@ class CssGenerator extends Generator {
|
|
|
503
498
|
}
|
|
504
499
|
}
|
|
505
500
|
if (this._generatesJsOnly(module)) {
|
|
506
|
-
if (sourceTypes.has(JAVASCRIPT_TYPE)
|
|
501
|
+
if (sourceTypes.has(JAVASCRIPT_TYPE)) {
|
|
507
502
|
return JAVASCRIPT_TYPES;
|
|
508
503
|
}
|
|
509
504
|
return new Set();
|
|
@@ -578,3 +573,5 @@ class CssGenerator extends Generator {
|
|
|
578
573
|
}
|
|
579
574
|
|
|
580
575
|
module.exports = CssGenerator;
|
|
576
|
+
|
|
577
|
+
module.exports = CssGenerator;
|
|
@@ -386,6 +386,13 @@ class CssModulesPlugin {
|
|
|
386
386
|
compilation
|
|
387
387
|
).renderModuleContent.tap(PLUGIN_NAME, (source, module) => {
|
|
388
388
|
if (module instanceof CssModule && module.hot) {
|
|
389
|
+
const exportType = /** @type {BuildMeta} */ (module.buildMeta)
|
|
390
|
+
.exportType;
|
|
391
|
+
// When exportType !== "link", modules behave like JavaScript modules
|
|
392
|
+
if (exportType && exportType !== "link") {
|
|
393
|
+
return source;
|
|
394
|
+
}
|
|
395
|
+
// For exportType === "link", we can optimize with self-acceptance
|
|
389
396
|
const cssData = /** @type {BuildInfo} */ (module.buildInfo).cssData;
|
|
390
397
|
if (!cssData) {
|
|
391
398
|
return source;
|
|
@@ -65,6 +65,10 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|
|
65
65
|
return "cjs export require";
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
get category() {
|
|
69
|
+
return "commonjs";
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
/**
|
|
69
73
|
* @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
|
70
74
|
*/
|