@rspack/core 1.0.10 → 1.0.11
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/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
- package/dist/config/types.d.ts +309 -0
- package/dist/config/zod.d.ts +22 -534
- package/dist/cssExtractHmr.js +224 -0
- package/dist/cssExtractLoader.js +277 -0
- package/dist/index.js +23347 -31
- package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
- package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
- package/dist/stats/statsFactoryUtils.d.ts +1 -0
- package/package.json +8 -5
- package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
- package/compiled/json-parse-even-better-errors/index.js +0 -193
- package/compiled/json-parse-even-better-errors/package.json +0 -1
- package/compiled/neo-async/index.d.ts +0 -685
- package/compiled/neo-async/index.js +0 -9207
- package/compiled/neo-async/license +0 -22
- package/compiled/neo-async/package.json +0 -1
- package/compiled/zod-validation-error/index.d.ts +0 -41
- package/compiled/zod-validation-error/index.js +0 -335
- package/compiled/zod-validation-error/license +0 -9
- package/compiled/zod-validation-error/package.json +0 -1
- package/dist/Chunk.js +0 -118
- package/dist/ChunkGraph.js +0 -27
- package/dist/ChunkGroup.js +0 -76
- package/dist/Compilation.js +0 -854
- package/dist/Compiler.js +0 -925
- package/dist/ContextModuleFactory.js +0 -36
- package/dist/DependenciesBlock.js +0 -30
- package/dist/Dependency.js +0 -43
- package/dist/Entrypoint.js +0 -21
- package/dist/ErrorHelpers.js +0 -62
- package/dist/ExecuteModulePlugin.js +0 -46
- package/dist/FileSystem.js +0 -34
- package/dist/FileSystemInfo.js +0 -2
- package/dist/Module.js +0 -226
- package/dist/ModuleTypeConstants.js +0 -92
- package/dist/MultiCompiler.js +0 -440
- package/dist/MultiStats.js +0 -161
- package/dist/MultiWatching.js +0 -62
- package/dist/NormalModule.js +0 -97
- package/dist/NormalModuleFactory.js +0 -43
- package/dist/Resolver.js +0 -39
- package/dist/ResolverFactory.js +0 -61
- package/dist/RspackError.js +0 -21
- package/dist/RuleSetCompiler.js +0 -10
- package/dist/RuntimeGlobals.js +0 -357
- package/dist/RuntimeModule.js +0 -58
- package/dist/Stats.js +0 -161
- package/dist/Template.js +0 -206
- package/dist/Watching.js +0 -290
- package/dist/builtin-loader/index.js +0 -17
- package/dist/builtin-loader/lightningcss/index.js +0 -175
- package/dist/builtin-loader/swc/index.js +0 -5
- package/dist/builtin-loader/swc/pluginImport.js +0 -35
- package/dist/builtin-loader/swc/react.js +0 -7
- package/dist/builtin-loader/swc/types.js +0 -2
- package/dist/builtin-plugin/APIPlugin.js +0 -6
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
- package/dist/builtin-plugin/BannerPlugin.js +0 -22
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
- package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
- package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
- package/dist/builtin-plugin/DataUriPlugin.js +0 -6
- package/dist/builtin-plugin/DefinePlugin.js +0 -44
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
- package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
- package/dist/builtin-plugin/EntryPlugin.js +0 -34
- package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
- package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
- package/dist/builtin-plugin/FileUriPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
- package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
- package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
- package/dist/builtin-plugin/IgnorePlugin.js +0 -20
- package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
- package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
- package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
- package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
- package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
- package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
- package/dist/builtin-plugin/ProgressPlugin.js +0 -15
- package/dist/builtin-plugin/ProvidePlugin.js +0 -14
- package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimePlugin.js +0 -6
- package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
- package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
- package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
- package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
- package/dist/builtin-plugin/WorkerPlugin.js +0 -31
- package/dist/builtin-plugin/base.js +0 -58
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
- package/dist/builtin-plugin/css-extract/index.js +0 -105
- package/dist/builtin-plugin/css-extract/loader.js +0 -204
- package/dist/builtin-plugin/css-extract/utils.js +0 -51
- package/dist/builtin-plugin/index.js +0 -84
- package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
- package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
- package/dist/config/adapter.js +0 -691
- package/dist/config/adapterRuleUse.js +0 -107
- package/dist/config/browserslistTargetHandler.js +0 -345
- package/dist/config/defaults.js +0 -876
- package/dist/config/index.js +0 -20
- package/dist/config/normalization.js +0 -299
- package/dist/config/target.js +0 -318
- package/dist/config/types.js +0 -3
- package/dist/config/zod.js +0 -1030
- package/dist/container/ContainerPlugin.js +0 -50
- package/dist/container/ContainerReferencePlugin.js +0 -49
- package/dist/container/ModuleFederationPlugin.js +0 -137
- package/dist/container/ModuleFederationPluginV1.js +0 -63
- package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
- package/dist/container/options.js +0 -48
- package/dist/error/ConcurrentCompilationError.js +0 -20
- package/dist/exports.js +0 -183
- package/dist/lib/AbstractMethodError.js +0 -51
- package/dist/lib/Cache.js +0 -111
- package/dist/lib/CacheFacade.js +0 -321
- package/dist/lib/Dependency.js +0 -11
- package/dist/lib/EntryOptionPlugin.js +0 -89
- package/dist/lib/EnvironmentPlugin.js +0 -57
- package/dist/lib/HookWebpackError.js +0 -83
- package/dist/lib/IgnoreWarningsPlugin.js +0 -35
- package/dist/lib/LoaderOptionsPlugin.js +0 -74
- package/dist/lib/LoaderTargetPlugin.js +0 -37
- package/dist/lib/ModuleFilenameHelpers.js +0 -83
- package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
- package/dist/lib/WebpackError.js +0 -20
- package/dist/lib/cache/MemoryCachePlugin.js +0 -40
- package/dist/lib/cache/getLazyHashedEtag.js +0 -73
- package/dist/lib/cache/mergeEtags.js +0 -74
- package/dist/lib/formatLocation.js +0 -64
- package/dist/loader-runner/LoaderLoadingError.js +0 -19
- package/dist/loader-runner/index.js +0 -735
- package/dist/loader-runner/loadLoader.js +0 -64
- package/dist/logging/Logger.js +0 -143
- package/dist/logging/createConsoleLogger.js +0 -176
- package/dist/logging/runtime.js +0 -37
- package/dist/logging/truncateArgs.js +0 -81
- package/dist/node/NodeEnvironmentPlugin.js +0 -50
- package/dist/node/NodeTemplatePlugin.js +0 -26
- package/dist/node/NodeWatchFileSystem.js +0 -144
- package/dist/node/nodeConsole.js +0 -146
- package/dist/rspack.js +0 -123
- package/dist/rspackOptionsApply.js +0 -274
- package/dist/sharing/ConsumeSharedPlugin.js +0 -69
- package/dist/sharing/ProvideSharedPlugin.js +0 -50
- package/dist/sharing/SharePlugin.js +0 -66
- package/dist/sharing/ShareRuntimePlugin.js +0 -26
- package/dist/sharing/utils.js +0 -8
- package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
- package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
- package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
- package/dist/stats/StatsFactory.js +0 -167
- package/dist/stats/StatsPrinter.js +0 -142
- package/dist/stats/statsFactoryUtils.js +0 -341
- package/dist/util/ArrayQueue.js +0 -108
- package/dist/util/AssetInfo.js +0 -39
- package/dist/util/IterableHelpers.js +0 -35
- package/dist/util/MergeCaller.js +0 -24
- package/dist/util/SizeFormatHelpers.js +0 -24
- package/dist/util/SplitChunkSize.js +0 -18
- package/dist/util/assertNotNil.js +0 -9
- package/dist/util/assetCondition.js +0 -2
- package/dist/util/bindingVersionCheck.js +0 -124
- package/dist/util/cleverMerge.js +0 -504
- package/dist/util/comparators.js +0 -108
- package/dist/util/createHash.js +0 -161
- package/dist/util/createReadonlyMap.js +0 -29
- package/dist/util/fake.js +0 -28
- package/dist/util/fs.js +0 -120
- package/dist/util/hash/BatchedHash.js +0 -69
- package/dist/util/hash/index.js +0 -39
- package/dist/util/hash/md4.js +0 -27
- package/dist/util/hash/wasm-hash.js +0 -167
- package/dist/util/hash/xxhash64.js +0 -27
- package/dist/util/identifier.js +0 -330
- package/dist/util/index.js +0 -123
- package/dist/util/memoize.js +0 -61
- package/dist/util/scheme.js +0 -57
- package/dist/util/smartGrouping.js +0 -148
- package/dist/util/source.js +0 -42
- package/dist/util/validate.js +0 -77
- package/dist/util/webpack.js +0 -27
- /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RspackOptionsApply = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* The following code is modified based on
|
|
9
|
-
* https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/OptionsApply.js
|
|
10
|
-
*
|
|
11
|
-
* MIT Licensed
|
|
12
|
-
* Author Tobias Koppers @sokra
|
|
13
|
-
* Copyright (c) JS Foundation and other contributors
|
|
14
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
15
|
-
*/
|
|
16
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
17
|
-
const graceful_fs_1 = __importDefault(require("../compiled/graceful-fs"));
|
|
18
|
-
const Module_1 = require("./Module");
|
|
19
|
-
const builtin_plugin_1 = require("./builtin-plugin");
|
|
20
|
-
const EntryOptionPlugin_1 = __importDefault(require("./lib/EntryOptionPlugin"));
|
|
21
|
-
const IgnoreWarningsPlugin_1 = __importDefault(require("./lib/IgnoreWarningsPlugin"));
|
|
22
|
-
const MemoryCachePlugin_1 = __importDefault(require("./lib/cache/MemoryCachePlugin"));
|
|
23
|
-
const DefaultStatsFactoryPlugin_1 = require("./stats/DefaultStatsFactoryPlugin");
|
|
24
|
-
const DefaultStatsPresetPlugin_1 = require("./stats/DefaultStatsPresetPlugin");
|
|
25
|
-
const DefaultStatsPrinterPlugin_1 = require("./stats/DefaultStatsPrinterPlugin");
|
|
26
|
-
const assertNotNil_1 = require("./util/assertNotNil");
|
|
27
|
-
class RspackOptionsApply {
|
|
28
|
-
process(options, compiler) {
|
|
29
|
-
(0, node_assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
|
|
30
|
-
compiler.outputPath = options.output.path;
|
|
31
|
-
compiler.name = options.name;
|
|
32
|
-
compiler.outputFileSystem = graceful_fs_1.default;
|
|
33
|
-
if (options.externals) {
|
|
34
|
-
(0, node_assert_1.default)(options.externalsType, "options.externalsType should have value after `applyRspackOptionsDefaults`");
|
|
35
|
-
new builtin_plugin_1.ExternalsPlugin(options.externalsType, options.externals).apply(compiler);
|
|
36
|
-
}
|
|
37
|
-
if (options.externalsPresets.node) {
|
|
38
|
-
new builtin_plugin_1.NodeTargetPlugin().apply(compiler);
|
|
39
|
-
}
|
|
40
|
-
if (options.externalsPresets.electronMain) {
|
|
41
|
-
new builtin_plugin_1.ElectronTargetPlugin("main").apply(compiler);
|
|
42
|
-
}
|
|
43
|
-
if (options.externalsPresets.electronPreload) {
|
|
44
|
-
new builtin_plugin_1.ElectronTargetPlugin("preload").apply(compiler);
|
|
45
|
-
}
|
|
46
|
-
if (options.externalsPresets.electronRenderer) {
|
|
47
|
-
new builtin_plugin_1.ElectronTargetPlugin("renderer").apply(compiler);
|
|
48
|
-
}
|
|
49
|
-
if (options.externalsPresets.electron &&
|
|
50
|
-
!options.externalsPresets.electronMain &&
|
|
51
|
-
!options.externalsPresets.electronPreload &&
|
|
52
|
-
!options.externalsPresets.electronRenderer) {
|
|
53
|
-
new builtin_plugin_1.ElectronTargetPlugin().apply(compiler);
|
|
54
|
-
}
|
|
55
|
-
if (options.externalsPresets.nwjs) {
|
|
56
|
-
new builtin_plugin_1.ExternalsPlugin("node-commonjs", "nw.gui").apply(compiler);
|
|
57
|
-
}
|
|
58
|
-
if (options.externalsPresets.web ||
|
|
59
|
-
options.externalsPresets.webAsync ||
|
|
60
|
-
(options.externalsPresets.node && options.experiments.css)) {
|
|
61
|
-
new builtin_plugin_1.HttpExternalsRspackPlugin(!!options.experiments.css, !!options.externalsPresets.webAsync).apply(compiler);
|
|
62
|
-
}
|
|
63
|
-
new builtin_plugin_1.ChunkPrefetchPreloadPlugin().apply(compiler);
|
|
64
|
-
if (typeof options.output.chunkFormat === "string") {
|
|
65
|
-
switch (options.output.chunkFormat) {
|
|
66
|
-
case "array-push": {
|
|
67
|
-
new builtin_plugin_1.ArrayPushCallbackChunkFormatPlugin().apply(compiler);
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case "commonjs": {
|
|
71
|
-
new builtin_plugin_1.CommonJsChunkFormatPlugin().apply(compiler);
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
case "module": {
|
|
75
|
-
new builtin_plugin_1.ModuleChunkFormatPlugin().apply(compiler);
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
default:
|
|
79
|
-
throw new Error(`Unsupported chunk format '${options.output.chunkFormat}'.`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (options.output.enabledChunkLoadingTypes &&
|
|
83
|
-
options.output.enabledChunkLoadingTypes.length > 0) {
|
|
84
|
-
for (const type of options.output.enabledChunkLoadingTypes) {
|
|
85
|
-
new builtin_plugin_1.EnableChunkLoadingPlugin(type).apply(compiler);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (options.output.enabledWasmLoadingTypes &&
|
|
89
|
-
options.output.enabledWasmLoadingTypes.length > 0) {
|
|
90
|
-
for (const type of options.output.enabledWasmLoadingTypes) {
|
|
91
|
-
new builtin_plugin_1.EnableWasmLoadingPlugin(type).apply(compiler);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const runtimeChunk = options.optimization
|
|
95
|
-
.runtimeChunk;
|
|
96
|
-
if (runtimeChunk) {
|
|
97
|
-
new builtin_plugin_1.RuntimeChunkPlugin(runtimeChunk).apply(compiler);
|
|
98
|
-
}
|
|
99
|
-
if (!options.optimization.emitOnErrors) {
|
|
100
|
-
new builtin_plugin_1.NoEmitOnErrorsPlugin().apply(compiler);
|
|
101
|
-
}
|
|
102
|
-
if (options.devtool) {
|
|
103
|
-
if (options.devtool.includes("source-map")) {
|
|
104
|
-
const hidden = options.devtool.includes("hidden");
|
|
105
|
-
const inline = options.devtool.includes("inline");
|
|
106
|
-
const evalWrapped = options.devtool.includes("eval");
|
|
107
|
-
const cheap = options.devtool.includes("cheap");
|
|
108
|
-
const moduleMaps = options.devtool.includes("module");
|
|
109
|
-
const noSources = options.devtool.includes("nosources");
|
|
110
|
-
const Plugin = evalWrapped
|
|
111
|
-
? builtin_plugin_1.EvalSourceMapDevToolPlugin
|
|
112
|
-
: builtin_plugin_1.SourceMapDevToolPlugin;
|
|
113
|
-
new Plugin({
|
|
114
|
-
filename: inline ? null : options.output.sourceMapFilename,
|
|
115
|
-
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
|
|
116
|
-
fallbackModuleFilenameTemplate: options.output.devtoolFallbackModuleFilenameTemplate,
|
|
117
|
-
append: hidden ? false : undefined,
|
|
118
|
-
module: moduleMaps ? true : !cheap,
|
|
119
|
-
columns: !cheap,
|
|
120
|
-
noSources: noSources,
|
|
121
|
-
namespace: options.output.devtoolNamespace
|
|
122
|
-
}).apply(compiler);
|
|
123
|
-
}
|
|
124
|
-
else if (options.devtool.includes("eval")) {
|
|
125
|
-
new builtin_plugin_1.EvalDevToolModulePlugin({
|
|
126
|
-
moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
|
|
127
|
-
namespace: options.output.devtoolNamespace
|
|
128
|
-
}).apply(compiler);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
new builtin_plugin_1.JavascriptModulesPlugin().apply(compiler);
|
|
132
|
-
new builtin_plugin_1.JsonModulesPlugin().apply(compiler);
|
|
133
|
-
new builtin_plugin_1.AssetModulesPlugin().apply(compiler);
|
|
134
|
-
if (options.experiments.asyncWebAssembly) {
|
|
135
|
-
new builtin_plugin_1.AsyncWebAssemblyModulesPlugin().apply(compiler);
|
|
136
|
-
}
|
|
137
|
-
if (options.experiments.css) {
|
|
138
|
-
new builtin_plugin_1.CssModulesPlugin().apply(compiler);
|
|
139
|
-
}
|
|
140
|
-
new EntryOptionPlugin_1.default().apply(compiler);
|
|
141
|
-
(0, assertNotNil_1.assertNotNill)(options.context);
|
|
142
|
-
compiler.hooks.entryOption.call(options.context, options.entry);
|
|
143
|
-
new builtin_plugin_1.RuntimePlugin().apply(compiler);
|
|
144
|
-
if (options.experiments.rspackFuture.bundlerInfo) {
|
|
145
|
-
new builtin_plugin_1.BundlerInfoRspackPlugin(options.experiments.rspackFuture.bundlerInfo).apply(compiler);
|
|
146
|
-
}
|
|
147
|
-
new builtin_plugin_1.InferAsyncModulesPlugin().apply(compiler);
|
|
148
|
-
new builtin_plugin_1.APIPlugin().apply(compiler);
|
|
149
|
-
new builtin_plugin_1.DataUriPlugin().apply(compiler);
|
|
150
|
-
new builtin_plugin_1.FileUriPlugin().apply(compiler);
|
|
151
|
-
new builtin_plugin_1.EnsureChunkConditionsPlugin().apply(compiler);
|
|
152
|
-
if (options.optimization.mergeDuplicateChunks) {
|
|
153
|
-
new builtin_plugin_1.MergeDuplicateChunksPlugin().apply(compiler);
|
|
154
|
-
}
|
|
155
|
-
if (options.optimization.sideEffects) {
|
|
156
|
-
new builtin_plugin_1.SideEffectsFlagPlugin( /* options.optimization.sideEffects === true */).apply(compiler);
|
|
157
|
-
}
|
|
158
|
-
if (options.optimization.providedExports) {
|
|
159
|
-
new builtin_plugin_1.FlagDependencyExportsPlugin().apply(compiler);
|
|
160
|
-
}
|
|
161
|
-
if (options.optimization.usedExports) {
|
|
162
|
-
new builtin_plugin_1.FlagDependencyUsagePlugin(options.optimization.usedExports === "global").apply(compiler);
|
|
163
|
-
}
|
|
164
|
-
if (options.optimization.concatenateModules) {
|
|
165
|
-
new builtin_plugin_1.ModuleConcatenationPlugin().apply(compiler);
|
|
166
|
-
}
|
|
167
|
-
if (options.optimization.mangleExports) {
|
|
168
|
-
new builtin_plugin_1.MangleExportsPlugin(options.optimization.mangleExports !== "size").apply(compiler);
|
|
169
|
-
}
|
|
170
|
-
if (options.experiments.lazyCompilation) {
|
|
171
|
-
const lazyOptions = options.experiments.lazyCompilation;
|
|
172
|
-
new builtin_plugin_1.LazyCompilationPlugin(
|
|
173
|
-
// this is only for test
|
|
174
|
-
// @ts-expect-error cacheable is hide
|
|
175
|
-
lazyOptions.cacheable ?? true, lazyOptions.entries ?? true, lazyOptions.imports ?? true, typeof lazyOptions.test === "function"
|
|
176
|
-
? jsModule => lazyOptions.test.call(lazyOptions, new Module_1.Module(jsModule))
|
|
177
|
-
: lazyOptions.test
|
|
178
|
-
? {
|
|
179
|
-
source: lazyOptions.test.source,
|
|
180
|
-
flags: lazyOptions.test.flags
|
|
181
|
-
}
|
|
182
|
-
: undefined, lazyOptions.backend).apply(compiler);
|
|
183
|
-
}
|
|
184
|
-
if (options.output.enabledLibraryTypes &&
|
|
185
|
-
options.output.enabledLibraryTypes.length > 0) {
|
|
186
|
-
for (const type of options.output.enabledLibraryTypes) {
|
|
187
|
-
new builtin_plugin_1.EnableLibraryPlugin(type).apply(compiler);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (options.optimization.splitChunks) {
|
|
191
|
-
new builtin_plugin_1.SplitChunksPlugin(options.optimization.splitChunks).apply(compiler);
|
|
192
|
-
}
|
|
193
|
-
// TODO: inconsistent: the plugin need to be placed after SplitChunksPlugin
|
|
194
|
-
if (options.optimization.removeEmptyChunks) {
|
|
195
|
-
new builtin_plugin_1.RemoveEmptyChunksPlugin().apply(compiler);
|
|
196
|
-
}
|
|
197
|
-
if (options.optimization.realContentHash) {
|
|
198
|
-
new builtin_plugin_1.RealContentHashPlugin().apply(compiler);
|
|
199
|
-
}
|
|
200
|
-
const moduleIds = options.optimization.moduleIds;
|
|
201
|
-
if (moduleIds) {
|
|
202
|
-
switch (moduleIds) {
|
|
203
|
-
case "named": {
|
|
204
|
-
new builtin_plugin_1.NamedModuleIdsPlugin().apply(compiler);
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
case "natural": {
|
|
208
|
-
new builtin_plugin_1.NaturalModuleIdsPlugin().apply(compiler);
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
case "deterministic": {
|
|
212
|
-
new builtin_plugin_1.DeterministicModuleIdsPlugin().apply(compiler);
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
default:
|
|
216
|
-
throw new Error(`moduleIds: ${moduleIds} is not implemented`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const chunkIds = options.optimization.chunkIds;
|
|
220
|
-
if (chunkIds) {
|
|
221
|
-
switch (chunkIds) {
|
|
222
|
-
case "natural": {
|
|
223
|
-
new builtin_plugin_1.NaturalChunkIdsPlugin().apply(compiler);
|
|
224
|
-
}
|
|
225
|
-
case "named": {
|
|
226
|
-
new builtin_plugin_1.NamedChunkIdsPlugin().apply(compiler);
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
case "deterministic": {
|
|
230
|
-
new builtin_plugin_1.DeterministicChunkIdsPlugin().apply(compiler);
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
default:
|
|
234
|
-
throw new Error(`chunkIds: ${chunkIds} is not implemented`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (options.optimization.nodeEnv) {
|
|
238
|
-
new builtin_plugin_1.DefinePlugin({
|
|
239
|
-
"process.env.NODE_ENV": JSON.stringify(options.optimization.nodeEnv)
|
|
240
|
-
}).apply(compiler);
|
|
241
|
-
}
|
|
242
|
-
const { minimize, minimizer } = options.optimization;
|
|
243
|
-
if (minimize && minimizer) {
|
|
244
|
-
for (const item of minimizer) {
|
|
245
|
-
if (typeof item === "function") {
|
|
246
|
-
item.call(compiler, compiler);
|
|
247
|
-
}
|
|
248
|
-
else if (item !== "..." && item) {
|
|
249
|
-
item.apply(compiler);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (options.performance) {
|
|
254
|
-
new builtin_plugin_1.SizeLimitsPlugin(options.performance).apply(compiler);
|
|
255
|
-
}
|
|
256
|
-
new builtin_plugin_1.WarnCaseSensitiveModulesPlugin().apply(compiler);
|
|
257
|
-
if (options.cache) {
|
|
258
|
-
new MemoryCachePlugin_1.default().apply(compiler);
|
|
259
|
-
}
|
|
260
|
-
new builtin_plugin_1.WorkerPlugin(options.output.workerChunkLoading, options.output.workerWasmLoading, options.output.module, options.output.workerPublicPath).apply(compiler);
|
|
261
|
-
new DefaultStatsFactoryPlugin_1.DefaultStatsFactoryPlugin().apply(compiler);
|
|
262
|
-
new DefaultStatsPresetPlugin_1.DefaultStatsPresetPlugin().apply(compiler);
|
|
263
|
-
new DefaultStatsPrinterPlugin_1.DefaultStatsPrinterPlugin().apply(compiler);
|
|
264
|
-
if (options.ignoreWarnings && options.ignoreWarnings.length > 0) {
|
|
265
|
-
new IgnoreWarningsPlugin_1.default(options.ignoreWarnings).apply(compiler);
|
|
266
|
-
}
|
|
267
|
-
compiler.hooks.afterPlugins.call(compiler);
|
|
268
|
-
if (!compiler.inputFileSystem) {
|
|
269
|
-
throw new Error("No input filesystem provided");
|
|
270
|
-
}
|
|
271
|
-
compiler.hooks.afterResolvers.call(compiler);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
exports.RspackOptionsApply = RspackOptionsApply;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConsumeSharedPlugin = void 0;
|
|
4
|
-
const binding_1 = require("@rspack/binding");
|
|
5
|
-
const base_1 = require("../builtin-plugin/base");
|
|
6
|
-
const options_1 = require("../container/options");
|
|
7
|
-
const ShareRuntimePlugin_1 = require("./ShareRuntimePlugin");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
class ConsumeSharedPlugin extends base_1.RspackBuiltinPlugin {
|
|
10
|
-
constructor(options) {
|
|
11
|
-
super();
|
|
12
|
-
this.name = binding_1.BuiltinPluginName.ConsumeSharedPlugin;
|
|
13
|
-
this._options = {
|
|
14
|
-
consumes: (0, options_1.parseOptions)(options.consumes, (item, key) => {
|
|
15
|
-
if (Array.isArray(item))
|
|
16
|
-
throw new Error("Unexpected array in options");
|
|
17
|
-
const result = item === key || !(0, utils_1.isRequiredVersion)(item)
|
|
18
|
-
? // item is a request/key
|
|
19
|
-
{
|
|
20
|
-
import: key,
|
|
21
|
-
shareScope: options.shareScope || "default",
|
|
22
|
-
shareKey: key,
|
|
23
|
-
requiredVersion: undefined,
|
|
24
|
-
packageName: undefined,
|
|
25
|
-
strictVersion: false,
|
|
26
|
-
singleton: false,
|
|
27
|
-
eager: false
|
|
28
|
-
}
|
|
29
|
-
: // key is a request/key
|
|
30
|
-
// item is a version
|
|
31
|
-
{
|
|
32
|
-
import: key,
|
|
33
|
-
shareScope: options.shareScope || "default",
|
|
34
|
-
shareKey: key,
|
|
35
|
-
requiredVersion: item,
|
|
36
|
-
strictVersion: true,
|
|
37
|
-
packageName: undefined,
|
|
38
|
-
singleton: false,
|
|
39
|
-
eager: false
|
|
40
|
-
};
|
|
41
|
-
return result;
|
|
42
|
-
}, (item, key) => ({
|
|
43
|
-
import: item.import === false ? undefined : item.import || key,
|
|
44
|
-
shareScope: item.shareScope || options.shareScope || "default",
|
|
45
|
-
shareKey: item.shareKey || key,
|
|
46
|
-
requiredVersion: item.requiredVersion,
|
|
47
|
-
strictVersion: typeof item.strictVersion === "boolean"
|
|
48
|
-
? item.strictVersion
|
|
49
|
-
: item.import !== false && !item.singleton,
|
|
50
|
-
packageName: item.packageName,
|
|
51
|
-
singleton: !!item.singleton,
|
|
52
|
-
eager: !!item.eager
|
|
53
|
-
})),
|
|
54
|
-
enhanced: options.enhanced ?? false
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
raw(compiler) {
|
|
58
|
-
new ShareRuntimePlugin_1.ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
59
|
-
const rawOptions = {
|
|
60
|
-
consumes: this._options.consumes.map(([key, v]) => ({
|
|
61
|
-
key,
|
|
62
|
-
...v
|
|
63
|
-
})),
|
|
64
|
-
enhanced: this._options.enhanced
|
|
65
|
-
};
|
|
66
|
-
return (0, base_1.createBuiltinPlugin)(this.name, rawOptions);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.ConsumeSharedPlugin = ConsumeSharedPlugin;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProvideSharedPlugin = void 0;
|
|
4
|
-
const binding_1 = require("@rspack/binding");
|
|
5
|
-
const base_1 = require("../builtin-plugin/base");
|
|
6
|
-
const options_1 = require("../container/options");
|
|
7
|
-
const ShareRuntimePlugin_1 = require("./ShareRuntimePlugin");
|
|
8
|
-
class ProvideSharedPlugin extends base_1.RspackBuiltinPlugin {
|
|
9
|
-
constructor(options) {
|
|
10
|
-
super();
|
|
11
|
-
this.name = binding_1.BuiltinPluginName.ProvideSharedPlugin;
|
|
12
|
-
this._provides = (0, options_1.parseOptions)(options.provides, item => {
|
|
13
|
-
if (Array.isArray(item))
|
|
14
|
-
throw new Error("Unexpected array of provides");
|
|
15
|
-
return {
|
|
16
|
-
shareKey: item,
|
|
17
|
-
version: undefined,
|
|
18
|
-
shareScope: options.shareScope || "default",
|
|
19
|
-
eager: false
|
|
20
|
-
};
|
|
21
|
-
}, item => {
|
|
22
|
-
const raw = {
|
|
23
|
-
shareKey: item.shareKey,
|
|
24
|
-
version: item.version,
|
|
25
|
-
shareScope: item.shareScope || options.shareScope || "default",
|
|
26
|
-
eager: !!item.eager
|
|
27
|
-
};
|
|
28
|
-
if (options.enhanced) {
|
|
29
|
-
const enhancedItem = item;
|
|
30
|
-
return {
|
|
31
|
-
...raw,
|
|
32
|
-
singleton: enhancedItem.singleton,
|
|
33
|
-
requiredVersion: enhancedItem.requiredVersion,
|
|
34
|
-
strictVersion: enhancedItem.strictVersion
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return raw;
|
|
38
|
-
});
|
|
39
|
-
this._enhanced = options.enhanced;
|
|
40
|
-
}
|
|
41
|
-
raw(compiler) {
|
|
42
|
-
new ShareRuntimePlugin_1.ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
|
|
43
|
-
const rawOptions = this._provides.map(([key, v]) => ({
|
|
44
|
-
key,
|
|
45
|
-
...v
|
|
46
|
-
}));
|
|
47
|
-
return (0, base_1.createBuiltinPlugin)(this.name, rawOptions);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ProvideSharedPlugin = ProvideSharedPlugin;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharePlugin = void 0;
|
|
4
|
-
const options_1 = require("../container/options");
|
|
5
|
-
const ConsumeSharedPlugin_1 = require("./ConsumeSharedPlugin");
|
|
6
|
-
const ProvideSharedPlugin_1 = require("./ProvideSharedPlugin");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
class SharePlugin {
|
|
9
|
-
constructor(options) {
|
|
10
|
-
const sharedOptions = (0, options_1.parseOptions)(options.shared, (item, key) => {
|
|
11
|
-
if (typeof item !== "string")
|
|
12
|
-
throw new Error("Unexpected array in shared");
|
|
13
|
-
const config = item === key || !(0, utils_1.isRequiredVersion)(item)
|
|
14
|
-
? {
|
|
15
|
-
import: item
|
|
16
|
-
}
|
|
17
|
-
: {
|
|
18
|
-
import: key,
|
|
19
|
-
requiredVersion: item
|
|
20
|
-
};
|
|
21
|
-
return config;
|
|
22
|
-
}, item => item);
|
|
23
|
-
const consumes = sharedOptions.map(([key, options]) => ({
|
|
24
|
-
[key]: {
|
|
25
|
-
import: options.import,
|
|
26
|
-
shareKey: options.shareKey || key,
|
|
27
|
-
shareScope: options.shareScope,
|
|
28
|
-
requiredVersion: options.requiredVersion,
|
|
29
|
-
strictVersion: options.strictVersion,
|
|
30
|
-
singleton: options.singleton,
|
|
31
|
-
packageName: options.packageName,
|
|
32
|
-
eager: options.eager
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
const provides = sharedOptions
|
|
36
|
-
.filter(([, options]) => options.import !== false)
|
|
37
|
-
.map(([key, options]) => ({
|
|
38
|
-
[options.import || key]: {
|
|
39
|
-
shareKey: options.shareKey || key,
|
|
40
|
-
shareScope: options.shareScope,
|
|
41
|
-
version: options.version,
|
|
42
|
-
eager: options.eager,
|
|
43
|
-
singleton: options.singleton,
|
|
44
|
-
requiredVersion: options.requiredVersion,
|
|
45
|
-
strictVersion: options.strictVersion
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
this._shareScope = options.shareScope;
|
|
49
|
-
this._consumes = consumes;
|
|
50
|
-
this._provides = provides;
|
|
51
|
-
this._enhanced = options.enhanced ?? false;
|
|
52
|
-
}
|
|
53
|
-
apply(compiler) {
|
|
54
|
-
new ConsumeSharedPlugin_1.ConsumeSharedPlugin({
|
|
55
|
-
shareScope: this._shareScope,
|
|
56
|
-
consumes: this._consumes,
|
|
57
|
-
enhanced: this._enhanced
|
|
58
|
-
}).apply(compiler);
|
|
59
|
-
new ProvideSharedPlugin_1.ProvideSharedPlugin({
|
|
60
|
-
shareScope: this._shareScope,
|
|
61
|
-
provides: this._provides,
|
|
62
|
-
enhanced: this._enhanced
|
|
63
|
-
}).apply(compiler);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.SharePlugin = SharePlugin;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShareRuntimePlugin = void 0;
|
|
4
|
-
const binding_1 = require("@rspack/binding");
|
|
5
|
-
const base_1 = require("../builtin-plugin/base");
|
|
6
|
-
const compilerSet = new WeakSet();
|
|
7
|
-
function isSingleton(compiler) {
|
|
8
|
-
return compilerSet.has(compiler);
|
|
9
|
-
}
|
|
10
|
-
function setSingleton(compiler) {
|
|
11
|
-
compilerSet.add(compiler);
|
|
12
|
-
}
|
|
13
|
-
class ShareRuntimePlugin extends base_1.RspackBuiltinPlugin {
|
|
14
|
-
constructor(enhanced = false) {
|
|
15
|
-
super();
|
|
16
|
-
this.enhanced = enhanced;
|
|
17
|
-
this.name = binding_1.BuiltinPluginName.ShareRuntimePlugin;
|
|
18
|
-
}
|
|
19
|
-
raw(compiler) {
|
|
20
|
-
if (isSingleton(compiler))
|
|
21
|
-
return;
|
|
22
|
-
setSingleton(compiler);
|
|
23
|
-
return (0, base_1.createBuiltinPlugin)(this.name, this.enhanced);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.ShareRuntimePlugin = ShareRuntimePlugin;
|
package/dist/sharing/utils.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRequiredVersion = void 0;
|
|
4
|
-
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
5
|
-
function isRequiredVersion(str) {
|
|
6
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
7
|
-
}
|
|
8
|
-
exports.isRequiredVersion = isRequiredVersion;
|