@rspack/core 1.0.10 → 1.0.12

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.
Files changed (219) hide show
  1. package/compiled/browserslist/index.js +94 -49
  2. package/compiled/browserslist/package.json +1 -1
  3. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  4. package/dist/config/types.d.ts +309 -0
  5. package/dist/config/zod.d.ts +22 -534
  6. package/dist/cssExtractHmr.js +224 -0
  7. package/dist/cssExtractLoader.js +277 -0
  8. package/dist/index.js +23255 -31
  9. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  10. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  11. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  12. package/package.json +8 -5
  13. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  14. package/compiled/json-parse-even-better-errors/index.js +0 -193
  15. package/compiled/json-parse-even-better-errors/package.json +0 -1
  16. package/compiled/neo-async/index.d.ts +0 -685
  17. package/compiled/neo-async/index.js +0 -9207
  18. package/compiled/neo-async/license +0 -22
  19. package/compiled/neo-async/package.json +0 -1
  20. package/compiled/zod-validation-error/index.d.ts +0 -41
  21. package/compiled/zod-validation-error/index.js +0 -335
  22. package/compiled/zod-validation-error/license +0 -9
  23. package/compiled/zod-validation-error/package.json +0 -1
  24. package/dist/Chunk.js +0 -118
  25. package/dist/ChunkGraph.js +0 -27
  26. package/dist/ChunkGroup.js +0 -76
  27. package/dist/Compilation.js +0 -854
  28. package/dist/Compiler.js +0 -925
  29. package/dist/ContextModuleFactory.js +0 -36
  30. package/dist/DependenciesBlock.js +0 -30
  31. package/dist/Dependency.js +0 -43
  32. package/dist/Entrypoint.js +0 -21
  33. package/dist/ErrorHelpers.js +0 -62
  34. package/dist/ExecuteModulePlugin.js +0 -46
  35. package/dist/FileSystem.js +0 -34
  36. package/dist/FileSystemInfo.js +0 -2
  37. package/dist/Module.js +0 -226
  38. package/dist/ModuleTypeConstants.js +0 -92
  39. package/dist/MultiCompiler.js +0 -440
  40. package/dist/MultiStats.js +0 -161
  41. package/dist/MultiWatching.js +0 -62
  42. package/dist/NormalModule.js +0 -97
  43. package/dist/NormalModuleFactory.js +0 -43
  44. package/dist/Resolver.js +0 -39
  45. package/dist/ResolverFactory.js +0 -61
  46. package/dist/RspackError.js +0 -21
  47. package/dist/RuleSetCompiler.js +0 -10
  48. package/dist/RuntimeGlobals.js +0 -357
  49. package/dist/RuntimeModule.js +0 -58
  50. package/dist/Stats.js +0 -161
  51. package/dist/Template.js +0 -206
  52. package/dist/Watching.js +0 -290
  53. package/dist/builtin-loader/index.js +0 -17
  54. package/dist/builtin-loader/lightningcss/index.js +0 -175
  55. package/dist/builtin-loader/swc/index.js +0 -5
  56. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  57. package/dist/builtin-loader/swc/react.js +0 -7
  58. package/dist/builtin-loader/swc/types.js +0 -2
  59. package/dist/builtin-plugin/APIPlugin.js +0 -6
  60. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  61. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  62. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  63. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  64. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  65. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  66. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  67. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  68. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  69. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  70. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  71. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  72. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  73. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  74. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  75. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  76. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  78. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  79. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  80. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  81. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  82. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  83. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  84. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  85. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  86. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  87. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  88. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  89. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  90. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  91. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  92. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  93. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  94. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  95. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  96. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  97. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  98. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  99. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  100. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  101. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  102. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  106. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  107. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  108. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  109. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  110. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  111. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  112. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  113. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  114. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  115. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  116. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  117. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  118. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  119. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  120. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  121. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  122. package/dist/builtin-plugin/base.js +0 -58
  123. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  124. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  125. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  126. package/dist/builtin-plugin/css-extract/index.js +0 -105
  127. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  128. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  129. package/dist/builtin-plugin/index.js +0 -84
  130. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  131. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  132. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  133. package/dist/config/adapter.js +0 -691
  134. package/dist/config/adapterRuleUse.js +0 -107
  135. package/dist/config/browserslistTargetHandler.js +0 -345
  136. package/dist/config/defaults.js +0 -876
  137. package/dist/config/index.js +0 -20
  138. package/dist/config/normalization.js +0 -299
  139. package/dist/config/target.js +0 -318
  140. package/dist/config/types.js +0 -3
  141. package/dist/config/zod.js +0 -1030
  142. package/dist/container/ContainerPlugin.js +0 -50
  143. package/dist/container/ContainerReferencePlugin.js +0 -49
  144. package/dist/container/ModuleFederationPlugin.js +0 -137
  145. package/dist/container/ModuleFederationPluginV1.js +0 -63
  146. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  147. package/dist/container/options.js +0 -48
  148. package/dist/error/ConcurrentCompilationError.js +0 -20
  149. package/dist/exports.js +0 -183
  150. package/dist/lib/AbstractMethodError.js +0 -51
  151. package/dist/lib/Cache.js +0 -111
  152. package/dist/lib/CacheFacade.js +0 -321
  153. package/dist/lib/Dependency.js +0 -11
  154. package/dist/lib/EntryOptionPlugin.js +0 -89
  155. package/dist/lib/EnvironmentPlugin.js +0 -57
  156. package/dist/lib/HookWebpackError.js +0 -83
  157. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  158. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  159. package/dist/lib/LoaderTargetPlugin.js +0 -37
  160. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  161. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  162. package/dist/lib/WebpackError.js +0 -20
  163. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  164. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  165. package/dist/lib/cache/mergeEtags.js +0 -74
  166. package/dist/lib/formatLocation.js +0 -64
  167. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  168. package/dist/loader-runner/index.js +0 -735
  169. package/dist/loader-runner/loadLoader.js +0 -64
  170. package/dist/logging/Logger.js +0 -143
  171. package/dist/logging/createConsoleLogger.js +0 -176
  172. package/dist/logging/runtime.js +0 -37
  173. package/dist/logging/truncateArgs.js +0 -81
  174. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  175. package/dist/node/NodeTemplatePlugin.js +0 -26
  176. package/dist/node/NodeWatchFileSystem.js +0 -144
  177. package/dist/node/nodeConsole.js +0 -146
  178. package/dist/rspack.js +0 -123
  179. package/dist/rspackOptionsApply.js +0 -274
  180. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  181. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  182. package/dist/sharing/SharePlugin.js +0 -66
  183. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  184. package/dist/sharing/utils.js +0 -8
  185. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  186. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  187. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  188. package/dist/stats/StatsFactory.js +0 -167
  189. package/dist/stats/StatsPrinter.js +0 -142
  190. package/dist/stats/statsFactoryUtils.js +0 -341
  191. package/dist/util/ArrayQueue.js +0 -108
  192. package/dist/util/AssetInfo.js +0 -39
  193. package/dist/util/IterableHelpers.js +0 -35
  194. package/dist/util/MergeCaller.js +0 -24
  195. package/dist/util/SizeFormatHelpers.js +0 -24
  196. package/dist/util/SplitChunkSize.js +0 -18
  197. package/dist/util/assertNotNil.js +0 -9
  198. package/dist/util/assetCondition.js +0 -2
  199. package/dist/util/bindingVersionCheck.js +0 -124
  200. package/dist/util/cleverMerge.js +0 -504
  201. package/dist/util/comparators.js +0 -108
  202. package/dist/util/createHash.js +0 -161
  203. package/dist/util/createReadonlyMap.js +0 -29
  204. package/dist/util/fake.js +0 -28
  205. package/dist/util/fs.js +0 -120
  206. package/dist/util/hash/BatchedHash.js +0 -69
  207. package/dist/util/hash/index.js +0 -39
  208. package/dist/util/hash/md4.js +0 -27
  209. package/dist/util/hash/wasm-hash.js +0 -167
  210. package/dist/util/hash/xxhash64.js +0 -27
  211. package/dist/util/identifier.js +0 -330
  212. package/dist/util/index.js +0 -123
  213. package/dist/util/memoize.js +0 -61
  214. package/dist/util/scheme.js +0 -57
  215. package/dist/util/smartGrouping.js +0 -148
  216. package/dist/util/source.js +0 -42
  217. package/dist/util/validate.js +0 -77
  218. package/dist/util/webpack.js +0 -27
  219. /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
@@ -1,876 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/defaults.js
5
- *
6
- * MIT Licensed
7
- * Author Tobias Koppers @sokra
8
- * Copyright (c) JS Foundation and other contributors
9
- * https://github.com/webpack/webpack/blob/main/LICENSE
10
- */
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.applyRspackOptionsBaseDefaults = exports.applyRspackOptionsDefaults = void 0;
16
- const node_assert_1 = __importDefault(require("node:assert"));
17
- const node_fs_1 = __importDefault(require("node:fs"));
18
- const node_path_1 = __importDefault(require("node:path"));
19
- const ModuleTypeConstants_1 = require("../ModuleTypeConstants");
20
- const Template_1 = require("../Template");
21
- const builtin_plugin_1 = require("../builtin-plugin");
22
- const util_1 = require("../util");
23
- const assertNotNil_1 = require("../util/assertNotNil");
24
- const cleverMerge_1 = require("../util/cleverMerge");
25
- const target_1 = require("./target");
26
- const applyRspackOptionsDefaults = (options) => {
27
- F(options, "context", () => process.cwd());
28
- F(options, "target", () => {
29
- return (0, target_1.getDefaultTarget)(options.context);
30
- });
31
- const { mode, target } = options;
32
- (0, node_assert_1.default)(!(0, util_1.isNil)(target));
33
- const targetProperties = target === false
34
- ? false
35
- : typeof target === "string"
36
- ? (0, target_1.getTargetProperties)(target, options.context)
37
- : (0, target_1.getTargetsProperties)(target, options.context);
38
- const development = mode === "development";
39
- const production = mode === "production" || !mode;
40
- if (typeof options.entry !== "function") {
41
- for (const key of Object.keys(options.entry)) {
42
- F(options.entry[key], "import", () => ["./src"]);
43
- }
44
- }
45
- F(options, "devtool", () => (development ? "eval" : false));
46
- D(options, "watch", false);
47
- D(options, "profile", false);
48
- // IGNORE(bail): bail is default to false in webpack, but it's set in `Compilation`
49
- D(options, "bail", false);
50
- // IGNORE(cache): cache is default to { type: "memory" } in webpack when the mode is development,
51
- // but Rspack currently does not support this option
52
- F(options, "cache", () => development);
53
- applyExperimentsDefaults(options.experiments);
54
- applySnapshotDefaults(options.snapshot, { production });
55
- applyModuleDefaults(options.module, {
56
- asyncWebAssembly: options.experiments.asyncWebAssembly,
57
- css: options.experiments.css,
58
- targetProperties
59
- });
60
- applyOutputDefaults(options.output, {
61
- context: options.context,
62
- targetProperties,
63
- isAffectedByBrowserslist: target === undefined ||
64
- (typeof target === "string" && target.startsWith("browserslist")) ||
65
- (Array.isArray(target) &&
66
- target.some(target => target.startsWith("browserslist"))),
67
- outputModule: options.experiments.outputModule,
68
- development,
69
- entry: options.entry,
70
- futureDefaults: options.experiments.futureDefaults
71
- });
72
- // bundlerInfo is affected by outputDefaults so must be executed after outputDefaults
73
- applybundlerInfoDefaults(options.experiments.rspackFuture, options.output.library);
74
- applyExternalsPresetsDefaults(options.externalsPresets, {
75
- targetProperties
76
- });
77
- F(options, "externalsType", () => {
78
- return options.output.library
79
- ? // loose type 'string', actual type is "commonjs" | "var" | "commonjs2"....
80
- options.output.library.type
81
- : options.output.module
82
- ? "module-import"
83
- : "var";
84
- });
85
- applyNodeDefaults(options.node, {
86
- targetProperties,
87
- outputModule: options.output.module
88
- });
89
- applyLoaderDefaults(options.loader, {
90
- targetProperties,
91
- environment: options.output.environment
92
- });
93
- F(options, "performance", () => production &&
94
- targetProperties &&
95
- (targetProperties.browser || targetProperties.browser === null)
96
- ? {}
97
- : false);
98
- applyPerformanceDefaults(options.performance, {
99
- production
100
- });
101
- applyOptimizationDefaults(options.optimization, {
102
- production,
103
- development,
104
- css: options.experiments.css
105
- });
106
- options.resolve = (0, cleverMerge_1.cleverMerge)(getResolveDefaults({
107
- context: options.context,
108
- targetProperties,
109
- mode: options.mode,
110
- css: options.experiments.css
111
- }), options.resolve);
112
- options.resolveLoader = (0, cleverMerge_1.cleverMerge)(getResolveLoaderDefaults(), options.resolveLoader);
113
- };
114
- exports.applyRspackOptionsDefaults = applyRspackOptionsDefaults;
115
- const applyRspackOptionsBaseDefaults = (options) => {
116
- F(options, "context", () => process.cwd());
117
- applyInfrastructureLoggingDefaults(options.infrastructureLogging);
118
- };
119
- exports.applyRspackOptionsBaseDefaults = applyRspackOptionsBaseDefaults;
120
- const applyInfrastructureLoggingDefaults = (infrastructureLogging) => {
121
- F(infrastructureLogging, "stream", () => process.stderr);
122
- const tty = infrastructureLogging.stream.isTTY && process.env.TERM !== "dumb";
123
- D(infrastructureLogging, "level", "info");
124
- D(infrastructureLogging, "debug", false);
125
- D(infrastructureLogging, "colors", tty);
126
- D(infrastructureLogging, "appendOnly", !tty);
127
- };
128
- const applyExperimentsDefaults = (experiments) => {
129
- D(experiments, "futureDefaults", false);
130
- // IGNORE(experiments.lazyCompilation): In webpack, lazyCompilation is undefined by default
131
- D(experiments, "lazyCompilation", false);
132
- D(experiments, "asyncWebAssembly", experiments.futureDefaults);
133
- D(experiments, "css", experiments.futureDefaults ? true : undefined);
134
- D(experiments, "layers", false);
135
- D(experiments, "topLevelAwait", true);
136
- // IGNORE(experiments.incremental): Rspack specific configuration for incremental
137
- D(experiments, "incremental", {});
138
- if (typeof experiments.incremental === "object") {
139
- D(experiments.incremental, "make", true);
140
- D(experiments.incremental, "emitAssets", true);
141
- D(experiments.incremental, "inferAsyncModules", false);
142
- D(experiments.incremental, "providedExports", false);
143
- D(experiments.incremental, "moduleHashes", false);
144
- D(experiments.incremental, "moduleCodegen", false);
145
- D(experiments.incremental, "moduleRuntimeRequirements", false);
146
- }
147
- // IGNORE(experiments.rspackFuture): Rspack specific configuration
148
- D(experiments, "rspackFuture", {});
149
- // rspackFuture.bundlerInfo default value is applied after applyDefaults
150
- };
151
- const applybundlerInfoDefaults = (rspackFuture, library) => {
152
- if (typeof rspackFuture === "object") {
153
- D(rspackFuture, "bundlerInfo", {});
154
- if (typeof rspackFuture.bundlerInfo === "object") {
155
- D(rspackFuture.bundlerInfo, "version", require("../../package.json").version);
156
- D(rspackFuture.bundlerInfo, "bundler", "rspack");
157
- // don't inject for library mode
158
- D(rspackFuture.bundlerInfo, "force", !library);
159
- }
160
- }
161
- };
162
- const applySnapshotDefaults = (_snapshot, _env) => { };
163
- const applyJavascriptParserOptionsDefaults = (parserOptions) => {
164
- D(parserOptions, "dynamicImportMode", "lazy");
165
- D(parserOptions, "dynamicImportPrefetch", false);
166
- D(parserOptions, "dynamicImportPreload", false);
167
- D(parserOptions, "url", true);
168
- D(parserOptions, "exprContextCritical", true);
169
- D(parserOptions, "wrappedContextCritical", false);
170
- D(parserOptions, "strictExportPresence", false);
171
- D(parserOptions, "requireAsExpression", true);
172
- D(parserOptions, "requireDynamic", true);
173
- D(parserOptions, "requireResolve", true);
174
- D(parserOptions, "importDynamic", true);
175
- D(parserOptions, "worker", ["..."]);
176
- D(parserOptions, "importMeta", true);
177
- };
178
- const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
179
- (0, assertNotNil_1.assertNotNill)(module.parser);
180
- (0, assertNotNil_1.assertNotNill)(module.generator);
181
- // IGNORE(module.parser): already check to align in 2024.6.27
182
- F(module.parser, ModuleTypeConstants_1.ASSET_MODULE_TYPE, () => ({}));
183
- (0, assertNotNil_1.assertNotNill)(module.parser.asset);
184
- F(module.parser.asset, "dataUrlCondition", () => ({}));
185
- if (typeof module.parser.asset.dataUrlCondition === "object") {
186
- D(module.parser.asset.dataUrlCondition, "maxSize", 8096);
187
- }
188
- F(module.parser, "javascript", () => ({}));
189
- (0, assertNotNil_1.assertNotNill)(module.parser.javascript);
190
- applyJavascriptParserOptionsDefaults(module.parser.javascript);
191
- if (css) {
192
- F(module.parser, "css", () => ({}));
193
- (0, assertNotNil_1.assertNotNill)(module.parser.css);
194
- D(module.parser.css, "namedExports", true);
195
- F(module.parser, "css/auto", () => ({}));
196
- (0, assertNotNil_1.assertNotNill)(module.parser["css/auto"]);
197
- D(module.parser["css/auto"], "namedExports", true);
198
- F(module.parser, "css/module", () => ({}));
199
- (0, assertNotNil_1.assertNotNill)(module.parser["css/module"]);
200
- D(module.parser["css/module"], "namedExports", true);
201
- // IGNORE(module.generator): already check to align in 2024.6.27
202
- F(module.generator, "css", () => ({}));
203
- (0, assertNotNil_1.assertNotNill)(module.generator.css);
204
- D(module.generator.css, "exportsOnly", !targetProperties || !targetProperties.document);
205
- D(module.generator.css, "esModule", true);
206
- F(module.generator, "css/auto", () => ({}));
207
- (0, assertNotNil_1.assertNotNill)(module.generator["css/auto"]);
208
- D(module.generator["css/auto"], "exportsOnly", !targetProperties || !targetProperties.document);
209
- D(module.generator["css/auto"], "exportsConvention", "as-is");
210
- D(module.generator["css/auto"], "localIdentName", "[uniqueName]-[id]-[local]");
211
- D(module.generator["css/auto"], "esModule", true);
212
- F(module.generator, "css/module", () => ({}));
213
- (0, assertNotNil_1.assertNotNill)(module.generator["css/module"]);
214
- D(module.generator["css/module"], "exportsOnly", !targetProperties || !targetProperties.document);
215
- D(module.generator["css/module"], "exportsConvention", "as-is");
216
- D(module.generator["css/module"], "localIdentName", "[uniqueName]-[id]-[local]");
217
- D(module.generator["css/module"], "esModule", true);
218
- }
219
- // IGNORE(module.defaultRules): Rspack does not support `rule.assert`
220
- // https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L839
221
- A(module, "defaultRules", () => {
222
- const esm = {
223
- type: "javascript/esm",
224
- resolve: {
225
- byDependency: {
226
- esm: {
227
- fullySpecified: true
228
- }
229
- }
230
- }
231
- };
232
- const commonjs = {
233
- type: "javascript/dynamic"
234
- };
235
- const rules = [
236
- {
237
- mimetype: "application/node",
238
- type: "javascript/auto"
239
- },
240
- {
241
- test: /\.json$/i,
242
- type: "json"
243
- },
244
- {
245
- mimetype: "application/json",
246
- type: "json"
247
- },
248
- {
249
- test: /\.mjs$/i,
250
- ...esm
251
- },
252
- {
253
- test: /\.js$/i,
254
- descriptionData: {
255
- type: "module"
256
- },
257
- ...esm
258
- },
259
- {
260
- test: /\.cjs$/i,
261
- ...commonjs
262
- },
263
- {
264
- test: /\.js$/i,
265
- descriptionData: {
266
- type: "commonjs"
267
- },
268
- ...commonjs
269
- },
270
- {
271
- mimetype: {
272
- or: ["text/javascript", "application/javascript"]
273
- },
274
- ...esm
275
- }
276
- ];
277
- if (asyncWebAssembly) {
278
- const wasm = {
279
- type: "webassembly/async",
280
- rules: [
281
- {
282
- descriptionData: {
283
- type: "module"
284
- },
285
- resolve: {
286
- fullySpecified: true
287
- }
288
- }
289
- ]
290
- };
291
- rules.push({
292
- test: /\.wasm$/i,
293
- ...wasm
294
- });
295
- rules.push({
296
- mimetype: "application/wasm",
297
- ...wasm
298
- });
299
- }
300
- if (css) {
301
- const resolve = {
302
- fullySpecified: true,
303
- preferRelative: true
304
- };
305
- rules.push({
306
- test: /\.css$/i,
307
- type: "css/auto",
308
- resolve
309
- });
310
- rules.push({
311
- mimetype: "text/css+module",
312
- type: "css/module",
313
- resolve
314
- });
315
- rules.push({
316
- mimetype: "text/css",
317
- type: "css",
318
- resolve
319
- });
320
- }
321
- rules.push({
322
- dependency: "url",
323
- oneOf: [
324
- {
325
- scheme: /^data$/,
326
- type: "asset/inline"
327
- },
328
- {
329
- type: "asset/resource"
330
- }
331
- ]
332
- }, {
333
- with: { type: "json" },
334
- type: "json"
335
- });
336
- return rules;
337
- });
338
- };
339
- const applyOutputDefaults = (output, { context, outputModule, targetProperties: tp, isAffectedByBrowserslist, development, entry, futureDefaults }) => {
340
- const getLibraryName = (library) => {
341
- const libraryName = typeof library === "object" &&
342
- library &&
343
- !Array.isArray(library) &&
344
- "type" in library
345
- ? library.name
346
- : library;
347
- if (Array.isArray(libraryName)) {
348
- return libraryName.join(".");
349
- }
350
- if (typeof libraryName === "object") {
351
- return getLibraryName(libraryName.root);
352
- }
353
- if (typeof libraryName === "string") {
354
- return libraryName;
355
- }
356
- return "";
357
- };
358
- F(output, "uniqueName", () => {
359
- const libraryName = getLibraryName(output.library).replace(/^\[(\\*[\w:]+\\*)\](\.)|(\.)\[(\\*[\w:]+\\*)\](?=\.|$)|\[(\\*[\w:]+\\*)\]/g, (m, a, d1, d2, b, c) => {
360
- const content = a || b || c;
361
- return content.startsWith("\\") && content.endsWith("\\")
362
- ? `${d2 || ""}[${content.slice(1, -1)}]${d1 || ""}`
363
- : "";
364
- });
365
- if (libraryName)
366
- return libraryName;
367
- const pkgPath = node_path_1.default.resolve(context, "package.json");
368
- try {
369
- const packageInfo = JSON.parse(node_fs_1.default.readFileSync(pkgPath, "utf-8"));
370
- return packageInfo.name || "";
371
- }
372
- catch (err) {
373
- const e = err;
374
- if (e.code !== "ENOENT") {
375
- e.message += `\nwhile determining default 'output.uniqueName' from 'name' in ${pkgPath}`;
376
- throw e;
377
- }
378
- return "";
379
- }
380
- });
381
- F(output, "devtoolNamespace", () => output.uniqueName);
382
- F(output, "module", () => !!outputModule);
383
- D(output, "filename", output.module ? "[name].mjs" : "[name].js");
384
- F(output, "iife", () => !output.module);
385
- F(output, "chunkFilename", () => {
386
- const filename = output.filename;
387
- if (typeof filename !== "function") {
388
- const hasName = filename.includes("[name]");
389
- const hasId = filename.includes("[id]");
390
- const hasChunkHash = filename.includes("[chunkhash]");
391
- const hasContentHash = filename.includes("[contenthash]");
392
- // Anything changing depending on chunk is fine
393
- if (hasChunkHash || hasContentHash || hasName || hasId)
394
- return filename;
395
- // Otherwise prefix "[id]." in front of the basename to make it changing
396
- return filename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2");
397
- }
398
- return "[id].js";
399
- });
400
- F(output, "cssFilename", () => {
401
- const filename = output.filename;
402
- if (typeof filename !== "function") {
403
- return filename.replace(/\.[mc]?js(\?|$)/, ".css$1");
404
- }
405
- return "[id].css";
406
- });
407
- F(output, "cssChunkFilename", () => {
408
- const chunkFilename = output.chunkFilename;
409
- if (typeof chunkFilename !== "function") {
410
- return chunkFilename.replace(/\.[mc]?js(\?|$)/, ".css$1");
411
- }
412
- return "[id].css";
413
- });
414
- D(output, "hotUpdateChunkFilename", `[id].[fullhash].hot-update.${output.module ? "mjs" : "js"}`);
415
- D(output, "hotUpdateMainFilename", "[runtime].[fullhash].hot-update.json");
416
- const uniqueNameId = Template_1.Template.toIdentifier(output.uniqueName);
417
- F(output, "hotUpdateGlobal", () => `webpackHotUpdate${uniqueNameId}`);
418
- F(output, "chunkLoadingGlobal", () => `webpackChunk${uniqueNameId}`);
419
- D(output, "cssHeadDataCompression", !development);
420
- D(output, "assetModuleFilename", "[hash][ext][query]");
421
- D(output, "webassemblyModuleFilename", "[hash].module.wasm");
422
- F(output, "path", () => node_path_1.default.join(process.cwd(), "dist"));
423
- F(output, "pathinfo", () => development);
424
- D(output, "publicPath", tp && (tp.document || tp.importScripts) ? "auto" : "");
425
- D(output, "hashFunction", futureDefaults ? "xxhash64" : "md4");
426
- D(output, "hashDigest", "hex");
427
- D(output, "hashDigestLength", futureDefaults ? 16 : 20);
428
- D(output, "strictModuleErrorHandling", false);
429
- if (output.library) {
430
- F(output.library, "type", () => (output.module ? "module" : "var"));
431
- }
432
- F(output, "chunkFormat", () => {
433
- if (tp) {
434
- const helpMessage = isAffectedByBrowserslist
435
- ? "Make sure that your 'browserslist' includes only platforms that support these features or select an appropriate 'target' to allow selecting a chunk format by default. Alternatively specify the 'output.chunkFormat' directly."
436
- : "Select an appropriate 'target' to allow selecting one by default, or specify the 'output.chunkFormat' directly.";
437
- if (output.module) {
438
- if (tp.dynamicImport)
439
- return "module";
440
- if (tp.document)
441
- return "array-push";
442
- throw new Error(`For the selected environment is no default ESM chunk format available:\nESM exports can be chosen when 'import()' is available.\nJSONP Array push can be chosen when 'document' is available.\n${helpMessage}`);
443
- }
444
- if (tp.document)
445
- return "array-push";
446
- if (tp.require)
447
- return "commonjs";
448
- if (tp.nodeBuiltins)
449
- return "commonjs";
450
- if (tp.importScripts)
451
- return "array-push";
452
- throw new Error(`For the selected environment is no default script chunk format available:\nJSONP Array push can be chosen when 'document' or 'importScripts' is available.\nCommonJs exports can be chosen when 'require' or node builtins are available.\n${helpMessage}`);
453
- }
454
- throw new Error("Chunk format can't be selected by default when no target is specified");
455
- });
456
- D(output, "asyncChunks", true);
457
- F(output, "chunkLoading", () => {
458
- if (tp) {
459
- switch (output.chunkFormat) {
460
- case "array-push":
461
- if (tp.document)
462
- return "jsonp";
463
- if (tp.importScripts)
464
- return "import-scripts";
465
- break;
466
- case "commonjs":
467
- if (tp.require)
468
- return "require";
469
- if (tp.nodeBuiltins)
470
- return "async-node";
471
- break;
472
- case "module":
473
- if (tp.dynamicImport)
474
- return "import";
475
- break;
476
- }
477
- if (tp.require === null ||
478
- tp.nodeBuiltins === null ||
479
- tp.document === null ||
480
- tp.importScripts === null) {
481
- return "universal";
482
- }
483
- }
484
- return false;
485
- });
486
- F(output, "workerChunkLoading", () => {
487
- if (tp) {
488
- switch (output.chunkFormat) {
489
- case "array-push":
490
- if (tp.importScriptsInWorker)
491
- return "import-scripts";
492
- break;
493
- case "commonjs":
494
- if (tp.require)
495
- return "require";
496
- if (tp.nodeBuiltins)
497
- return "async-node";
498
- break;
499
- case "module":
500
- if (tp.dynamicImportInWorker)
501
- return "import";
502
- break;
503
- }
504
- if (tp.require === null ||
505
- tp.nodeBuiltins === null ||
506
- tp.importScriptsInWorker === null) {
507
- return "universal";
508
- }
509
- }
510
- return false;
511
- });
512
- F(output, "wasmLoading", () => {
513
- if (tp) {
514
- if (tp.fetchWasm)
515
- return "fetch";
516
- if (tp.nodeBuiltins)
517
- return output.module ? "async-node-module" : "async-node";
518
- if (tp.nodeBuiltins === null || tp.fetchWasm === null) {
519
- return "universal";
520
- }
521
- }
522
- return false;
523
- });
524
- F(output, "workerWasmLoading", () => output.wasmLoading);
525
- F(output, "globalObject", () => {
526
- if (tp) {
527
- if (tp.global)
528
- return "global";
529
- if (tp.globalThis)
530
- return "globalThis";
531
- }
532
- return "self";
533
- });
534
- D(output, "importFunctionName", "import");
535
- D(output, "importMetaName", "import.meta");
536
- // IGNORE(output.clean): The default value of `output.clean` in webpack is undefined, but it has the same effect as false.
537
- F(output, "clean", () => !!output.clean);
538
- D(output, "crossOriginLoading", false);
539
- D(output, "workerPublicPath", "");
540
- D(output, "sourceMapFilename", "[file].map[query]");
541
- F(output, "scriptType", () => (output.module ? "module" : false));
542
- D(output, "charset", true);
543
- D(output, "chunkLoadTimeout", 120000);
544
- const { trustedTypes } = output;
545
- if (trustedTypes) {
546
- F(trustedTypes, "policyName", () => output.uniqueName.replace(/[^a-zA-Z0-9\-#=_/@.%]+/g, "_") || "webpack");
547
- }
548
- const forEachEntry = (fn) => {
549
- if (typeof entry === "function") {
550
- return;
551
- }
552
- for (const name of Object.keys(entry)) {
553
- fn(entry[name]);
554
- }
555
- };
556
- A(output, "enabledLibraryTypes", () => {
557
- const enabledLibraryTypes = [];
558
- if (output.library) {
559
- enabledLibraryTypes.push(output.library.type);
560
- }
561
- forEachEntry(desc => {
562
- if (desc.library) {
563
- enabledLibraryTypes.push(desc.library.type);
564
- }
565
- });
566
- return enabledLibraryTypes;
567
- });
568
- A(output, "enabledChunkLoadingTypes", () => {
569
- const enabledChunkLoadingTypes = new Set();
570
- if (output.chunkLoading) {
571
- enabledChunkLoadingTypes.add(output.chunkLoading);
572
- }
573
- if (output.workerChunkLoading) {
574
- enabledChunkLoadingTypes.add(output.workerChunkLoading);
575
- }
576
- forEachEntry(desc => {
577
- if (desc.chunkLoading) {
578
- enabledChunkLoadingTypes.add(desc.chunkLoading);
579
- }
580
- });
581
- return Array.from(enabledChunkLoadingTypes);
582
- });
583
- A(output, "enabledWasmLoadingTypes", () => {
584
- const enabledWasmLoadingTypes = new Set();
585
- if (output.wasmLoading) {
586
- enabledWasmLoadingTypes.add(output.wasmLoading);
587
- }
588
- if (output.workerWasmLoading) {
589
- enabledWasmLoadingTypes.add(output.workerWasmLoading);
590
- }
591
- // forEachEntry(desc => {
592
- // if (desc.wasmLoading) {
593
- // enabledWasmLoadingTypes.add(desc.wasmLoading);
594
- // }
595
- // });
596
- return Array.from(enabledWasmLoadingTypes);
597
- });
598
- const environment = output.environment;
599
- const optimistic = (v) => v || v === undefined;
600
- const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
601
- F(environment, "globalThis", () => tp?.globalThis);
602
- F(environment, "bigIntLiteral", () => tp && optimistic(tp.bigIntLiteral));
603
- F(environment, "const", () => tp && optimistic(tp.const));
604
- F(environment, "arrowFunction", () => tp && optimistic(tp.arrowFunction));
605
- F(environment, "asyncFunction", () => tp && optimistic(tp.asyncFunction));
606
- F(environment, "forOf", () => tp && optimistic(tp.forOf));
607
- F(environment, "destructuring", () => tp && optimistic(tp.destructuring));
608
- F(environment, "optionalChaining", () => tp && optimistic(tp.optionalChaining));
609
- F(environment, "nodePrefixForCoreModules", () => tp && optimistic(tp.nodePrefixForCoreModules));
610
- F(environment, "templateLiteral", () => tp && optimistic(tp.templateLiteral));
611
- F(environment, "dynamicImport", () => conditionallyOptimistic(tp?.dynamicImport, output.module));
612
- F(environment, "dynamicImportInWorker", () => conditionallyOptimistic(tp?.dynamicImportInWorker, output.module));
613
- F(environment, "module", () => conditionallyOptimistic(tp?.module, output.module));
614
- F(environment, "document", () => tp && optimistic(tp.document));
615
- };
616
- const applyExternalsPresetsDefaults = (externalsPresets, { targetProperties }) => {
617
- D(externalsPresets, "web", targetProperties?.web);
618
- D(externalsPresets, "node", targetProperties?.node);
619
- D(externalsPresets, "electron", targetProperties?.electron);
620
- D(externalsPresets, "electronMain", targetProperties?.electron && targetProperties.electronMain);
621
- D(externalsPresets, "electronPreload", targetProperties?.electron && targetProperties.electronPreload);
622
- D(externalsPresets, "electronRenderer", targetProperties?.electron && targetProperties.electronRenderer);
623
- D(externalsPresets, "nwjs", targetProperties?.nwjs);
624
- };
625
- const applyLoaderDefaults = (loader, { targetProperties, environment }) => {
626
- F(loader, "target", () => {
627
- if (targetProperties) {
628
- if (targetProperties.electron) {
629
- if (targetProperties.electronMain)
630
- return "electron-main";
631
- if (targetProperties.electronPreload)
632
- return "electron-preload";
633
- if (targetProperties.electronRenderer)
634
- return "electron-renderer";
635
- return "electron";
636
- }
637
- if (targetProperties.nwjs)
638
- return "nwjs";
639
- if (targetProperties.node)
640
- return "node";
641
- if (targetProperties.web)
642
- return "web";
643
- }
644
- });
645
- D(loader, "environment", environment);
646
- };
647
- const applyNodeDefaults = (node, { outputModule, targetProperties }) => {
648
- if (node === false)
649
- return;
650
- // IGNORE(node.global): The default value of `global` is determined by `futureDefaults` in webpack.
651
- F(node, "global", () => {
652
- if (targetProperties?.global)
653
- return false;
654
- return "warn";
655
- });
656
- // IGNORE(node.__dirname): The default value of `__dirname` is determined by `futureDefaults` in webpack.
657
- F(node, "__dirname", () => {
658
- if (targetProperties?.node)
659
- return outputModule ? "node-module" : "eval-only";
660
- return "warn-mock";
661
- });
662
- // IGNORE(node.__filename): The default value of `__filename` is determined by `futureDefaults` in webpack.
663
- F(node, "__filename", () => {
664
- if (targetProperties?.node)
665
- return outputModule ? "node-module" : "eval-only";
666
- return "warn-mock";
667
- });
668
- };
669
- const applyPerformanceDefaults = (performance, { production }) => {
670
- if (performance === false)
671
- return;
672
- D(performance, "maxAssetSize", 250000);
673
- D(performance, "maxEntrypointSize", 250000);
674
- F(performance, "hints", () => (production ? "warning" : false));
675
- };
676
- const applyOptimizationDefaults = (optimization, { production, development, css }) => {
677
- D(optimization, "removeAvailableModules", false);
678
- D(optimization, "removeEmptyChunks", true);
679
- D(optimization, "mergeDuplicateChunks", true);
680
- F(optimization, "moduleIds", () => {
681
- if (production)
682
- return "deterministic";
683
- if (development)
684
- return "named";
685
- return "natural";
686
- });
687
- F(optimization, "chunkIds", () => {
688
- if (production)
689
- return "deterministic";
690
- if (development)
691
- return "named";
692
- return "natural";
693
- });
694
- F(optimization, "sideEffects", () => (production ? true : "flag"));
695
- D(optimization, "mangleExports", production);
696
- D(optimization, "providedExports", true);
697
- D(optimization, "usedExports", production);
698
- D(optimization, "innerGraph", production);
699
- D(optimization, "emitOnErrors", !production);
700
- D(optimization, "runtimeChunk", false);
701
- D(optimization, "realContentHash", production);
702
- D(optimization, "minimize", production);
703
- D(optimization, "concatenateModules", production);
704
- // IGNORE(optimization.minimizer): Rspack use `SwcJsMinimizerRspackPlugin` and `LightningCssMinimizerRspackPlugin` by default
705
- A(optimization, "minimizer", () => [
706
- new builtin_plugin_1.SwcJsMinimizerRspackPlugin(),
707
- new builtin_plugin_1.LightningCssMinimizerRspackPlugin()
708
- ]);
709
- F(optimization, "nodeEnv", () => {
710
- if (production)
711
- return "production";
712
- if (development)
713
- return "development";
714
- return false;
715
- });
716
- const { splitChunks } = optimization;
717
- if (splitChunks) {
718
- // IGNORE(optimization.splitChunks.defaultSizeTypes): Rspack enables `experiments.css` by default currently
719
- A(splitChunks, "defaultSizeTypes", () => css ? ["javascript", "css", "unknown"] : ["javascript", "unknown"]);
720
- D(splitChunks, "hidePathInfo", production);
721
- D(splitChunks, "chunks", "async");
722
- D(splitChunks, "usedExports", optimization.usedExports === true);
723
- D(splitChunks, "minChunks", 1);
724
- F(splitChunks, "minSize", () => (production ? 20000 : 10000));
725
- // F(splitChunks, "minRemainingSize", () => (development ? 0 : undefined));
726
- // F(splitChunks, "enforceSizeThreshold", () => (production ? 50000 : 30000));
727
- F(splitChunks, "maxAsyncRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
728
- F(splitChunks, "maxInitialRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
729
- D(splitChunks, "automaticNameDelimiter", "-");
730
- const { cacheGroups } = splitChunks;
731
- if (cacheGroups) {
732
- F(cacheGroups, "default", () => ({
733
- idHint: "",
734
- reuseExistingChunk: true,
735
- minChunks: 2,
736
- priority: -20
737
- }));
738
- F(cacheGroups, "defaultVendors", () => ({
739
- idHint: "vendors",
740
- reuseExistingChunk: true,
741
- test: /[\\/]node_modules[\\/]/i,
742
- priority: -10
743
- }));
744
- }
745
- }
746
- };
747
- const getResolveLoaderDefaults = () => {
748
- const resolveOptions = {
749
- conditionNames: ["loader", "require", "node"],
750
- exportsFields: ["exports"],
751
- mainFields: ["loader", "main"],
752
- extensions: [".js"],
753
- mainFiles: ["index"]
754
- };
755
- return resolveOptions;
756
- };
757
- // The values are aligned with webpack
758
- // https://github.com/webpack/webpack/blob/b9fb99c63ca433b24233e0bbc9ce336b47872c08/lib/config/defaults.js#L1431
759
- const getResolveDefaults = ({ context, targetProperties, mode, css }) => {
760
- const conditions = ["webpack"];
761
- conditions.push(mode === "development" ? "development" : "production");
762
- if (targetProperties) {
763
- if (targetProperties.webworker)
764
- conditions.push("worker");
765
- if (targetProperties.node)
766
- conditions.push("node");
767
- if (targetProperties.web)
768
- conditions.push("browser");
769
- if (targetProperties.electron)
770
- conditions.push("electron");
771
- if (targetProperties.nwjs)
772
- conditions.push("nwjs");
773
- }
774
- const jsExtensions = [".js", ".json", ".wasm"];
775
- const tp = targetProperties;
776
- const browserField = tp?.web && (!tp.node || (tp.electron && tp.electronRenderer));
777
- const aliasFields = browserField ? ["browser"] : [];
778
- const mainFields = browserField
779
- ? ["browser", "module", "..."]
780
- : ["module", "..."];
781
- const cjsDeps = () => ({
782
- aliasFields,
783
- mainFields,
784
- conditionNames: ["require", "module", "..."],
785
- extensions: [...jsExtensions]
786
- });
787
- const esmDeps = () => ({
788
- aliasFields,
789
- mainFields,
790
- conditionNames: ["import", "module", "..."],
791
- extensions: [...jsExtensions]
792
- });
793
- const resolveOptions = {
794
- modules: ["node_modules"],
795
- conditionNames: conditions,
796
- mainFiles: ["index"],
797
- extensions: [],
798
- aliasFields: [],
799
- exportsFields: ["exports"],
800
- roots: [context],
801
- mainFields: ["main"],
802
- importsFields: ["imports"],
803
- byDependency: {
804
- wasm: esmDeps(),
805
- esm: esmDeps(),
806
- url: {
807
- preferRelative: true
808
- },
809
- worker: {
810
- ...esmDeps(),
811
- preferRelative: true
812
- },
813
- commonjs: cjsDeps(),
814
- // amd: cjsDeps(),
815
- // for backward-compat: loadModule
816
- // loader: cjsDeps(),
817
- // for backward-compat: Custom Dependency and getResolve without dependencyType
818
- unknown: cjsDeps()
819
- }
820
- };
821
- if (css) {
822
- const styleConditions = [];
823
- styleConditions.push("webpack");
824
- styleConditions.push(mode === "development" ? "development" : "production");
825
- styleConditions.push("style");
826
- // IGNORE(resolve.byDependency.css-import): Rspack enables `experiments.css` by default currently
827
- resolveOptions.byDependency["css-import"] = {
828
- // We avoid using any main files because we have to be consistent with CSS `@import`
829
- // and CSS `@import` does not handle `main` files in directories,
830
- // you should always specify the full URL for styles
831
- mainFiles: [],
832
- mainFields: ["style", "..."],
833
- conditionNames: styleConditions,
834
- extensions: [".css"],
835
- preferRelative: true
836
- };
837
- }
838
- return resolveOptions;
839
- };
840
- const D = (obj, prop, value) => {
841
- if (obj[prop] === undefined) {
842
- obj[prop] = value;
843
- }
844
- };
845
- const F = (obj, prop, factory) => {
846
- if (obj[prop] === undefined) {
847
- obj[prop] = factory();
848
- }
849
- };
850
- const A = (obj, prop, factory) => {
851
- const value = obj[prop];
852
- if (value === undefined) {
853
- obj[prop] = factory();
854
- }
855
- else if (Array.isArray(value)) {
856
- let newArray = undefined;
857
- for (let i = 0; i < value.length; i++) {
858
- const item = value[i];
859
- if (item === "...") {
860
- if (newArray === undefined) {
861
- newArray = value.slice(0, i);
862
- obj[prop] = newArray;
863
- }
864
- const items = factory();
865
- if (items !== undefined) {
866
- for (const item of items) {
867
- newArray.push(item);
868
- }
869
- }
870
- }
871
- else if (newArray !== undefined) {
872
- newArray.push(item);
873
- }
874
- }
875
- }
876
- };