webpack 5.59.0 → 5.76.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/README.md +22 -24
- package/bin/webpack.js +0 -0
- package/hot/dev-server.js +17 -4
- package/hot/lazy-compilation-node.js +3 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +33 -0
- package/lib/BannerPlugin.js +13 -5
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +4 -11
- package/lib/Chunk.js +6 -3
- package/lib/ChunkGraph.js +94 -8
- package/lib/ChunkGroup.js +1 -1
- package/lib/CleanPlugin.js +81 -20
- package/lib/Compilation.js +188 -93
- package/lib/Compiler.js +87 -18
- package/lib/ConstPlugin.js +2 -2
- package/lib/ContextModule.js +142 -51
- package/lib/ContextModuleFactory.js +65 -25
- package/lib/DelegatedModule.js +1 -1
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/Dependency.js +17 -0
- package/lib/DependencyTemplate.js +9 -0
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +2 -0
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +25 -4
- package/lib/ExportsInfo.js +5 -5
- package/lib/ExternalModule.js +94 -54
- package/lib/ExternalModuleFactoryPlugin.js +5 -5
- package/lib/FileSystemInfo.js +124 -58
- package/lib/Generator.js +3 -0
- package/lib/HookWebpackError.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +3 -1
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/Module.js +28 -4
- package/lib/ModuleFilenameHelpers.js +8 -4
- package/lib/ModuleHashingError.js +29 -0
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NodeStuffPlugin.js +13 -3
- package/lib/NormalModule.js +51 -33
- package/lib/NormalModuleFactory.js +42 -37
- package/lib/ProgressPlugin.js +4 -5
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +29 -1
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +84 -1
- package/lib/RuntimeTemplate.js +114 -2
- package/lib/Template.js +3 -2
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/WatchIgnorePlugin.js +19 -7
- package/lib/Watching.js +33 -19
- package/lib/WebpackOptionsApply.js +79 -11
- package/lib/asset/AssetGenerator.js +228 -71
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/AssetParser.js +1 -0
- package/lib/asset/AssetSourceGenerator.js +31 -6
- package/lib/asset/AssetSourceParser.js +1 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +38 -7
- package/lib/cache/PackFileCacheStrategy.js +15 -8
- package/lib/cache/ResolverCachePlugin.js +90 -29
- package/lib/cli.js +44 -3
- package/lib/config/browserslistTargetHandler.js +41 -6
- package/lib/config/defaults.js +123 -19
- package/lib/config/normalization.js +10 -2
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerEntryModule.js +8 -5
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/ModuleFederationPlugin.js +2 -0
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/RemoteRuntimeModule.js +8 -7
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +109 -0
- package/lib/css/CssLoadingRuntimeModule.js +442 -0
- package/lib/css/CssModulesPlugin.js +462 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +24 -21
- package/lib/dependencies/AMDRequireDependency.js +6 -6
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -2
- package/lib/dependencies/CommonJsFullRequireDependency.js +5 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +344 -61
- package/lib/dependencies/CommonJsRequireContextDependency.js +6 -2
- package/lib/dependencies/CommonJsRequireDependency.js +2 -1
- package/lib/dependencies/ContextDependency.js +16 -2
- package/lib/dependencies/ContextDependencyHelpers.js +21 -8
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +4 -1
- package/lib/dependencies/ContextElementDependency.js +25 -3
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/CssExportDependency.js +85 -0
- package/lib/dependencies/CssImportDependency.js +75 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
- package/lib/dependencies/CssUrlDependency.js +132 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +5 -3
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +127 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +25 -17
- package/lib/dependencies/HarmonyExportInitFragment.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +23 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +142 -45
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -22
- package/lib/dependencies/HarmonyModulesPlugin.js +10 -0
- package/lib/dependencies/ImportContextDependency.js +0 -2
- package/lib/dependencies/ImportMetaContextDependency.js +35 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +252 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +59 -0
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/ImportParserPlugin.js +35 -29
- package/lib/dependencies/JsonExportsDependency.js +17 -21
- package/lib/dependencies/LoaderDependency.js +13 -0
- package/lib/dependencies/LoaderImportDependency.js +13 -0
- package/lib/dependencies/LoaderPlugin.js +4 -2
- package/lib/dependencies/ModuleDependency.js +11 -1
- package/lib/dependencies/ProvidedDependency.js +31 -8
- package/lib/dependencies/RequireContextDependency.js +0 -16
- package/lib/dependencies/RequireEnsureDependency.js +2 -2
- package/lib/dependencies/RequireResolveContextDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -1
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/dependencies/URLPlugin.js +22 -1
- package/lib/dependencies/WorkerPlugin.js +2 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +25 -9
- package/lib/hmr/HotModuleReplacement.runtime.js +29 -14
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/lib/hmr/LazyCompilationPlugin.js +54 -26
- package/lib/hmr/lazyCompilationBackend.js +51 -12
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +11 -14
- package/lib/ids/IdHelpers.js +26 -12
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +20 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
- package/lib/javascript/BasicEvaluatedExpression.js +5 -2
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/JavascriptParser.js +143 -73
- package/lib/javascript/StartupHelpers.js +7 -30
- package/lib/json/JsonData.js +8 -0
- package/lib/json/JsonParser.js +4 -6
- package/lib/library/AssignLibraryPlugin.js +39 -15
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/library/UmdLibraryPlugin.js +5 -3
- package/lib/node/NodeTargetPlugin.js +3 -0
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +23 -8
- package/lib/node/RequireChunkLoadingRuntimeModule.js +24 -9
- package/lib/optimize/ConcatenatedModule.js +62 -26
- package/lib/optimize/ModuleConcatenationPlugin.js +26 -4
- package/lib/optimize/RealContentHashPlugin.js +45 -15
- package/lib/optimize/SplitChunksPlugin.js +8 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +50 -66
- package/lib/runtime/BaseUriRuntimeModule.js +31 -0
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/runtime/LoadScriptRuntimeModule.js +11 -9
- package/lib/runtime/NonceRuntimeModule.js +24 -0
- package/lib/schemes/HttpUriPlugin.js +77 -14
- package/lib/serialization/FileMiddleware.js +44 -9
- package/lib/sharing/ConsumeSharedModule.js +8 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +26 -5
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/ProvideSharedPlugin.js +1 -2
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +113 -68
- package/lib/stats/DefaultStatsPrinterPlugin.js +90 -25
- package/lib/util/ArrayHelpers.js +30 -0
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/create-schema-validation.js +9 -2
- package/lib/util/createHash.js +12 -0
- package/lib/util/deprecation.js +10 -2
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/fs.js +11 -0
- package/lib/util/hash/BatchedHash.js +7 -4
- package/lib/util/hash/md4.js +20 -0
- package/lib/util/hash/wasm-hash.js +163 -0
- package/lib/util/hash/xxhash64.js +5 -139
- package/lib/util/identifier.js +65 -44
- package/lib/util/internalSerializables.js +15 -0
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/wasm-sync/WebAssemblyParser.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +31 -18
- package/lib/webpack.js +10 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +33 -22
- package/module.d.ts +215 -0
- package/package.json +28 -32
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +321 -30
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +4 -0
- package/types.d.ts +869 -296
package/lib/config/defaults.js
CHANGED
@@ -16,6 +16,7 @@ const {
|
|
16
16
|
} = require("./target");
|
17
17
|
|
18
18
|
/** @typedef {import("../../declarations/WebpackOptions").CacheOptionsNormalized} CacheOptions */
|
19
|
+
/** @typedef {import("../../declarations/WebpackOptions").CssExperimentOptions} CssExperimentOptions */
|
19
20
|
/** @typedef {import("../../declarations/WebpackOptions").EntryDescription} EntryDescription */
|
20
21
|
/** @typedef {import("../../declarations/WebpackOptions").EntryNormalized} Entry */
|
21
22
|
/** @typedef {import("../../declarations/WebpackOptions").Experiments} Experiments */
|
@@ -160,7 +161,11 @@ const applyWebpackOptionsDefaults = options => {
|
|
160
161
|
D(options, "recordsInputPath", false);
|
161
162
|
D(options, "recordsOutputPath", false);
|
162
163
|
|
163
|
-
applyExperimentsDefaults(options.experiments, {
|
164
|
+
applyExperimentsDefaults(options.experiments, {
|
165
|
+
production,
|
166
|
+
development,
|
167
|
+
targetProperties
|
168
|
+
});
|
164
169
|
|
165
170
|
const futureDefaults = options.experiments.futureDefaults;
|
166
171
|
|
@@ -183,7 +188,10 @@ const applyWebpackOptionsDefaults = options => {
|
|
183
188
|
applyModuleDefaults(options.module, {
|
184
189
|
cache,
|
185
190
|
syncWebAssembly: options.experiments.syncWebAssembly,
|
186
|
-
asyncWebAssembly: options.experiments.asyncWebAssembly
|
191
|
+
asyncWebAssembly: options.experiments.asyncWebAssembly,
|
192
|
+
css: options.experiments.css,
|
193
|
+
futureDefaults,
|
194
|
+
isNode: targetProperties && targetProperties.node === true
|
187
195
|
});
|
188
196
|
|
189
197
|
applyOutputDefaults(options.output, {
|
@@ -238,6 +246,7 @@ const applyWebpackOptionsDefaults = options => {
|
|
238
246
|
applyOptimizationDefaults(options.optimization, {
|
239
247
|
development,
|
240
248
|
production,
|
249
|
+
css: options.experiments.css,
|
241
250
|
records: !!(options.recordsInputPath || options.recordsOutputPath)
|
242
251
|
});
|
243
252
|
|
@@ -262,24 +271,37 @@ const applyWebpackOptionsDefaults = options => {
|
|
262
271
|
* @param {Object} options options
|
263
272
|
* @param {boolean} options.production is production
|
264
273
|
* @param {boolean} options.development is development mode
|
274
|
+
* @param {TargetProperties | false} options.targetProperties target properties
|
265
275
|
* @returns {void}
|
266
276
|
*/
|
267
|
-
const applyExperimentsDefaults = (
|
268
|
-
|
277
|
+
const applyExperimentsDefaults = (
|
278
|
+
experiments,
|
279
|
+
{ production, development, targetProperties }
|
280
|
+
) => {
|
281
|
+
D(experiments, "futureDefaults", false);
|
282
|
+
D(experiments, "backCompat", !experiments.futureDefaults);
|
283
|
+
D(experiments, "topLevelAwait", experiments.futureDefaults);
|
269
284
|
D(experiments, "syncWebAssembly", false);
|
270
|
-
D(experiments, "asyncWebAssembly",
|
285
|
+
D(experiments, "asyncWebAssembly", experiments.futureDefaults);
|
271
286
|
D(experiments, "outputModule", false);
|
272
|
-
D(experiments, "asset", false);
|
273
287
|
D(experiments, "layers", false);
|
274
288
|
D(experiments, "lazyCompilation", undefined);
|
275
289
|
D(experiments, "buildHttp", undefined);
|
276
|
-
D(experiments, "futureDefaults", false);
|
277
290
|
D(experiments, "cacheUnaffected", experiments.futureDefaults);
|
291
|
+
F(experiments, "css", () => (experiments.futureDefaults ? {} : undefined));
|
278
292
|
|
279
293
|
if (typeof experiments.buildHttp === "object") {
|
280
294
|
D(experiments.buildHttp, "frozen", production);
|
281
295
|
D(experiments.buildHttp, "upgrade", false);
|
282
296
|
}
|
297
|
+
|
298
|
+
if (typeof experiments.css === "object") {
|
299
|
+
D(
|
300
|
+
experiments.css,
|
301
|
+
"exportsOnly",
|
302
|
+
!targetProperties || !targetProperties.document
|
303
|
+
);
|
304
|
+
}
|
283
305
|
};
|
284
306
|
|
285
307
|
/**
|
@@ -382,7 +404,7 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
|
|
382
404
|
return [path.resolve(match[1], "unplugged")];
|
383
405
|
}
|
384
406
|
} else {
|
385
|
-
const match = /^(.+?[\\/]node_modules
|
407
|
+
const match = /^(.+?[\\/]node_modules[\\/])/.exec(
|
386
408
|
// eslint-disable-next-line node/no-extraneous-require
|
387
409
|
require.resolve("watchpack")
|
388
410
|
);
|
@@ -428,9 +450,15 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
|
|
428
450
|
|
429
451
|
/**
|
430
452
|
* @param {JavascriptParserOptions} parserOptions parser options
|
453
|
+
* @param {Object} options options
|
454
|
+
* @param {boolean} options.futureDefaults is future defaults enabled
|
455
|
+
* @param {boolean} options.isNode is node target platform
|
431
456
|
* @returns {void}
|
432
457
|
*/
|
433
|
-
const applyJavascriptParserOptionsDefaults =
|
458
|
+
const applyJavascriptParserOptionsDefaults = (
|
459
|
+
parserOptions,
|
460
|
+
{ futureDefaults, isNode }
|
461
|
+
) => {
|
434
462
|
D(parserOptions, "unknownContextRequest", ".");
|
435
463
|
D(parserOptions, "unknownContextRegExp", false);
|
436
464
|
D(parserOptions, "unknownContextRecursive", true);
|
@@ -442,9 +470,13 @@ const applyJavascriptParserOptionsDefaults = parserOptions => {
|
|
442
470
|
D(parserOptions, "wrappedContextRegExp", /.*/);
|
443
471
|
D(parserOptions, "wrappedContextRecursive", true);
|
444
472
|
D(parserOptions, "wrappedContextCritical", false);
|
445
|
-
|
446
|
-
D(parserOptions, "strictExportPresence", false);
|
447
473
|
D(parserOptions, "strictThisContextOnImports", false);
|
474
|
+
D(parserOptions, "importMeta", true);
|
475
|
+
D(parserOptions, "dynamicImportMode", "lazy");
|
476
|
+
D(parserOptions, "dynamicImportPrefetch", false);
|
477
|
+
D(parserOptions, "dynamicImportPreload", false);
|
478
|
+
D(parserOptions, "createRequire", isNode);
|
479
|
+
if (futureDefaults) D(parserOptions, "exportsPresence", "error");
|
448
480
|
};
|
449
481
|
|
450
482
|
/**
|
@@ -453,11 +485,14 @@ const applyJavascriptParserOptionsDefaults = parserOptions => {
|
|
453
485
|
* @param {boolean} options.cache is caching enabled
|
454
486
|
* @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
|
455
487
|
* @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
|
488
|
+
* @param {CssExperimentOptions|false} options.css is css enabled
|
489
|
+
* @param {boolean} options.futureDefaults is future defaults enabled
|
490
|
+
* @param {boolean} options.isNode is node target platform
|
456
491
|
* @returns {void}
|
457
492
|
*/
|
458
493
|
const applyModuleDefaults = (
|
459
494
|
module,
|
460
|
-
{ cache, syncWebAssembly, asyncWebAssembly }
|
495
|
+
{ cache, syncWebAssembly, asyncWebAssembly, css, futureDefaults, isNode }
|
461
496
|
) => {
|
462
497
|
if (cache) {
|
463
498
|
D(module, "unsafeCache", module => {
|
@@ -475,7 +510,10 @@ const applyModuleDefaults = (
|
|
475
510
|
}
|
476
511
|
|
477
512
|
F(module.parser, "javascript", () => ({}));
|
478
|
-
applyJavascriptParserOptionsDefaults(module.parser.javascript
|
513
|
+
applyJavascriptParserOptionsDefaults(module.parser.javascript, {
|
514
|
+
futureDefaults,
|
515
|
+
isNode
|
516
|
+
});
|
479
517
|
|
480
518
|
A(module, "defaultRules", () => {
|
481
519
|
const esm = {
|
@@ -579,6 +617,41 @@ const applyModuleDefaults = (
|
|
579
617
|
...wasm
|
580
618
|
});
|
581
619
|
}
|
620
|
+
if (css) {
|
621
|
+
const cssRule = {
|
622
|
+
type: "css",
|
623
|
+
resolve: {
|
624
|
+
fullySpecified: true,
|
625
|
+
preferRelative: true
|
626
|
+
}
|
627
|
+
};
|
628
|
+
const cssModulesRule = {
|
629
|
+
type: "css/module",
|
630
|
+
resolve: {
|
631
|
+
fullySpecified: true
|
632
|
+
}
|
633
|
+
};
|
634
|
+
rules.push({
|
635
|
+
test: /\.css$/i,
|
636
|
+
oneOf: [
|
637
|
+
{
|
638
|
+
test: /\.module\.css$/i,
|
639
|
+
...cssModulesRule
|
640
|
+
},
|
641
|
+
{
|
642
|
+
...cssRule
|
643
|
+
}
|
644
|
+
]
|
645
|
+
});
|
646
|
+
rules.push({
|
647
|
+
mimetype: "text/css+module",
|
648
|
+
...cssModulesRule
|
649
|
+
});
|
650
|
+
rules.push({
|
651
|
+
mimetype: "text/css",
|
652
|
+
...cssRule
|
653
|
+
});
|
654
|
+
}
|
582
655
|
rules.push(
|
583
656
|
{
|
584
657
|
dependency: "url",
|
@@ -650,7 +723,15 @@ const applyOutputDefaults = (
|
|
650
723
|
};
|
651
724
|
|
652
725
|
F(output, "uniqueName", () => {
|
653
|
-
const libraryName = getLibraryName(output.library)
|
726
|
+
const libraryName = getLibraryName(output.library).replace(
|
727
|
+
/^\[(\\*[\w:]+\\*)\](\.)|(\.)\[(\\*[\w:]+\\*)\](?=\.|$)|\[(\\*[\w:]+\\*)\]/g,
|
728
|
+
(m, a, d1, d2, b, c) => {
|
729
|
+
const content = a || b || c;
|
730
|
+
return content.startsWith("\\") && content.endsWith("\\")
|
731
|
+
? `${d2 || ""}[${content.slice(1, -1)}]${d1 || ""}`
|
732
|
+
: "";
|
733
|
+
}
|
734
|
+
);
|
654
735
|
if (libraryName) return libraryName;
|
655
736
|
const pkgPath = path.resolve(context, "package.json");
|
656
737
|
try {
|
@@ -684,6 +765,20 @@ const applyOutputDefaults = (
|
|
684
765
|
}
|
685
766
|
return output.module ? "[id].mjs" : "[id].js";
|
686
767
|
});
|
768
|
+
F(output, "cssFilename", () => {
|
769
|
+
const filename = output.filename;
|
770
|
+
if (typeof filename !== "function") {
|
771
|
+
return filename.replace(/\.[mc]?js(\?|$)/, ".css$1");
|
772
|
+
}
|
773
|
+
return "[id].css";
|
774
|
+
});
|
775
|
+
F(output, "cssChunkFilename", () => {
|
776
|
+
const chunkFilename = output.chunkFilename;
|
777
|
+
if (typeof chunkFilename !== "function") {
|
778
|
+
return chunkFilename.replace(/\.[mc]?js(\?|$)/, ".css$1");
|
779
|
+
}
|
780
|
+
return "[id].css";
|
781
|
+
});
|
687
782
|
D(output, "assetModuleFilename", "[hash][ext][query]");
|
688
783
|
D(output, "webassemblyModuleFilename", "[hash].module.wasm");
|
689
784
|
D(output, "compareBeforeEmit", true);
|
@@ -736,6 +831,7 @@ const applyOutputDefaults = (
|
|
736
831
|
"Chunk format can't be selected by default when no target is specified"
|
737
832
|
);
|
738
833
|
});
|
834
|
+
D(output, "asyncChunks", true);
|
739
835
|
F(output, "chunkLoading", () => {
|
740
836
|
if (tp) {
|
741
837
|
switch (output.chunkFormat) {
|
@@ -823,10 +919,11 @@ const applyOutputDefaults = (
|
|
823
919
|
D(output, "chunkLoadTimeout", 120000);
|
824
920
|
D(output, "hashFunction", futureDefaults ? "xxhash64" : "md4");
|
825
921
|
D(output, "hashDigest", "hex");
|
826
|
-
D(output, "hashDigestLength", 20);
|
922
|
+
D(output, "hashDigestLength", futureDefaults ? 16 : 20);
|
827
923
|
D(output, "strictModuleExceptionHandling", false);
|
828
924
|
|
829
925
|
const optimistic = v => v || v === undefined;
|
926
|
+
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
|
830
927
|
F(
|
831
928
|
output.environment,
|
832
929
|
"arrowFunction",
|
@@ -840,8 +937,12 @@ const applyOutputDefaults = (
|
|
840
937
|
);
|
841
938
|
F(output.environment, "forOf", () => tp && optimistic(tp.forOf));
|
842
939
|
F(output.environment, "bigIntLiteral", () => tp && tp.bigIntLiteral);
|
843
|
-
F(output.environment, "dynamicImport", () =>
|
844
|
-
|
940
|
+
F(output.environment, "dynamicImport", () =>
|
941
|
+
conditionallyOptimistic(tp && tp.dynamicImport, output.module)
|
942
|
+
);
|
943
|
+
F(output.environment, "module", () =>
|
944
|
+
conditionallyOptimistic(tp && tp.module, output.module)
|
945
|
+
);
|
845
946
|
|
846
947
|
const { trustedTypes } = output;
|
847
948
|
if (trustedTypes) {
|
@@ -1021,12 +1122,13 @@ const applyPerformanceDefaults = (performance, { production }) => {
|
|
1021
1122
|
* @param {Object} options options
|
1022
1123
|
* @param {boolean} options.production is production
|
1023
1124
|
* @param {boolean} options.development is development
|
1125
|
+
* @param {CssExperimentOptions|false} options.css is css enabled
|
1024
1126
|
* @param {boolean} options.records using records
|
1025
1127
|
* @returns {void}
|
1026
1128
|
*/
|
1027
1129
|
const applyOptimizationDefaults = (
|
1028
1130
|
optimization,
|
1029
|
-
{ production, development, records }
|
1131
|
+
{ production, development, css, records }
|
1030
1132
|
) => {
|
1031
1133
|
D(optimization, "removeAvailableModules", false);
|
1032
1134
|
D(optimization, "removeEmptyChunks", true);
|
@@ -1077,7 +1179,9 @@ const applyOptimizationDefaults = (
|
|
1077
1179
|
});
|
1078
1180
|
const { splitChunks } = optimization;
|
1079
1181
|
if (splitChunks) {
|
1080
|
-
A(splitChunks, "defaultSizeTypes", () =>
|
1182
|
+
A(splitChunks, "defaultSizeTypes", () =>
|
1183
|
+
css ? ["javascript", "css", "unknown"] : ["javascript", "unknown"]
|
1184
|
+
);
|
1081
1185
|
D(splitChunks, "hidePathInfo", production);
|
1082
1186
|
D(splitChunks, "chunks", "async");
|
1083
1187
|
D(splitChunks, "usedExports", optimization.usedExports === true);
|
@@ -178,8 +178,10 @@ const getNormalizedWebpackOptions = config => {
|
|
178
178
|
),
|
179
179
|
lazyCompilation: optionalNestedConfig(
|
180
180
|
experiments.lazyCompilation,
|
181
|
-
options =>
|
182
|
-
|
181
|
+
options => (options === true ? {} : options)
|
182
|
+
),
|
183
|
+
css: optionalNestedConfig(experiments.css, options =>
|
184
|
+
options === true ? {} : options
|
183
185
|
)
|
184
186
|
})),
|
185
187
|
externals: config.externals,
|
@@ -229,6 +231,7 @@ const getNormalizedWebpackOptions = config => {
|
|
229
231
|
wrappedContextRegExp: module.wrappedContextRegExp,
|
230
232
|
wrappedContextRecursive: module.wrappedContextRecursive,
|
231
233
|
wrappedContextCritical: module.wrappedContextCritical,
|
234
|
+
// TODO webpack 6 remove
|
232
235
|
strictExportPresence: module.strictExportPresence,
|
233
236
|
strictThisContextOnImports: module.strictThisContextOnImports,
|
234
237
|
...parserOptions
|
@@ -289,12 +292,15 @@ const getNormalizedWebpackOptions = config => {
|
|
289
292
|
/** @type {OutputNormalized} */
|
290
293
|
const result = {
|
291
294
|
assetModuleFilename: output.assetModuleFilename,
|
295
|
+
asyncChunks: output.asyncChunks,
|
292
296
|
charset: output.charset,
|
293
297
|
chunkFilename: output.chunkFilename,
|
294
298
|
chunkFormat: output.chunkFormat,
|
295
299
|
chunkLoading: output.chunkLoading,
|
296
300
|
chunkLoadingGlobal: output.chunkLoadingGlobal,
|
297
301
|
chunkLoadTimeout: output.chunkLoadTimeout,
|
302
|
+
cssFilename: output.cssFilename,
|
303
|
+
cssChunkFilename: output.cssChunkFilename,
|
298
304
|
clean: output.clean,
|
299
305
|
compareBeforeEmit: output.compareBeforeEmit,
|
300
306
|
crossOriginLoading: output.crossOriginLoading,
|
@@ -481,8 +487,10 @@ const getNormalizedEntryStatic = entry => {
|
|
481
487
|
filename: value.filename,
|
482
488
|
layer: value.layer,
|
483
489
|
runtime: value.runtime,
|
490
|
+
baseUri: value.baseUri,
|
484
491
|
publicPath: value.publicPath,
|
485
492
|
chunkLoading: value.chunkLoading,
|
493
|
+
asyncChunks: value.asyncChunks,
|
486
494
|
wasmLoading: value.wasmLoading,
|
487
495
|
dependOn:
|
488
496
|
value.dependOn &&
|
package/lib/config/target.js
CHANGED
@@ -59,6 +59,8 @@ const getDefaultTarget = context => {
|
|
59
59
|
* @property {boolean | null} dynamicImport async import() is available
|
60
60
|
* @property {boolean | null} dynamicImportInWorker async import() is available when creating a worker
|
61
61
|
* @property {boolean | null} module ESM syntax is available (when in module)
|
62
|
+
* @property {boolean | null} optionalChaining optional chaining is available
|
63
|
+
* @property {boolean | null} templateLiteral template literal is available
|
62
64
|
*/
|
63
65
|
|
64
66
|
///** @typedef {PlatformTargetProperties | ApiTargetProperties | EcmaTargetProperties | PlatformTargetProperties & ApiTargetProperties | PlatformTargetProperties & EcmaTargetProperties | ApiTargetProperties & EcmaTargetProperties} TargetProperties */
|
@@ -167,6 +169,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
167
169
|
|
168
170
|
globalThis: v(12),
|
169
171
|
const: v(6),
|
172
|
+
templateLiteral: v(4),
|
173
|
+
optionalChaining: v(14),
|
170
174
|
arrowFunction: v(6),
|
171
175
|
forOf: v(5),
|
172
176
|
destructuring: v(6),
|
@@ -206,6 +210,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
206
210
|
|
207
211
|
globalThis: v(5),
|
208
212
|
const: v(1, 1),
|
213
|
+
templateLiteral: v(1, 1),
|
214
|
+
optionalChaining: v(8),
|
209
215
|
arrowFunction: v(1, 1),
|
210
216
|
forOf: v(0, 36),
|
211
217
|
destructuring: v(1, 1),
|
@@ -241,6 +247,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
241
247
|
|
242
248
|
globalThis: v(0, 43),
|
243
249
|
const: v(0, 15),
|
250
|
+
templateLiteral: v(0, 13),
|
251
|
+
optionalChaining: v(0, 44),
|
244
252
|
arrowFunction: v(0, 15),
|
245
253
|
forOf: v(0, 13),
|
246
254
|
destructuring: v(0, 15),
|
@@ -260,6 +268,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
260
268
|
if (v < 1000) v = v + 2009;
|
261
269
|
return {
|
262
270
|
const: v >= 2015,
|
271
|
+
templateLiteral: v >= 2015,
|
272
|
+
optionalChaining: v >= 2020,
|
263
273
|
arrowFunction: v >= 2015,
|
264
274
|
forOf: v >= 2015,
|
265
275
|
destructuring: v >= 2015,
|
@@ -10,6 +10,7 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
10
10
|
const Module = require("../Module");
|
11
11
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
12
12
|
const Template = require("../Template");
|
13
|
+
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
13
14
|
const makeSerializable = require("../util/makeSerializable");
|
14
15
|
const ContainerExposedDependency = require("./ContainerExposedDependency");
|
15
16
|
|
@@ -78,12 +79,14 @@ class ContainerEntryModule extends Module {
|
|
78
79
|
* @returns {string | null} an identifier for library inclusion
|
79
80
|
*/
|
80
81
|
libIdent(options) {
|
81
|
-
return `webpack/container/entry/${
|
82
|
+
return `${this.layer ? `(${this.layer})/` : ""}webpack/container/entry/${
|
83
|
+
this._name
|
84
|
+
}`;
|
82
85
|
}
|
83
86
|
|
84
87
|
/**
|
85
88
|
* @param {NeedBuildContext} context context info
|
86
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
89
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
87
90
|
* @returns {void}
|
88
91
|
*/
|
89
92
|
needBuild(context, callback) {
|
@@ -104,6 +107,7 @@ class ContainerEntryModule extends Module {
|
|
104
107
|
strict: true,
|
105
108
|
topLevelDeclarations: new Set(["moduleMap", "get", "init"])
|
106
109
|
};
|
110
|
+
this.buildMeta.exportsType = "namespace";
|
107
111
|
|
108
112
|
this.clearDependenciesAndBlocks();
|
109
113
|
|
@@ -127,6 +131,7 @@ class ContainerEntryModule extends Module {
|
|
127
131
|
}
|
128
132
|
this.addBlock(block);
|
129
133
|
}
|
134
|
+
this.addDependency(new StaticExportsDependency(["get", "init"], false));
|
130
135
|
|
131
136
|
callback();
|
132
137
|
}
|
@@ -217,10 +222,8 @@ class ContainerEntryModule extends Module {
|
|
217
222
|
])};`,
|
218
223
|
`var init = ${runtimeTemplate.basicFunction("shareScope, initScope", [
|
219
224
|
`if (!${RuntimeGlobals.shareScopeMap}) return;`,
|
220
|
-
`var oldScope = ${RuntimeGlobals.shareScopeMap}[${JSON.stringify(
|
221
|
-
this._shareScope
|
222
|
-
)}];`,
|
223
225
|
`var name = ${JSON.stringify(this._shareScope)}`,
|
226
|
+
`var oldScope = ${RuntimeGlobals.shareScopeMap}[name];`,
|
224
227
|
`if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope");`,
|
225
228
|
`${RuntimeGlobals.shareScopeMap}[name] = shareScope;`,
|
226
229
|
`return ${RuntimeGlobals.initializeSharing}(name, initScope);`
|
@@ -60,9 +60,9 @@ class FallbackModule extends Module {
|
|
60
60
|
* @returns {string | null} an identifier for library inclusion
|
61
61
|
*/
|
62
62
|
libIdent(options) {
|
63
|
-
return `webpack/container/fallback/${
|
64
|
-
this.requests
|
65
|
-
} more`;
|
63
|
+
return `${this.layer ? `(${this.layer})/` : ""}webpack/container/fallback/${
|
64
|
+
this.requests[0]
|
65
|
+
}/and ${this.requests.length - 1} more`;
|
66
66
|
}
|
67
67
|
|
68
68
|
/**
|
@@ -76,7 +76,7 @@ class FallbackModule extends Module {
|
|
76
76
|
|
77
77
|
/**
|
78
78
|
* @param {NeedBuildContext} context context info
|
79
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
79
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
80
80
|
* @returns {void}
|
81
81
|
*/
|
82
82
|
needBuild(context, callback) {
|
@@ -65,6 +65,7 @@ class ModuleFederationPlugin {
|
|
65
65
|
library,
|
66
66
|
filename: options.filename,
|
67
67
|
runtime: options.runtime,
|
68
|
+
shareScope: options.shareScope,
|
68
69
|
exposes: options.exposes
|
69
70
|
}).apply(compiler);
|
70
71
|
}
|
@@ -76,6 +77,7 @@ class ModuleFederationPlugin {
|
|
76
77
|
) {
|
77
78
|
new ContainerReferencePlugin({
|
78
79
|
remoteType,
|
80
|
+
shareScope: options.shareScope,
|
79
81
|
remotes: options.remotes
|
80
82
|
}).apply(compiler);
|
81
83
|
}
|
@@ -67,12 +67,14 @@ class RemoteModule extends Module {
|
|
67
67
|
* @returns {string | null} an identifier for library inclusion
|
68
68
|
*/
|
69
69
|
libIdent(options) {
|
70
|
-
return `webpack/container/remote/${
|
70
|
+
return `${this.layer ? `(${this.layer})/` : ""}webpack/container/remote/${
|
71
|
+
this.request
|
72
|
+
}`;
|
71
73
|
}
|
72
74
|
|
73
75
|
/**
|
74
76
|
* @param {NeedBuildContext} context context info
|
75
|
-
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
77
|
+
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
|
76
78
|
* @returns {void}
|
77
79
|
*/
|
78
80
|
needBuild(context, callback) {
|
@@ -73,9 +73,9 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
73
73
|
Template.indent(
|
74
74
|
`error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2];`
|
75
75
|
),
|
76
|
-
|
77
|
-
|
78
|
-
])}`,
|
76
|
+
`${
|
77
|
+
RuntimeGlobals.moduleFactories
|
78
|
+
}[id] = ${runtimeTemplate.basicFunction("", ["throw error;"])}`,
|
79
79
|
"data.p = 0;"
|
80
80
|
])};`,
|
81
81
|
`var handleFunction = ${runtimeTemplate.basicFunction(
|
@@ -111,10 +111,11 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|
111
111
|
)};`,
|
112
112
|
`var onFactory = ${runtimeTemplate.basicFunction("factory", [
|
113
113
|
"data.p = 1;",
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
114
|
+
`${
|
115
|
+
RuntimeGlobals.moduleFactories
|
116
|
+
}[id] = ${runtimeTemplate.basicFunction("module", [
|
117
|
+
"module.exports = factory();"
|
118
|
+
])}`
|
118
119
|
])};`,
|
119
120
|
"handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1);"
|
120
121
|
])});`
|
@@ -0,0 +1,139 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Sergey Melyukov @smelukov
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const { ReplaceSource, RawSource, ConcatSource } = require("webpack-sources");
|
9
|
+
const { UsageState } = require("../ExportsInfo");
|
10
|
+
const Generator = require("../Generator");
|
11
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
12
|
+
const Template = require("../Template");
|
13
|
+
|
14
|
+
/** @typedef {import("webpack-sources").Source} Source */
|
15
|
+
/** @typedef {import("../Dependency")} Dependency */
|
16
|
+
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
17
|
+
/** @typedef {import("../Generator").UpdateHashContext} UpdateHashContext */
|
18
|
+
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
19
|
+
/** @typedef {import("../NormalModule")} NormalModule */
|
20
|
+
/** @typedef {import("../util/Hash")} Hash */
|
21
|
+
|
22
|
+
const TYPES = new Set(["javascript"]);
|
23
|
+
|
24
|
+
class CssExportsGenerator extends Generator {
|
25
|
+
constructor() {
|
26
|
+
super();
|
27
|
+
}
|
28
|
+
|
29
|
+
// TODO add getConcatenationBailoutReason to allow concatenation
|
30
|
+
// but how to make it have a module id
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @param {NormalModule} module module for which the code should be generated
|
34
|
+
* @param {GenerateContext} generateContext context for generate
|
35
|
+
* @returns {Source} generated code
|
36
|
+
*/
|
37
|
+
generate(module, generateContext) {
|
38
|
+
const source = new ReplaceSource(new RawSource(""));
|
39
|
+
const initFragments = [];
|
40
|
+
const cssExports = new Map();
|
41
|
+
|
42
|
+
generateContext.runtimeRequirements.add(RuntimeGlobals.module);
|
43
|
+
|
44
|
+
const runtimeRequirements = new Set();
|
45
|
+
|
46
|
+
const templateContext = {
|
47
|
+
runtimeTemplate: generateContext.runtimeTemplate,
|
48
|
+
dependencyTemplates: generateContext.dependencyTemplates,
|
49
|
+
moduleGraph: generateContext.moduleGraph,
|
50
|
+
chunkGraph: generateContext.chunkGraph,
|
51
|
+
module,
|
52
|
+
runtime: generateContext.runtime,
|
53
|
+
runtimeRequirements: runtimeRequirements,
|
54
|
+
concatenationScope: generateContext.concatenationScope,
|
55
|
+
codeGenerationResults: generateContext.codeGenerationResults,
|
56
|
+
initFragments,
|
57
|
+
cssExports
|
58
|
+
};
|
59
|
+
|
60
|
+
const handleDependency = dependency => {
|
61
|
+
const constructor = /** @type {new (...args: any[]) => Dependency} */ (
|
62
|
+
dependency.constructor
|
63
|
+
);
|
64
|
+
const template = generateContext.dependencyTemplates.get(constructor);
|
65
|
+
if (!template) {
|
66
|
+
throw new Error(
|
67
|
+
"No template for dependency: " + dependency.constructor.name
|
68
|
+
);
|
69
|
+
}
|
70
|
+
|
71
|
+
template.apply(dependency, source, templateContext);
|
72
|
+
};
|
73
|
+
module.dependencies.forEach(handleDependency);
|
74
|
+
|
75
|
+
if (generateContext.concatenationScope) {
|
76
|
+
const source = new ConcatSource();
|
77
|
+
const usedIdentifiers = new Set();
|
78
|
+
for (const [k, v] of cssExports) {
|
79
|
+
let identifier = Template.toIdentifier(k);
|
80
|
+
let i = 0;
|
81
|
+
while (usedIdentifiers.has(identifier)) {
|
82
|
+
identifier = Template.toIdentifier(k + i);
|
83
|
+
}
|
84
|
+
usedIdentifiers.add(identifier);
|
85
|
+
generateContext.concatenationScope.registerExport(k, identifier);
|
86
|
+
source.add(
|
87
|
+
`${
|
88
|
+
generateContext.runtimeTemplate.supportsConst ? "const" : "var"
|
89
|
+
} ${identifier} = ${JSON.stringify(v)};\n`
|
90
|
+
);
|
91
|
+
}
|
92
|
+
return source;
|
93
|
+
} else {
|
94
|
+
const otherUsed =
|
95
|
+
generateContext.moduleGraph
|
96
|
+
.getExportsInfo(module)
|
97
|
+
.otherExportsInfo.getUsed(generateContext.runtime) !==
|
98
|
+
UsageState.Unused;
|
99
|
+
if (otherUsed) {
|
100
|
+
generateContext.runtimeRequirements.add(
|
101
|
+
RuntimeGlobals.makeNamespaceObject
|
102
|
+
);
|
103
|
+
}
|
104
|
+
return new RawSource(
|
105
|
+
`${otherUsed ? `${RuntimeGlobals.makeNamespaceObject}(` : ""}${
|
106
|
+
module.moduleArgument
|
107
|
+
}.exports = {\n${Array.from(
|
108
|
+
cssExports,
|
109
|
+
([k, v]) => `\t${JSON.stringify(k)}: ${JSON.stringify(v)}`
|
110
|
+
).join(",\n")}\n}${otherUsed ? ")" : ""};`
|
111
|
+
);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* @param {NormalModule} module fresh module
|
117
|
+
* @returns {Set<string>} available types (do not mutate)
|
118
|
+
*/
|
119
|
+
getTypes(module) {
|
120
|
+
return TYPES;
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
* @param {NormalModule} module the module
|
125
|
+
* @param {string=} type source type
|
126
|
+
* @returns {number} estimate size of the module
|
127
|
+
*/
|
128
|
+
getSize(module, type) {
|
129
|
+
return 42;
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* @param {Hash} hash hash that will be modified
|
134
|
+
* @param {UpdateHashContext} updateHashContext context for updating hash
|
135
|
+
*/
|
136
|
+
updateHash(hash, { module }) {}
|
137
|
+
}
|
138
|
+
|
139
|
+
module.exports = CssExportsGenerator;
|