webpack 5.85.0 → 5.88.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.
- package/README.md +5 -2
- package/lib/APIPlugin.js +150 -99
- package/lib/AsyncDependenciesBlock.js +3 -3
- package/lib/BannerPlugin.js +2 -1
- package/lib/CaseSensitiveModulesWarning.js +3 -1
- package/lib/Chunk.js +35 -17
- package/lib/ChunkGraph.js +4 -4
- package/lib/ChunkGroup.js +20 -9
- package/lib/CompatibilityPlugin.js +50 -30
- package/lib/Compilation.js +2 -1
- package/lib/Compiler.js +10 -9
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +11 -1
- package/lib/ConstPlugin.js +73 -32
- package/lib/ContextModule.js +8 -3
- package/lib/ContextModuleFactory.js +1 -0
- package/lib/ContextReplacementPlugin.js +13 -0
- package/lib/DelegatedModule.js +15 -3
- package/lib/DelegatedModuleFactoryPlugin.js +6 -0
- package/lib/DependenciesBlock.js +1 -1
- package/lib/Dependency.js +11 -5
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllEntryPlugin.js +11 -1
- package/lib/DllModule.js +6 -0
- package/lib/DllReferencePlugin.js +13 -1
- package/lib/Entrypoint.js +1 -1
- package/lib/ErrorHelpers.js +1 -0
- package/lib/EvalSourceMapDevToolPlugin.js +6 -1
- package/lib/ExportsInfo.js +22 -4
- package/lib/ExportsInfoApiPlugin.js +14 -5
- package/lib/ExternalModule.js +20 -8
- package/lib/FileSystemInfo.js +52 -24
- package/lib/FlagAllModulesAsUsedPlugin.js +6 -1
- package/lib/FlagDependencyUsagePlugin.js +3 -1
- package/lib/FlagEntryExportAsUsedPlugin.js +4 -0
- package/lib/Generator.js +7 -0
- package/lib/HotModuleReplacementPlugin.js +8 -0
- package/lib/InitFragment.js +28 -5
- package/lib/JavascriptMetaInfoPlugin.js +11 -6
- package/lib/LibManifestPlugin.js +20 -4
- package/lib/Module.js +14 -3
- package/lib/ModuleDependencyError.js +4 -2
- package/lib/ModuleDependencyWarning.js +4 -2
- package/lib/ModuleGraph.js +31 -24
- package/lib/ModuleGraphConnection.js +19 -6
- package/lib/ModuleInfoHeaderPlugin.js +9 -2
- package/lib/ModuleNotFoundError.js +5 -2
- package/lib/ModuleProfile.js +1 -0
- package/lib/ModuleRestoreError.js +2 -0
- package/lib/ModuleStoreError.js +2 -1
- package/lib/ModuleTypeConstants.js +7 -0
- package/lib/MultiWatching.js +4 -0
- package/lib/NodeStuffPlugin.js +32 -6
- package/lib/ProgressPlugin.js +71 -15
- package/lib/ProvidePlugin.js +13 -4
- package/lib/RawModule.js +3 -1
- package/lib/RequireJsStuffPlugin.js +7 -0
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +3 -3
- package/lib/RuntimePlugin.js +6 -3
- package/lib/RuntimeTemplate.js +22 -4
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -0
- package/lib/SourceMapDevToolPlugin.js +7 -2
- package/lib/UseStrictPlugin.js +10 -3
- package/lib/Watching.js +62 -25
- package/lib/WebpackError.js +6 -5
- package/lib/WebpackIsIncludedPlugin.js +6 -4
- package/lib/WebpackOptionsApply.js +4 -2
- package/lib/WebpackOptionsDefaulter.js +10 -3
- package/lib/asset/AssetGenerator.js +2 -1
- package/lib/asset/AssetParser.js +11 -6
- package/lib/asset/AssetSourceParser.js +8 -3
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -0
- package/lib/buildChunkGraph.js +37 -21
- package/lib/cache/IdleFileCachePlugin.js +2 -1
- package/lib/cache/PackFileCacheStrategy.js +53 -22
- package/lib/config/browserslistTargetHandler.js +7 -7
- package/lib/config/defaults.js +43 -26
- package/lib/container/RemoteRuntimeModule.js +1 -1
- package/lib/css/CssExportsGenerator.js +9 -0
- package/lib/css/CssGenerator.js +1 -1
- package/lib/css/CssLoadingRuntimeModule.js +43 -19
- package/lib/css/CssModulesPlugin.js +42 -14
- package/lib/css/CssParser.js +22 -0
- package/lib/dependencies/AMDDefineDependency.js +34 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +5 -0
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +14 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +169 -59
- package/lib/dependencies/CommonJsPlugin.js +13 -8
- package/lib/dependencies/CommonJsRequireContextDependency.js +2 -2
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +7 -2
- package/lib/dependencies/CssImportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +5 -0
- package/lib/dependencies/CssUrlDependency.js +3 -3
- package/lib/dependencies/DllEntryDependency.js +5 -0
- package/lib/dependencies/DynamicExports.js +10 -6
- package/lib/dependencies/ExportsInfoDependency.js +14 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +2 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +4 -4
- package/lib/dependencies/HarmonyExports.js +9 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +40 -27
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +1 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +31 -21
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -3
- package/lib/dependencies/ImportDependency.js +5 -3
- package/lib/dependencies/ImportEagerDependency.js +5 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +19 -0
- package/lib/dependencies/ImportMetaPlugin.js +31 -15
- package/lib/dependencies/ImportParserPlugin.js +62 -25
- package/lib/dependencies/ImportWeakDependency.js +5 -3
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +2 -1
- package/lib/dependencies/ProvidedDependency.js +4 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +13 -5
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +5 -2
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +6 -1
- package/lib/dependencies/RequireHeaderDependency.js +4 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +26 -5
- package/lib/dependencies/RequireResolveHeaderDependency.js +9 -0
- package/lib/dependencies/SystemPlugin.js +17 -5
- package/lib/dependencies/SystemRuntimeModule.js +1 -1
- package/lib/dependencies/URLDependency.js +2 -2
- package/lib/dependencies/URLPlugin.js +9 -4
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +59 -22
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -0
- package/lib/javascript/BasicEvaluatedExpression.js +28 -19
- package/lib/javascript/CommonJsChunkFormatPlugin.js +6 -2
- package/lib/javascript/JavascriptModulesPlugin.js +25 -5
- package/lib/javascript/JavascriptParser.js +157 -85
- package/lib/javascript/JavascriptParserHelpers.js +37 -15
- package/lib/json/JsonData.js +2 -2
- package/lib/json/JsonParser.js +25 -12
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +13 -1
- package/lib/library/EnableLibraryPlugin.js +4 -0
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +20 -2
- package/lib/logging/runtime.js +1 -1
- package/lib/logging/truncateArgs.js +4 -0
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +10 -6
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
- package/lib/node/RequireChunkLoadingRuntimeModule.js +10 -6
- package/lib/optimize/AggressiveMergingPlugin.js +8 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
- package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
- package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +2 -1
- package/lib/optimize/LimitChunkCountPlugin.js +29 -4
- package/lib/optimize/MangleExportsPlugin.js +1 -1
- package/lib/optimize/MinMaxSizeWarning.js +5 -0
- package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
- package/lib/optimize/RealContentHashPlugin.js +80 -30
- package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
- package/lib/optimize/RuntimeChunkPlugin.js +9 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
- package/lib/optimize/SplitChunksPlugin.js +71 -31
- package/lib/performance/SizeLimitsPlugin.js +7 -4
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +3 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +6 -3
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +4 -2
- package/lib/rules/BasicEffectRulePlugin.js +4 -0
- package/lib/rules/BasicMatcherRulePlugin.js +5 -0
- package/lib/rules/RuleSetCompiler.js +3 -3
- package/lib/rules/UseEffectRulePlugin.js +6 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +8 -5
- package/lib/runtime/AutoPublicPathRuntimeModule.js +4 -2
- package/lib/runtime/BaseUriRuntimeModule.js +3 -3
- package/lib/runtime/ChunkNameRuntimeModule.js +1 -1
- package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +5 -2
- package/lib/runtime/CompatRuntimeModule.js +7 -2
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/CreateScriptRuntimeModule.js +4 -2
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +4 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +5 -2
- package/lib/runtime/EnsureChunkRuntimeModule.js +15 -4
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +6 -10
- package/lib/runtime/GetFullHashRuntimeModule.js +4 -3
- package/lib/runtime/GetMainFilenameRuntimeModule.js +5 -2
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +4 -2
- package/lib/runtime/GlobalRuntimeModule.js +1 -1
- package/lib/runtime/HasOwnPropertyRuntimeModule.js +5 -2
- package/lib/runtime/LoadScriptRuntimeModule.js +64 -48
- package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +5 -2
- package/lib/runtime/NonceRuntimeModule.js +1 -1
- package/lib/runtime/OnChunksLoadedRuntimeModule.js +4 -2
- package/lib/runtime/PublicPathRuntimeModule.js +4 -2
- package/lib/runtime/RelativeUrlRuntimeModule.js +5 -2
- package/lib/runtime/RuntimeIdRuntimeModule.js +6 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -3
- package/lib/runtime/StartupEntrypointRuntimeModule.js +3 -2
- package/lib/runtime/SystemContextRuntimeModule.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +143 -1
- package/lib/serialization/ErrorObjectSerializer.js +3 -0
- package/lib/serialization/ObjectMiddleware.js +9 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedFallbackDependency.js +3 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +14 -5
- package/lib/sharing/ProvideSharedDependency.js +11 -0
- package/lib/sharing/ProvideSharedModule.js +4 -0
- package/lib/sharing/ProvideSharedPlugin.js +22 -21
- package/lib/sharing/ShareRuntimeModule.js +12 -5
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/sharing/utils.js +32 -5
- package/lib/util/AsyncQueue.js +4 -2
- package/lib/util/ParallelismFactorCalculator.js +10 -0
- package/lib/util/Semaphore.js +1 -1
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/createHash.js +30 -9
- package/lib/util/deprecation.js +10 -3
- package/lib/util/deterministicGrouping.js +50 -11
- package/lib/util/findGraphRoots.js +4 -2
- package/lib/util/memoize.js +3 -3
- package/lib/util/processAsyncTree.js +7 -1
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +84 -21
- package/lib/util/semver.js +1 -0
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +6 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +6 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +7 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +14 -7
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +3 -1
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -0
- package/lib/wasm-sync/WebAssemblyParser.js +6 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +14 -4
- package/lib/webpack.js +11 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +15 -16
- package/module.d.ts +1 -0
- package/package.json +5 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +52 -6
- package/schemas/plugins/css/CssGeneratorOptions.json +1 -1
- package/schemas/plugins/css/CssParserOptions.json +1 -1
- package/types.d.ts +606 -292
@@ -11,7 +11,8 @@ const HotUpdateChunk = require("../HotUpdateChunk");
|
|
11
11
|
const {
|
12
12
|
CSS_MODULE_TYPE,
|
13
13
|
CSS_MODULE_TYPE_GLOBAL,
|
14
|
-
CSS_MODULE_TYPE_MODULE
|
14
|
+
CSS_MODULE_TYPE_MODULE,
|
15
|
+
CSS_MODULE_TYPE_AUTO
|
15
16
|
} = require("../ModuleTypeConstants");
|
16
17
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
17
18
|
const SelfModuleFactory = require("../SelfModuleFactory");
|
@@ -46,6 +47,10 @@ const getCssLoadingRuntimeModule = memoize(() =>
|
|
46
47
|
require("./CssLoadingRuntimeModule")
|
47
48
|
);
|
48
49
|
|
50
|
+
/**
|
51
|
+
* @param {string} name name
|
52
|
+
* @returns {{oneOf: [{$ref: string}], definitions: *}} schema
|
53
|
+
*/
|
49
54
|
const getSchema = name => {
|
50
55
|
const { definitions } = require("../../schemas/WebpackOptions.json");
|
51
56
|
return {
|
@@ -145,7 +150,8 @@ class CssModulesPlugin {
|
|
145
150
|
for (const type of [
|
146
151
|
CSS_MODULE_TYPE,
|
147
152
|
CSS_MODULE_TYPE_GLOBAL,
|
148
|
-
CSS_MODULE_TYPE_MODULE
|
153
|
+
CSS_MODULE_TYPE_MODULE,
|
154
|
+
CSS_MODULE_TYPE_AUTO
|
149
155
|
]) {
|
150
156
|
normalModuleFactory.hooks.createParser
|
151
157
|
.for(type)
|
@@ -154,6 +160,7 @@ class CssModulesPlugin {
|
|
154
160
|
|
155
161
|
switch (type) {
|
156
162
|
case CSS_MODULE_TYPE:
|
163
|
+
case CSS_MODULE_TYPE_AUTO:
|
157
164
|
return new CssParser();
|
158
165
|
case CSS_MODULE_TYPE_GLOBAL:
|
159
166
|
return new CssParser({
|
@@ -302,6 +309,10 @@ class CssModulesPlugin {
|
|
302
309
|
return result;
|
303
310
|
});
|
304
311
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
312
|
+
/**
|
313
|
+
* @param {Chunk} chunk the chunk
|
314
|
+
* @returns {boolean} true, when enabled
|
315
|
+
*/
|
305
316
|
const isEnabledForChunk = chunk => {
|
306
317
|
const options = chunk.getEntryOptions();
|
307
318
|
const chunkLoading =
|
@@ -311,6 +322,10 @@ class CssModulesPlugin {
|
|
311
322
|
return chunkLoading === "jsonp";
|
312
323
|
};
|
313
324
|
const onceForChunkSet = new WeakSet();
|
325
|
+
/**
|
326
|
+
* @param {Chunk} chunk chunk to check
|
327
|
+
* @param {Set<string>} set runtime requirements
|
328
|
+
*/
|
314
329
|
const handler = (chunk, set) => {
|
315
330
|
if (onceForChunkSet.has(chunk)) return;
|
316
331
|
onceForChunkSet.add(chunk);
|
@@ -361,7 +376,10 @@ class CssModulesPlugin {
|
|
361
376
|
};
|
362
377
|
})
|
363
378
|
.filter(item => item.index !== undefined)
|
364
|
-
.sort(
|
379
|
+
.sort(
|
380
|
+
(a, b) =>
|
381
|
+
/** @type {number} */ (b.index) - /** @type {number} */ (a.index)
|
382
|
+
)
|
365
383
|
.map(item => item.module);
|
366
384
|
|
367
385
|
return { list: sortedModules, set: new Set(sortedModules) };
|
@@ -455,19 +473,25 @@ class CssModulesPlugin {
|
|
455
473
|
return [
|
456
474
|
...this.getModulesInOrder(
|
457
475
|
chunk,
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
476
|
+
/** @type {Iterable<Module>} */
|
477
|
+
(
|
478
|
+
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
479
|
+
chunk,
|
480
|
+
"css-import",
|
481
|
+
compareModulesByIdentifier
|
482
|
+
)
|
462
483
|
),
|
463
484
|
compilation
|
464
485
|
),
|
465
486
|
...this.getModulesInOrder(
|
466
487
|
chunk,
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
488
|
+
/** @type {Iterable<Module>} */
|
489
|
+
(
|
490
|
+
chunkGraph.getOrderedChunkModulesIterableBySourceType(
|
491
|
+
chunk,
|
492
|
+
"css",
|
493
|
+
compareModulesByIdentifier
|
494
|
+
)
|
471
495
|
),
|
472
496
|
compilation
|
473
497
|
)
|
@@ -498,8 +522,11 @@ class CssModulesPlugin {
|
|
498
522
|
const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
|
499
523
|
|
500
524
|
let moduleSource =
|
501
|
-
|
502
|
-
|
525
|
+
/** @type {Source} */
|
526
|
+
(
|
527
|
+
codeGenResult.sources.get("css") ||
|
528
|
+
codeGenResult.sources.get("css-import")
|
529
|
+
);
|
503
530
|
|
504
531
|
let inheritance = [[module.cssLayer, module.supports, module.media]];
|
505
532
|
|
@@ -569,7 +596,8 @@ class CssModulesPlugin {
|
|
569
596
|
}${escapeCss(moduleId)}`
|
570
597
|
);
|
571
598
|
} catch (e) {
|
572
|
-
|
599
|
+
/** @type {Error} */
|
600
|
+
(e).message += `\nduring rendering of css ${module.identifier()}`;
|
573
601
|
throw e;
|
574
602
|
}
|
575
603
|
}
|
package/lib/css/CssParser.js
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const ModuleDependencyWarning = require("../ModuleDependencyWarning");
|
9
|
+
const { CSS_MODULE_TYPE_AUTO } = require("../ModuleTypeConstants");
|
9
10
|
const Parser = require("../Parser");
|
10
11
|
const WebpackError = require("../WebpackError");
|
11
12
|
const ConstDependency = require("../dependencies/ConstDependency");
|
@@ -15,6 +16,7 @@ const CssLocalIdentifierDependency = require("../dependencies/CssLocalIdentifier
|
|
15
16
|
const CssSelfLocalIdentifierDependency = require("../dependencies/CssSelfLocalIdentifierDependency");
|
16
17
|
const CssUrlDependency = require("../dependencies/CssUrlDependency");
|
17
18
|
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
19
|
+
const { parseResource } = require("../util/identifier");
|
18
20
|
const walkCssTokens = require("./walkCssTokens");
|
19
21
|
|
20
22
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
@@ -37,6 +39,7 @@ const IMAGE_SET_FUNCTION = /^(-\w+-)?image-set$/i;
|
|
37
39
|
const OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE = /^@(-\w+-)?keyframes$/;
|
38
40
|
const OPTIONALLY_VENDOR_PREFIXED_ANIMATION_PROPERTY =
|
39
41
|
/^(-\w+-)?animation(-name)?$/i;
|
42
|
+
const IS_MODULES = /\.module(s)?\.[^.]+$/i;
|
40
43
|
|
41
44
|
/**
|
42
45
|
* @param {string} str url string
|
@@ -169,6 +172,21 @@ class CssParser extends Parser {
|
|
169
172
|
}
|
170
173
|
|
171
174
|
const module = state.module;
|
175
|
+
|
176
|
+
/** @type {string | undefined} */
|
177
|
+
let oldDefaultMode;
|
178
|
+
|
179
|
+
if (
|
180
|
+
module.type === CSS_MODULE_TYPE_AUTO &&
|
181
|
+
IS_MODULES.test(
|
182
|
+
parseResource(module.matchResource || module.resource).path
|
183
|
+
)
|
184
|
+
) {
|
185
|
+
oldDefaultMode = this.defaultMode;
|
186
|
+
|
187
|
+
this.defaultMode = "local";
|
188
|
+
}
|
189
|
+
|
172
190
|
const locConverter = new LocConverter(source);
|
173
191
|
/** @type {Set<string>}*/
|
174
192
|
const declaredCssVariables = new Set();
|
@@ -1001,6 +1019,10 @@ class CssParser extends Parser {
|
|
1001
1019
|
}
|
1002
1020
|
});
|
1003
1021
|
|
1022
|
+
if (oldDefaultMode) {
|
1023
|
+
this.defaultMode = oldDefaultMode;
|
1024
|
+
}
|
1025
|
+
|
1004
1026
|
module.buildInfo.strict = true;
|
1005
1027
|
module.buildMeta.exportsType = "namespace";
|
1006
1028
|
module.addDependency(new StaticExportsDependency([], true));
|
@@ -180,6 +180,10 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends (
|
|
180
180
|
this.replace(dep, source, definition, content);
|
181
181
|
}
|
182
182
|
|
183
|
+
/**
|
184
|
+
* @param {AMDDefineDependency} dependency dependency
|
185
|
+
* @returns {string} variable name
|
186
|
+
*/
|
183
187
|
localModuleVar(dependency) {
|
184
188
|
return (
|
185
189
|
dependency.localModule &&
|
@@ -188,6 +192,10 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends (
|
|
188
192
|
);
|
189
193
|
}
|
190
194
|
|
195
|
+
/**
|
196
|
+
* @param {AMDDefineDependency} dependency dependency
|
197
|
+
* @returns {string} branch
|
198
|
+
*/
|
191
199
|
branch(dependency) {
|
192
200
|
const localModuleVar = this.localModuleVar(dependency) ? "l" : "";
|
193
201
|
const arrayRange = dependency.arrayRange ? "a" : "";
|
@@ -196,6 +204,12 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends (
|
|
196
204
|
return localModuleVar + arrayRange + objectRange + functionRange;
|
197
205
|
}
|
198
206
|
|
207
|
+
/**
|
208
|
+
* @param {AMDDefineDependency} dependency dependency
|
209
|
+
* @param {ReplaceSource} source source
|
210
|
+
* @param {string} definition definition
|
211
|
+
* @param {string} text text
|
212
|
+
*/
|
199
213
|
replace(dependency, source, definition, text) {
|
200
214
|
const localModuleVar = this.localModuleVar(dependency);
|
201
215
|
if (localModuleVar) {
|
@@ -216,18 +230,34 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends (
|
|
216
230
|
|
217
231
|
let current = dependency.range[0];
|
218
232
|
if (dependency.arrayRange) {
|
219
|
-
source.replace(
|
233
|
+
source.replace(
|
234
|
+
current,
|
235
|
+
dependency.arrayRange[0] - 1,
|
236
|
+
/** @type {string} */ (texts.shift())
|
237
|
+
);
|
220
238
|
current = dependency.arrayRange[1];
|
221
239
|
}
|
222
240
|
|
223
241
|
if (dependency.objectRange) {
|
224
|
-
source.replace(
|
242
|
+
source.replace(
|
243
|
+
current,
|
244
|
+
dependency.objectRange[0] - 1,
|
245
|
+
/** @type {string} */ (texts.shift())
|
246
|
+
);
|
225
247
|
current = dependency.objectRange[1];
|
226
248
|
} else if (dependency.functionRange) {
|
227
|
-
source.replace(
|
249
|
+
source.replace(
|
250
|
+
current,
|
251
|
+
dependency.functionRange[0] - 1,
|
252
|
+
/** @type {string} */ (texts.shift())
|
253
|
+
);
|
228
254
|
current = dependency.functionRange[1];
|
229
255
|
}
|
230
|
-
source.replace(
|
256
|
+
source.replace(
|
257
|
+
current,
|
258
|
+
dependency.range[1] - 1,
|
259
|
+
/** @type {string} */ (texts.shift())
|
260
|
+
);
|
231
261
|
if (texts.length > 0) throw new Error("Implementation error");
|
232
262
|
}
|
233
263
|
};
|
@@ -16,8 +16,13 @@ const DynamicExports = require("./DynamicExports");
|
|
16
16
|
const LocalModuleDependency = require("./LocalModuleDependency");
|
17
17
|
const { addLocalModule, getLocalModule } = require("./LocalModulesHelpers");
|
18
18
|
|
19
|
+
/** @typedef {import("estree").CallExpression} CallExpression */
|
19
20
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
20
21
|
|
22
|
+
/**
|
23
|
+
* @param {CallExpression} expr expression
|
24
|
+
* @returns {boolean} true if it's a bound function expression
|
25
|
+
*/
|
21
26
|
const isBoundFunctionExpression = expr => {
|
22
27
|
if (expr.type !== "CallExpression") return false;
|
23
28
|
if (expr.callee.type !== "MemberExpression") return false;
|
@@ -14,7 +14,7 @@ class AMDDefineRuntimeModule extends RuntimeModule {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
/**
|
17
|
-
* @returns {string} runtime code
|
17
|
+
* @returns {string | null} runtime code
|
18
18
|
*/
|
19
19
|
generate() {
|
20
20
|
return Template.asString([
|
@@ -35,7 +35,7 @@ class AMDOptionsRuntimeModule extends RuntimeModule {
|
|
35
35
|
}
|
36
36
|
|
37
37
|
/**
|
38
|
-
* @returns {string} runtime code
|
38
|
+
* @returns {string | null} runtime code
|
39
39
|
*/
|
40
40
|
generate() {
|
41
41
|
return Template.asString([
|
@@ -21,6 +21,7 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
|
|
21
21
|
/** @typedef {import("estree").Expression} Expression */
|
22
22
|
/** @typedef {import("estree").Super} Super */
|
23
23
|
|
24
|
+
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
24
25
|
/** @typedef {import("../NormalModule")} NormalModule */
|
25
26
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
26
27
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
@@ -43,7 +44,7 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
|
|
43
44
|
* ```
|
44
45
|
*
|
45
46
|
* @param {TODO} expr expression
|
46
|
-
* @returns {Expression} returns the value of property descriptor
|
47
|
+
* @returns {Expression | undefined} returns the value of property descriptor
|
47
48
|
*/
|
48
49
|
const getValueOfPropertyDescription = expr => {
|
49
50
|
if (expr.type !== "ObjectExpression") return;
|
@@ -127,6 +128,9 @@ const parseRequireCall = (parser, expr) => {
|
|
127
128
|
};
|
128
129
|
|
129
130
|
class CommonJsExportsParserPlugin {
|
131
|
+
/**
|
132
|
+
* @param {ModuleGraph} moduleGraph module graph
|
133
|
+
*/
|
130
134
|
constructor(moduleGraph) {
|
131
135
|
this.moduleGraph = moduleGraph;
|
132
136
|
}
|
@@ -143,7 +147,7 @@ class CommonJsExportsParserPlugin {
|
|
143
147
|
/**
|
144
148
|
* @param {boolean} topLevel true, when the export is on top level
|
145
149
|
* @param {string[]} members members of the export
|
146
|
-
* @param {Expression} valueExpr expression for the value
|
150
|
+
* @param {Expression | undefined} valueExpr expression for the value
|
147
151
|
* @returns {void}
|
148
152
|
*/
|
149
153
|
const checkNamespace = (topLevel, members, valueExpr) => {
|
@@ -156,10 +160,16 @@ class CommonJsExportsParserPlugin {
|
|
156
160
|
}
|
157
161
|
}
|
158
162
|
};
|
163
|
+
/**
|
164
|
+
* @param {string=} reason reason
|
165
|
+
*/
|
159
166
|
const bailout = reason => {
|
160
167
|
DynamicExports.bailout(parser.state);
|
161
168
|
if (reason) bailoutHint(reason);
|
162
169
|
};
|
170
|
+
/**
|
171
|
+
* @param {string} reason reason
|
172
|
+
*/
|
163
173
|
const bailoutHint = reason => {
|
164
174
|
this.moduleGraph
|
165
175
|
.getOptimizationBailout(parser.state.module)
|
@@ -292,8 +302,8 @@ class CommonJsExportsParserPlugin {
|
|
292
302
|
* @param {Expression | Super} expr expression
|
293
303
|
* @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
|
294
304
|
* @param {string[]} members members of the export
|
295
|
-
* @param {CallExpression} call call expression
|
296
|
-
* @returns {boolean} true, when the expression was handled
|
305
|
+
* @param {CallExpression=} call call expression
|
306
|
+
* @returns {boolean | void} true, when the expression was handled
|
297
307
|
*/
|
298
308
|
const handleAccessExport = (expr, base, members, call = undefined) => {
|
299
309
|
if (HarmonyExports.isEnabled(parser.state)) return;
|