webpack 5.82.0 → 5.82.1

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.

@@ -49,6 +49,7 @@ const ModuleProfile = require("./ModuleProfile");
49
49
  const ModuleRestoreError = require("./ModuleRestoreError");
50
50
  const ModuleStoreError = require("./ModuleStoreError");
51
51
  const ModuleTemplate = require("./ModuleTemplate");
52
+ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
52
53
  const RuntimeGlobals = require("./RuntimeGlobals");
53
54
  const RuntimeTemplate = require("./RuntimeTemplate");
54
55
  const Stats = require("./Stats");
@@ -5121,7 +5122,7 @@ This prevents using hashes of each other and should be avoided.`);
5121
5122
  const usedIds = new Set();
5122
5123
 
5123
5124
  for (const module of this.modules) {
5124
- if (module.type === "runtime") continue;
5125
+ if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) continue;
5125
5126
  const moduleId = chunkGraph.getModuleId(module);
5126
5127
  if (moduleId === null) continue;
5127
5128
  if (usedIds.has(moduleId)) {
@@ -18,6 +18,14 @@ const makeSerializable = require("./util/makeSerializable");
18
18
 
19
19
  /** @typedef {(d: Dependency) => boolean} DependencyFilterFunction */
20
20
 
21
+ /**
22
+ * DependenciesBlock is the base class for all Module classes in webpack. It describes a
23
+ * "block" of dependencies which are pointers to other DependenciesBlock instances. For example
24
+ * when a Module has a CommonJs require statement, the DependencyBlock for the CommonJs module
25
+ * would be added as a dependency to the Module. DependenciesBlock is inherited by two types of classes:
26
+ * Module subclasses and AsyncDependenciesBlock subclasses. The only difference between the two is that
27
+ * AsyncDependenciesBlock subclasses are used for code-splitting (async boundary) and Module subclasses are not.
28
+ */
21
29
  class DependenciesBlock {
22
30
  constructor() {
23
31
  /** @type {Dependency[]} */
@@ -1464,7 +1464,7 @@ class FileSystemInfo {
1464
1464
  push({
1465
1465
  type: RBDT_DIRECTORY,
1466
1466
  context: undefined,
1467
- path: resultPath,
1467
+ path: /** @type {string} */ (resultPath),
1468
1468
  expected: undefined,
1469
1469
  issuer: job
1470
1470
  });
@@ -38,7 +38,8 @@ const {
38
38
  const {
39
39
  JAVASCRIPT_MODULE_TYPE_AUTO,
40
40
  JAVASCRIPT_MODULE_TYPE_DYNAMIC,
41
- JAVASCRIPT_MODULE_TYPE_ESM
41
+ JAVASCRIPT_MODULE_TYPE_ESM,
42
+ WEBPACK_MODULE_TYPE_RUNTIME
42
43
  } = require("./ModuleTypeConstants");
43
44
 
44
45
  /** @typedef {import("./Chunk")} Chunk */
@@ -564,7 +565,7 @@ class HotModuleReplacementPlugin {
564
565
  newRuntime
565
566
  );
566
567
  if (hash !== oldHash) {
567
- if (module.type === "runtime") {
568
+ if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) {
568
569
  newRuntimeModules = newRuntimeModules || [];
569
570
  newRuntimeModules.push(
570
571
  /** @type {RuntimeModule} */ (module)
package/lib/Module.js CHANGED
@@ -28,6 +28,7 @@ const makeSerializable = require("./util/makeSerializable");
28
28
  /** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */
29
29
  /** @typedef {import("./FileSystemInfo")} FileSystemInfo */
30
30
  /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
31
+ /** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */
31
32
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
32
33
  /** @typedef {import("./RequestShortener")} RequestShortener */
33
34
  /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
@@ -129,14 +130,14 @@ const deprecatedNeedRebuild = util.deprecate(
129
130
 
130
131
  class Module extends DependenciesBlock {
131
132
  /**
132
- * @param {string} type the module type
133
+ * @param {ModuleTypes | ""} type the module type, when deserializing the type is not known and is an empty string
133
134
  * @param {string=} context an optional context
134
135
  * @param {string=} layer an optional layer in which the module is
135
136
  */
136
137
  constructor(type, context = null, layer = null) {
137
138
  super();
138
139
 
139
- /** @type {string} */
140
+ /** @type {ModuleTypes | ""} */
140
141
  this.type = type;
141
142
  /** @type {string | null} */
142
143
  this.context = context;
@@ -60,6 +60,88 @@ const CSS_MODULE_TYPE_GLOBAL = "css/global";
60
60
  */
61
61
  const CSS_MODULE_TYPE_MODULE = "css/module";
62
62
 
63
+ /**
64
+ * @type {Readonly<"asset">}
65
+ * This is the module type used for automatically choosing between `asset/inline`, `asset/resource` based on asset size limit (8096).
66
+ */
67
+ const ASSET_MODULE_TYPE = "asset";
68
+
69
+ /**
70
+ * @type {Readonly<"asset/inline">}
71
+ * This is the module type used for assets that are inlined as a data URI. This is the equivalent of `url-loader`.
72
+ */
73
+ const ASSET_MODULE_TYPE_INLINE = "asset/inline";
74
+
75
+ /**
76
+ * @type {Readonly<"asset/resource">}
77
+ * This is the module type used for assets that are copied to the output directory. This is the equivalent of `file-loader`.
78
+ */
79
+ const ASSET_MODULE_TYPE_RESOURCE = "asset/resource";
80
+
81
+ /**
82
+ * @type {Readonly<"asset/source">}
83
+ * This is the module type used for assets that are imported as source code. This is the equivalent of `raw-loader`.
84
+ */
85
+ const ASSET_MODULE_TYPE_SOURCE = "asset/source";
86
+
87
+ /**
88
+ * @type {Readonly<"asset/raw-data-url">}
89
+ * TODO: Document what this asset type is for. See css-loader tests for its usage.
90
+ */
91
+ const ASSET_MODULE_TYPE_RAW_DATA_URL = "asset/raw-data-url";
92
+
93
+ /**
94
+ * @type {Readonly<"runtime">}
95
+ * This is the module type used for the webpack runtime abstractions.
96
+ */
97
+ const WEBPACK_MODULE_TYPE_RUNTIME = "runtime";
98
+
99
+ /**
100
+ * @type {Readonly<"fallback-module">}
101
+ * This is the module type used for the ModuleFederation feature's FallbackModule class.
102
+ * TODO: Document this better.
103
+ */
104
+ const WEBPACK_MODULE_TYPE_FALLBACK = "fallback-module";
105
+
106
+ /**
107
+ * @type {Readonly<"remote-module">}
108
+ * This is the module type used for the ModuleFederation feature's RemoteModule class.
109
+ * TODO: Document this better.
110
+ */
111
+ const WEBPACK_MODULE_TYPE_REMOTE = "remote-module";
112
+
113
+ /**
114
+ * @type {Readonly<"provide-module">}
115
+ * This is the module type used for the ModuleFederation feature's ProvideModule class.
116
+ * TODO: Document this better.
117
+ */
118
+ const WEBPACK_MODULE_TYPE_PROVIDE = "provide-module";
119
+
120
+ /**
121
+ * @type {Readonly<"consume-shared-module">}
122
+ * This is the module type used for the ModuleFederation feature's ConsumeSharedModule class.
123
+ */
124
+ const WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE = "consume-shared-module";
125
+
126
+ /**
127
+ * @type {Readonly<"lazy-compilation-proxy">}
128
+ * Module type used for `experiments.lazyCompilation` feature. See `LazyCompilationPlugin` for more information.
129
+ */
130
+ const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY = "lazy-compilation-proxy";
131
+
132
+ /** @typedef {"javascript/auto" | "javascript/dynamic" | "javascript/esm"} JavaScriptModuleTypes */
133
+ /** @typedef {"json"} JSONModuleType */
134
+ /** @typedef {"webassembly/async" | "webassembly/sync"} WebAssemblyModuleTypes */
135
+ /** @typedef {"css" | "css/global" | "css/module"} CSSModuleTypes */
136
+ /** @typedef {"asset" | "asset/inline" | "asset/resource" | "asset/source" | "asset/raw-data-url"} AssetModuleTypes */
137
+ /** @typedef {"runtime" | "fallback-module" | "remote-module" | "provide-module" | "consume-shared-module" | "lazy-compilation-proxy"} WebpackModuleTypes */
138
+ /** @typedef {JavaScriptModuleTypes | JSONModuleType | WebAssemblyModuleTypes | CSSModuleTypes | AssetModuleTypes | WebpackModuleTypes} ModuleTypes */
139
+
140
+ exports.ASSET_MODULE_TYPE = ASSET_MODULE_TYPE;
141
+ exports.ASSET_MODULE_TYPE_RAW_DATA_URL = ASSET_MODULE_TYPE_RAW_DATA_URL;
142
+ exports.ASSET_MODULE_TYPE_SOURCE = ASSET_MODULE_TYPE_SOURCE;
143
+ exports.ASSET_MODULE_TYPE_RESOURCE = ASSET_MODULE_TYPE_RESOURCE;
144
+ exports.ASSET_MODULE_TYPE_INLINE = ASSET_MODULE_TYPE_INLINE;
63
145
  exports.JAVASCRIPT_MODULE_TYPE_AUTO = JAVASCRIPT_MODULE_TYPE_AUTO;
64
146
  exports.JAVASCRIPT_MODULE_TYPE_DYNAMIC = JAVASCRIPT_MODULE_TYPE_DYNAMIC;
65
147
  exports.JAVASCRIPT_MODULE_TYPE_ESM = JAVASCRIPT_MODULE_TYPE_ESM;
@@ -69,3 +151,11 @@ exports.WEBASSEMBLY_MODULE_TYPE_SYNC = WEBASSEMBLY_MODULE_TYPE_SYNC;
69
151
  exports.CSS_MODULE_TYPE = CSS_MODULE_TYPE;
70
152
  exports.CSS_MODULE_TYPE_GLOBAL = CSS_MODULE_TYPE_GLOBAL;
71
153
  exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE;
154
+ exports.WEBPACK_MODULE_TYPE_RUNTIME = WEBPACK_MODULE_TYPE_RUNTIME;
155
+ exports.WEBPACK_MODULE_TYPE_FALLBACK = WEBPACK_MODULE_TYPE_FALLBACK;
156
+ exports.WEBPACK_MODULE_TYPE_REMOTE = WEBPACK_MODULE_TYPE_REMOTE;
157
+ exports.WEBPACK_MODULE_TYPE_PROVIDE = WEBPACK_MODULE_TYPE_PROVIDE;
158
+ exports.WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE =
159
+ WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE;
160
+ exports.WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY =
161
+ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY;
@@ -65,6 +65,7 @@ const memoize = require("./util/memoize");
65
65
  /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
66
66
  /** @typedef {import("./ModuleGraph")} ModuleGraph */
67
67
  /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
68
+ /** @typedef {import("./ModuleTypeConstants").JavaScriptModuleTypes} JavaScriptModuleTypes */
68
69
  /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
69
70
  /** @typedef {import("./Parser")} Parser */
70
71
  /** @typedef {import("./RequestShortener")} RequestShortener */
@@ -201,7 +202,7 @@ makeSerializable(
201
202
  /**
202
203
  * @typedef {Object} NormalModuleCreateData
203
204
  * @property {string=} layer an optional layer in which the module is
204
- * @property {string} type module type
205
+ * @property {JavaScriptModuleTypes | ""} type module type. When deserializing, this is set to an empty string "".
205
206
  * @property {string} request request string
206
207
  * @property {string} userRequest request intended by user (without loaders from config)
207
208
  * @property {string} rawRequest request without resolving
@@ -8,6 +8,7 @@
8
8
  const { RawSource } = require("webpack-sources");
9
9
  const OriginalSource = require("webpack-sources").OriginalSource;
10
10
  const Module = require("./Module");
11
+ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
11
12
 
12
13
  /** @typedef {import("webpack-sources").Source} Source */
13
14
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
@@ -24,7 +25,7 @@ const Module = require("./Module");
24
25
  /** @typedef {import("./util/Hash")} Hash */
25
26
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
26
27
 
27
- const TYPES = new Set(["runtime"]);
28
+ const TYPES = new Set([WEBPACK_MODULE_TYPE_RUNTIME]);
28
29
 
29
30
  class RuntimeModule extends Module {
30
31
  /**
@@ -32,7 +33,7 @@ class RuntimeModule extends Module {
32
33
  * @param {number=} stage an optional stage
33
34
  */
34
35
  constructor(name, stage = 0) {
35
- super("runtime");
36
+ super(WEBPACK_MODULE_TYPE_RUNTIME);
36
37
  this.name = name;
37
38
  this.stage = stage;
38
39
  this.buildMeta = {};
@@ -137,7 +138,7 @@ class RuntimeModule extends Module {
137
138
  const generatedCode = this.getGeneratedCode();
138
139
  if (generatedCode) {
139
140
  sources.set(
140
- "runtime",
141
+ WEBPACK_MODULE_TYPE_RUNTIME,
141
142
  this.useSourceMap || this.useSimpleSourceMap
142
143
  ? new OriginalSource(generatedCode, this.identifier())
143
144
  : new RawSource(generatedCode)
package/lib/Template.js CHANGED
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const { ConcatSource, PrefixSource } = require("webpack-sources");
9
+ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
9
10
 
10
11
  /** @typedef {import("webpack-sources").Source} Source */
11
12
  /** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
@@ -362,7 +363,7 @@ class Template {
362
363
  runtimeSource = codeGenerationResults.getSource(
363
364
  module,
364
365
  renderContext.chunk.runtime,
365
- "runtime"
366
+ WEBPACK_MODULE_TYPE_RUNTIME
366
367
  );
367
368
  } else {
368
369
  const codeGenResult = module.codeGeneration({
@@ -10,6 +10,7 @@ const path = require("path");
10
10
  const { RawSource } = require("webpack-sources");
11
11
  const ConcatenationScope = require("../ConcatenationScope");
12
12
  const Generator = require("../Generator");
13
+ const { ASSET_MODULE_TYPE } = require("../ModuleTypeConstants");
13
14
  const RuntimeGlobals = require("../RuntimeGlobals");
14
15
  const createHash = require("../util/createHash");
15
16
  const { makePathsRelative } = require("../util/identifier");
@@ -122,7 +123,7 @@ const decodeDataUriContent = (encoding, content) => {
122
123
  };
123
124
 
124
125
  const JS_TYPES = new Set(["javascript"]);
125
- const JS_AND_ASSET_TYPES = new Set(["javascript", "asset"]);
126
+ const JS_AND_ASSET_TYPES = new Set(["javascript", ASSET_MODULE_TYPE]);
126
127
  const DEFAULT_ENCODING = "base64";
127
128
 
128
129
  class AssetGenerator extends Generator {
@@ -228,7 +229,7 @@ class AssetGenerator extends Generator {
228
229
  }
229
230
  ) {
230
231
  switch (type) {
231
- case "asset":
232
+ case ASSET_MODULE_TYPE:
232
233
  return module.originalSource();
233
234
  default: {
234
235
  let content;
@@ -406,7 +407,7 @@ class AssetGenerator extends Generator {
406
407
  */
407
408
  getSize(module, type) {
408
409
  switch (type) {
409
- case "asset": {
410
+ case ASSET_MODULE_TYPE: {
410
411
  const originalSource = module.originalSource();
411
412
 
412
413
  if (!originalSource) {
@@ -5,6 +5,12 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const {
9
+ ASSET_MODULE_TYPE_RESOURCE,
10
+ ASSET_MODULE_TYPE_INLINE,
11
+ ASSET_MODULE_TYPE,
12
+ ASSET_MODULE_TYPE_SOURCE
13
+ } = require("../ModuleTypeConstants");
8
14
  const { cleverMerge } = require("../util/cleverMerge");
9
15
  const { compareModulesByIdentifier } = require("../util/comparators");
10
16
  const createSchemaValidation = require("../util/create-schema-validation");
@@ -61,7 +67,7 @@ const getAssetSourceGenerator = memoize(() =>
61
67
  require("./AssetSourceGenerator")
62
68
  );
63
69
 
64
- const type = "asset";
70
+ const type = ASSET_MODULE_TYPE;
65
71
  const plugin = "AssetModulesPlugin";
66
72
 
67
73
  class AssetModulesPlugin {
@@ -75,7 +81,7 @@ class AssetModulesPlugin {
75
81
  plugin,
76
82
  (compilation, { normalModuleFactory }) => {
77
83
  normalModuleFactory.hooks.createParser
78
- .for("asset")
84
+ .for(ASSET_MODULE_TYPE)
79
85
  .tap(plugin, parserOptions => {
80
86
  validateParserOptions(parserOptions);
81
87
  parserOptions = cleverMerge(
@@ -96,35 +102,39 @@ class AssetModulesPlugin {
96
102
  return new AssetParser(dataUrlCondition);
97
103
  });
98
104
  normalModuleFactory.hooks.createParser
99
- .for("asset/inline")
105
+ .for(ASSET_MODULE_TYPE_INLINE)
100
106
  .tap(plugin, parserOptions => {
101
107
  const AssetParser = getAssetParser();
102
108
 
103
109
  return new AssetParser(true);
104
110
  });
105
111
  normalModuleFactory.hooks.createParser
106
- .for("asset/resource")
112
+ .for(ASSET_MODULE_TYPE_RESOURCE)
107
113
  .tap(plugin, parserOptions => {
108
114
  const AssetParser = getAssetParser();
109
115
 
110
116
  return new AssetParser(false);
111
117
  });
112
118
  normalModuleFactory.hooks.createParser
113
- .for("asset/source")
119
+ .for(ASSET_MODULE_TYPE_SOURCE)
114
120
  .tap(plugin, parserOptions => {
115
121
  const AssetSourceParser = getAssetSourceParser();
116
122
 
117
123
  return new AssetSourceParser();
118
124
  });
119
125
 
120
- for (const type of ["asset", "asset/inline", "asset/resource"]) {
126
+ for (const type of [
127
+ ASSET_MODULE_TYPE,
128
+ ASSET_MODULE_TYPE_INLINE,
129
+ ASSET_MODULE_TYPE_RESOURCE
130
+ ]) {
121
131
  normalModuleFactory.hooks.createGenerator
122
132
  .for(type)
123
133
  .tap(plugin, generatorOptions => {
124
134
  validateGeneratorOptions[type](generatorOptions);
125
135
 
126
136
  let dataUrl = undefined;
127
- if (type !== "asset/resource") {
137
+ if (type !== ASSET_MODULE_TYPE_RESOURCE) {
128
138
  dataUrl = generatorOptions.dataUrl;
129
139
  if (!dataUrl || typeof dataUrl === "object") {
130
140
  dataUrl = {
@@ -138,7 +148,7 @@ class AssetModulesPlugin {
138
148
  let filename = undefined;
139
149
  let publicPath = undefined;
140
150
  let outputPath = undefined;
141
- if (type !== "asset/inline") {
151
+ if (type !== ASSET_MODULE_TYPE_INLINE) {
142
152
  filename = generatorOptions.filename;
143
153
  publicPath = generatorOptions.publicPath;
144
154
  outputPath = generatorOptions.outputPath;
@@ -156,7 +166,7 @@ class AssetModulesPlugin {
156
166
  });
157
167
  }
158
168
  normalModuleFactory.hooks.createGenerator
159
- .for("asset/source")
169
+ .for(ASSET_MODULE_TYPE_SOURCE)
160
170
  .tap(plugin, () => {
161
171
  const AssetSourceGenerator = getAssetSourceGenerator();
162
172
 
@@ -169,7 +179,7 @@ class AssetModulesPlugin {
169
179
 
170
180
  const modules = chunkGraph.getOrderedChunkModulesIterableBySourceType(
171
181
  chunk,
172
- "asset",
182
+ ASSET_MODULE_TYPE,
173
183
  compareModulesByIdentifier
174
184
  );
175
185
  if (modules) {
@@ -207,7 +217,7 @@ class AssetModulesPlugin {
207
217
  "AssetModulesPlugin",
208
218
  (options, context) => {
209
219
  const { codeGenerationResult } = options;
210
- const source = codeGenerationResult.sources.get("asset");
220
+ const source = codeGenerationResult.sources.get(ASSET_MODULE_TYPE);
211
221
  if (source === undefined) return;
212
222
  context.assets.set(codeGenerationResult.data.get("filename"), {
213
223
  source,
@@ -7,6 +7,7 @@
7
7
 
8
8
  const { RawSource } = require("webpack-sources");
9
9
  const Module = require("../Module");
10
+ const { ASSET_MODULE_TYPE_RAW_DATA_URL } = require("../ModuleTypeConstants");
10
11
  const RuntimeGlobals = require("../RuntimeGlobals");
11
12
  const makeSerializable = require("../util/makeSerializable");
12
13
 
@@ -33,7 +34,7 @@ class RawDataUrlModule extends Module {
33
34
  * @param {string=} readableIdentifier readable identifier
34
35
  */
35
36
  constructor(url, identifier, readableIdentifier) {
36
- super("asset/raw-data-url", null);
37
+ super(ASSET_MODULE_TYPE_RAW_DATA_URL, null);
37
38
  this.url = url;
38
39
  this.urlBuffer = url ? Buffer.from(url) : undefined;
39
40
  this.identifierStr = identifier || this.url;
@@ -13,7 +13,8 @@ const {
13
13
  WEBASSEMBLY_MODULE_TYPE_ASYNC,
14
14
  JAVASCRIPT_MODULE_TYPE_ESM,
15
15
  JAVASCRIPT_MODULE_TYPE_DYNAMIC,
16
- WEBASSEMBLY_MODULE_TYPE_SYNC
16
+ WEBASSEMBLY_MODULE_TYPE_SYNC,
17
+ ASSET_MODULE_TYPE
17
18
  } = require("../ModuleTypeConstants");
18
19
  const Template = require("../Template");
19
20
  const { cleverMerge } = require("../util/cleverMerge");
@@ -511,7 +512,7 @@ const applyModuleDefaults = (
511
512
  D(module, "unsafeCache", false);
512
513
  }
513
514
 
514
- F(module.parser, "asset", () => ({}));
515
+ F(module.parser, ASSET_MODULE_TYPE, () => ({}));
515
516
  F(module.parser.asset, "dataUrlCondition", () => ({}));
516
517
  if (typeof module.parser.asset.dataUrlCondition === "object") {
517
518
  D(module.parser.asset.dataUrlCondition, "maxSize", 8096);
@@ -7,6 +7,7 @@
7
7
 
8
8
  const { RawSource } = require("webpack-sources");
9
9
  const Module = require("../Module");
10
+ const { WEBPACK_MODULE_TYPE_FALLBACK } = require("../ModuleTypeConstants");
10
11
  const RuntimeGlobals = require("../RuntimeGlobals");
11
12
  const Template = require("../Template");
12
13
  const makeSerializable = require("../util/makeSerializable");
@@ -37,7 +38,7 @@ class FallbackModule extends Module {
37
38
  * @param {string[]} requests list of requests to choose one
38
39
  */
39
40
  constructor(requests) {
40
- super("fallback-module");
41
+ super(WEBPACK_MODULE_TYPE_FALLBACK);
41
42
  this.requests = requests;
42
43
  this._identifier = `fallback ${this.requests.join(" ")}`;
43
44
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  const { RawSource } = require("webpack-sources");
9
9
  const Module = require("../Module");
10
+ const { WEBPACK_MODULE_TYPE_REMOTE } = require("../ModuleTypeConstants");
10
11
  const RuntimeGlobals = require("../RuntimeGlobals");
11
12
  const makeSerializable = require("../util/makeSerializable");
12
13
  const FallbackDependency = require("./FallbackDependency");
@@ -39,7 +40,7 @@ class RemoteModule extends Module {
39
40
  * @param {string} shareScope the used share scope name
40
41
  */
41
42
  constructor(request, externalRequests, internalRequest, shareScope) {
42
- super("remote-module");
43
+ super(WEBPACK_MODULE_TYPE_REMOTE);
43
44
  this.request = request;
44
45
  this.externalRequests = externalRequests;
45
46
  this.internalRequest = internalRequest;
@@ -157,7 +157,6 @@ class CssModulesPlugin {
157
157
  return new CssParser();
158
158
  case CSS_MODULE_TYPE_GLOBAL:
159
159
  return new CssParser({
160
- allowPseudoBlocks: false,
161
160
  allowModeSwitch: false
162
161
  });
163
162
  case CSS_MODULE_TYPE_MODULE:
@@ -302,12 +301,20 @@ class CssModulesPlugin {
302
301
  }
303
302
  return result;
304
303
  });
305
- const enabledChunks = new WeakSet();
304
+ const globalChunkLoading = compilation.outputOptions.chunkLoading;
305
+ const isEnabledForChunk = chunk => {
306
+ const options = chunk.getEntryOptions();
307
+ const chunkLoading =
308
+ options && options.chunkLoading !== undefined
309
+ ? options.chunkLoading
310
+ : globalChunkLoading;
311
+ return chunkLoading === "jsonp";
312
+ };
313
+ const onceForChunkSet = new WeakSet();
306
314
  const handler = (chunk, set) => {
307
- if (enabledChunks.has(chunk)) {
308
- return;
309
- }
310
- enabledChunks.add(chunk);
315
+ if (onceForChunkSet.has(chunk)) return;
316
+ onceForChunkSet.add(chunk);
317
+ if (!isEnabledForChunk(chunk)) return;
311
318
 
312
319
  set.add(RuntimeGlobals.publicPath);
313
320
  set.add(RuntimeGlobals.getChunkCssFilename);