webpack 5.106.2 → 5.107.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.
- package/README.md +2 -2
- package/lib/APIPlugin.js +1 -1
- package/lib/Cache.js +3 -6
- package/lib/CompatibilityPlugin.js +8 -7
- package/lib/Compilation.js +34 -26
- package/lib/Compiler.js +4 -13
- package/lib/ContextModule.js +2 -2
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +22 -1
- package/lib/DependencyTemplate.js +2 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +8 -9
- package/lib/ExternalModule.js +76 -15
- package/lib/ExternalModuleFactoryPlugin.js +5 -0
- package/lib/FileSystemInfo.js +187 -72
- package/lib/Generator.js +3 -3
- package/lib/HotModuleReplacementPlugin.js +26 -8
- package/lib/IgnorePlugin.js +2 -1
- package/lib/Module.js +19 -18
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleSourceTypeConstants.js +31 -1
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +2 -2
- package/lib/NodeStuffPlugin.js +1 -1
- package/lib/NormalModule.js +13 -31
- package/lib/NormalModuleFactory.js +10 -2
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +129 -56
- package/lib/RuntimeGlobals.js +5 -5
- package/lib/RuntimeModule.js +9 -7
- package/lib/RuntimePlugin.js +11 -0
- package/lib/WarnCaseSensitiveModulesPlugin.js +70 -2
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +16 -1
- package/lib/Watching.js +2 -3
- package/lib/WebpackError.js +3 -77
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +13 -1
- package/lib/asset/AssetBytesGenerator.js +6 -2
- package/lib/asset/AssetGenerator.js +22 -8
- package/lib/asset/AssetModulesPlugin.js +3 -1
- package/lib/asset/AssetSourceGenerator.js +6 -2
- package/lib/buildChunkGraph.js +4 -6
- package/lib/cache/PackFileCacheStrategy.js +4 -4
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +197 -10
- package/lib/config/normalization.js +3 -1
- package/lib/css/CssGenerator.js +320 -105
- package/lib/css/CssInjectStyleRuntimeModule.js +44 -42
- package/lib/css/CssLoadingRuntimeModule.js +22 -4
- package/lib/{CssModule.js → css/CssModule.js} +15 -15
- package/lib/css/CssModulesPlugin.js +166 -86
- package/lib/css/CssParser.js +566 -269
- package/lib/css/walkCssTokens.js +148 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +63 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +54 -10
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +32 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +4 -3
- package/lib/dependencies/CommonJsRequireDependency.js +67 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -1
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +332 -67
- package/lib/dependencies/CssIcssImportDependency.js +49 -7
- package/lib/dependencies/CssIcssSymbolDependency.js +11 -3
- package/lib/dependencies/CssImportDependency.js +8 -0
- package/lib/dependencies/CssUrlDependency.js +25 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +22 -14
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +110 -3
- package/lib/dependencies/HarmonyImportDependency.js +10 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +22 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +318 -0
- package/lib/dependencies/HtmlSourceDependency.js +127 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +2 -2
- package/lib/dependencies/ImportPhase.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +1 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +7 -7
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +31 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +4 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +2 -2
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +4 -4
- package/lib/{DllModule.js → dll/DllModule.js} +24 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +4 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +6 -5
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +14 -14
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +9 -9
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +2 -2
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +3 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +5 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +4 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +3 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +5 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +4 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +5 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/{ModuleNotFoundError.js → errors/ModuleNotFoundError.js} +2 -2
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +8 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +1 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +1 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +5 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +4 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +2 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +3 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +433 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +2733 -0
- package/lib/ids/IdHelpers.js +2 -1
- package/lib/index.js +34 -15
- package/lib/javascript/JavascriptModulesPlugin.js +89 -8
- package/lib/javascript/JavascriptParser.js +197 -16
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/json/JsonParser.js +7 -16
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/EnableLibraryPlugin.js +1 -1
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/ModuleLibraryPlugin.js +74 -0
- package/lib/node/NodeEnvironmentPlugin.js +4 -2
- package/lib/node/nodeConsole.js +113 -64
- package/lib/optimize/ConcatenatedModule.js +51 -6
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -1
- package/lib/optimize/MinMaxSizeWarning.js +4 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +15 -7
- package/lib/optimize/RealContentHashPlugin.js +89 -26
- package/lib/optimize/SideEffectsFlagPlugin.js +111 -3
- package/lib/optimize/SplitChunksPlugin.js +1 -1
- package/lib/performance/AssetsOverSizeLimitWarning.js +2 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -1
- package/lib/rules/UseEffectRulePlugin.js +4 -3
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +119 -13
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/schemes/DataUriPlugin.js +13 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +2 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +1 -1
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +2 -2
- package/lib/util/AsyncQueue.js +2 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/SortableSet.js +1 -1
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +3 -3
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +42 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +2 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +3 -1
- package/lib/util/fs.js +8 -8
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +48 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -7
- package/lib/util/parseJson.js +2 -73
- package/lib/util/source.js +21 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +5 -3
- package/lib/webpack.js +3 -1
- package/package.json +22 -20
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +118 -3
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +810 -101
- package/lib/CaseSensitiveModulesWarning.js +0 -80
- package/lib/GraphHelpers.js +0 -49
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -57
- /package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +0 -0
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
const WebpackError = require("./WebpackError");
|
|
9
|
-
|
|
10
|
-
/** @typedef {import("./Module")} Module */
|
|
11
|
-
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Sorts the conflicting modules by identifier to keep warning output stable.
|
|
15
|
-
* @param {Module[]} modules the modules to be sorted
|
|
16
|
-
* @returns {Module[]} sorted version of original modules
|
|
17
|
-
*/
|
|
18
|
-
const sortModules = (modules) =>
|
|
19
|
-
modules.sort((a, b) => {
|
|
20
|
-
const aIdent = a.identifier();
|
|
21
|
-
const bIdent = b.identifier();
|
|
22
|
-
/* istanbul ignore next */
|
|
23
|
-
if (aIdent < bIdent) return -1;
|
|
24
|
-
/* istanbul ignore next */
|
|
25
|
-
if (aIdent > bIdent) return 1;
|
|
26
|
-
/* istanbul ignore next */
|
|
27
|
-
return 0;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Formats the conflicting modules and one representative incoming reason for
|
|
32
|
-
* each module into the warning body.
|
|
33
|
-
* @param {Module[]} modules each module from throw
|
|
34
|
-
* @param {ModuleGraph} moduleGraph the module graph
|
|
35
|
-
* @returns {string} each message from provided modules
|
|
36
|
-
*/
|
|
37
|
-
const createModulesListMessage = (modules, moduleGraph) =>
|
|
38
|
-
modules
|
|
39
|
-
.map((m) => {
|
|
40
|
-
let message = `* ${m.identifier()}`;
|
|
41
|
-
const validReasons = [
|
|
42
|
-
...moduleGraph.getIncomingConnectionsByOriginModule(m).keys()
|
|
43
|
-
].filter(Boolean);
|
|
44
|
-
|
|
45
|
-
if (validReasons.length > 0) {
|
|
46
|
-
message += `\n Used by ${validReasons.length} module(s), i. e.`;
|
|
47
|
-
message += `\n ${
|
|
48
|
-
/** @type {Module[]} */ (validReasons)[0].identifier()
|
|
49
|
-
}`;
|
|
50
|
-
}
|
|
51
|
-
return message;
|
|
52
|
-
})
|
|
53
|
-
.join("\n");
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Warning emitted when webpack finds modules whose identifiers differ only by
|
|
57
|
-
* letter casing, which can behave inconsistently across filesystems.
|
|
58
|
-
*/
|
|
59
|
-
class CaseSensitiveModulesWarning extends WebpackError {
|
|
60
|
-
/**
|
|
61
|
-
* Builds a warning message that lists the case-conflicting modules and
|
|
62
|
-
* representative importers that caused them to be included.
|
|
63
|
-
* @param {Iterable<Module>} modules modules that were detected
|
|
64
|
-
* @param {ModuleGraph} moduleGraph the module graph
|
|
65
|
-
*/
|
|
66
|
-
constructor(modules, moduleGraph) {
|
|
67
|
-
const sortedModules = sortModules([...modules]);
|
|
68
|
-
const modulesList = createModulesListMessage(sortedModules, moduleGraph);
|
|
69
|
-
super(`There are multiple modules with names that only differ in casing.
|
|
70
|
-
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
|
|
71
|
-
Use equal casing. Compare these module identifiers:
|
|
72
|
-
${modulesList}`);
|
|
73
|
-
|
|
74
|
-
/** @type {string} */
|
|
75
|
-
this.name = "CaseSensitiveModulesWarning";
|
|
76
|
-
this.module = sortedModules[0];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = CaseSensitiveModulesWarning;
|
package/lib/GraphHelpers.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
/** @typedef {import("./Chunk")} Chunk */
|
|
9
|
-
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
10
|
-
/** @typedef {import(".").Entrypoint} Entrypoint */
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Connects chunk group and chunk.
|
|
14
|
-
* @param {ChunkGroup} chunkGroup the ChunkGroup to connect
|
|
15
|
-
* @param {Chunk} chunk chunk to tie to ChunkGroup
|
|
16
|
-
* @returns {void}
|
|
17
|
-
*/
|
|
18
|
-
const connectChunkGroupAndChunk = (chunkGroup, chunk) => {
|
|
19
|
-
if (chunkGroup.pushChunk(chunk)) {
|
|
20
|
-
chunk.addGroup(chunkGroup);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Connects chunk group parent and child.
|
|
26
|
-
* @param {ChunkGroup} parent parent ChunkGroup to connect
|
|
27
|
-
* @param {ChunkGroup} child child ChunkGroup to connect
|
|
28
|
-
* @returns {void}
|
|
29
|
-
*/
|
|
30
|
-
const connectChunkGroupParentAndChild = (parent, child) => {
|
|
31
|
-
if (parent.addChild(child)) {
|
|
32
|
-
child.addParent(parent);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Connects entrypoint and depend on.
|
|
38
|
-
* @param {Entrypoint} entrypoint the entrypoint
|
|
39
|
-
* @param {Entrypoint} dependOnEntrypoint the dependOnEntrypoint
|
|
40
|
-
* @returns {void}
|
|
41
|
-
*/
|
|
42
|
-
const connectEntrypointAndDependOn = (entrypoint, dependOnEntrypoint) => {
|
|
43
|
-
entrypoint.addDependOn(dependOnEntrypoint);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
module.exports.connectChunkGroupAndChunk = connectChunkGroupAndChunk;
|
|
47
|
-
module.exports.connectChunkGroupParentAndChild =
|
|
48
|
-
connectChunkGroupParentAndChild;
|
|
49
|
-
module.exports.connectEntrypointAndDependOn = connectEntrypointAndDependOn;
|
package/lib/NoModeWarning.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
const WebpackError = require("./WebpackError");
|
|
9
|
-
|
|
10
|
-
module.exports = class NoModeWarning extends WebpackError {
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
|
|
14
|
-
/** @type {string} */
|
|
15
|
-
this.name = "NoModeWarning";
|
|
16
|
-
this.message =
|
|
17
|
-
"configuration\n" +
|
|
18
|
-
"The 'mode' option has not been set, webpack will fallback to 'production' for this value.\n" +
|
|
19
|
-
"Set 'mode' option to 'development' or 'production' to enable defaults for each environment.\n" +
|
|
20
|
-
"You can also set it to 'none' to disable any default behavior. " +
|
|
21
|
-
"Learn more: https://webpack.js.org/configuration/mode/";
|
|
22
|
-
}
|
|
23
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Natsu @xiaoxiaojx
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
|
-
const RuntimeModule = require("../RuntimeModule");
|
|
10
|
-
const Template = require("../Template");
|
|
11
|
-
|
|
12
|
-
/** @typedef {import("../Chunk")} Chunk */
|
|
13
|
-
|
|
14
|
-
class CssMergeStyleSheetsRuntimeModule extends RuntimeModule {
|
|
15
|
-
constructor() {
|
|
16
|
-
super("css merge stylesheets");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Generates runtime code for this runtime module.
|
|
21
|
-
* @returns {string | null} runtime code
|
|
22
|
-
*/
|
|
23
|
-
generate() {
|
|
24
|
-
const { runtimeTemplate } = /** @type {import("../Compilation")} */ (
|
|
25
|
-
this.compilation
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
return Template.asString([
|
|
29
|
-
`${RuntimeGlobals.cssMergeStyleSheets} = ${runtimeTemplate.basicFunction(
|
|
30
|
-
"sheets",
|
|
31
|
-
[
|
|
32
|
-
"var sheetsArray = Array.isArray(sheets) ? sheets : [sheets];",
|
|
33
|
-
"var cssTexts = [];",
|
|
34
|
-
"for (var i = 0; i < sheetsArray.length; i++) {",
|
|
35
|
-
Template.indent([
|
|
36
|
-
"var s = sheetsArray[i];",
|
|
37
|
-
"if (!s) continue;",
|
|
38
|
-
"if (typeof s === 'string') {",
|
|
39
|
-
Template.indent("cssTexts.push(s);"),
|
|
40
|
-
"} else if (s.cssRules) {",
|
|
41
|
-
Template.indent([
|
|
42
|
-
"var rules = s.cssRules;",
|
|
43
|
-
"for (var j = 0; j < rules.length; j++) {",
|
|
44
|
-
Template.indent("cssTexts.push(rules[j].cssText);"),
|
|
45
|
-
"}"
|
|
46
|
-
]),
|
|
47
|
-
"}"
|
|
48
|
-
]),
|
|
49
|
-
"}",
|
|
50
|
-
"return cssTexts.join('');"
|
|
51
|
-
]
|
|
52
|
-
)};`
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = CssMergeStyleSheetsRuntimeModule;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|