@rspack/core 1.0.9 → 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.
Files changed (219) hide show
  1. package/dist/Dependency.d.ts +7 -6
  2. package/dist/Module.d.ts +19 -17
  3. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  4. package/dist/config/types.d.ts +545 -0
  5. package/dist/config/zod.d.ts +202 -1347
  6. package/dist/cssExtractHmr.js +224 -0
  7. package/dist/cssExtractLoader.js +277 -0
  8. package/dist/index.js +23347 -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 -920
  29. package/dist/ContextModuleFactory.js +0 -36
  30. package/dist/DependenciesBlock.js +0 -30
  31. package/dist/Dependency.js +0 -32
  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 -143
  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 -1028
  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
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/runtime/cssExtractHmr.ts
21
+ var cssExtractHmr_exports = {};
22
+ __export(cssExtractHmr_exports, {
23
+ cssReload: () => cssReload,
24
+ normalizeUrl: () => normalizeUrl
25
+ });
26
+ module.exports = __toCommonJS(cssExtractHmr_exports);
27
+ function normalizeUrl(url) {
28
+ const urlString = url.trim();
29
+ if (/^data:/i.test(urlString)) {
30
+ return urlString;
31
+ }
32
+ const protocol = urlString.indexOf("//") !== -1 ? `${urlString.split("//")[0]}//` : "";
33
+ const components = urlString.replace(new RegExp(protocol, "i"), "").split("/");
34
+ const host = components[0].toLowerCase().replace(/\.$/, "");
35
+ components[0] = "";
36
+ const path = components.reduce((accumulator, item) => {
37
+ switch (item) {
38
+ case "..":
39
+ accumulator.pop();
40
+ break;
41
+ case ".":
42
+ break;
43
+ default:
44
+ accumulator.push(item);
45
+ }
46
+ return accumulator;
47
+ }, []).join("/");
48
+ return protocol + host + path;
49
+ }
50
+ var srcByModuleId = /* @__PURE__ */ Object.create(null);
51
+ var noDocument = typeof document === "undefined";
52
+ var { forEach } = Array.prototype;
53
+ function debounce(fn, time) {
54
+ let timeout = 0;
55
+ return function(...args) {
56
+ const self = this;
57
+ const functionCall = function functionCall2() {
58
+ return fn.apply(self, args);
59
+ };
60
+ clearTimeout(timeout);
61
+ timeout = setTimeout(functionCall, time);
62
+ };
63
+ }
64
+ function noop() {
65
+ }
66
+ function getCurrentScriptUrl(moduleId) {
67
+ let src = srcByModuleId[moduleId];
68
+ if (!src) {
69
+ if (document.currentScript) {
70
+ ({ src } = document.currentScript);
71
+ } else {
72
+ const scripts = document.getElementsByTagName("script");
73
+ const lastScriptTag = scripts[scripts.length - 1];
74
+ if (lastScriptTag) {
75
+ ({ src } = lastScriptTag);
76
+ }
77
+ }
78
+ srcByModuleId[moduleId] = src;
79
+ }
80
+ return (fileMap) => {
81
+ if (!src) {
82
+ return null;
83
+ }
84
+ const splitResult = src.match(/([^\\/]+)\.js$/);
85
+ const filename = splitResult && splitResult[1];
86
+ if (!filename || !fileMap) {
87
+ return [src.replace(".js", ".css")];
88
+ }
89
+ return fileMap.split(",").map((mapRule) => {
90
+ const reg = new RegExp(`${filename}\\.js$`, "g");
91
+ return normalizeUrl(
92
+ src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`)
93
+ );
94
+ });
95
+ };
96
+ }
97
+ function updateCss(el, url) {
98
+ let normalizedUrl;
99
+ if (!url) {
100
+ if (!el.href) {
101
+ return;
102
+ }
103
+ normalizedUrl = el.href.split("?")[0];
104
+ } else {
105
+ normalizedUrl = url;
106
+ }
107
+ if (!isUrlRequest(normalizedUrl)) {
108
+ return;
109
+ }
110
+ if (el.isLoaded === false) {
111
+ return;
112
+ }
113
+ if (!normalizedUrl || !(normalizedUrl.indexOf(".css") > -1)) {
114
+ return;
115
+ }
116
+ el.visited = true;
117
+ const newEl = el.cloneNode();
118
+ newEl.isLoaded = false;
119
+ newEl.addEventListener("load", () => {
120
+ if (newEl.isLoaded) {
121
+ return;
122
+ }
123
+ newEl.isLoaded = true;
124
+ if (el.parentNode) {
125
+ el.parentNode.removeChild(el);
126
+ }
127
+ });
128
+ newEl.addEventListener("error", () => {
129
+ if (newEl.isLoaded) {
130
+ return;
131
+ }
132
+ newEl.isLoaded = true;
133
+ if (el.parentNode) {
134
+ el.parentNode.removeChild(el);
135
+ }
136
+ });
137
+ newEl.href = `${normalizedUrl}?${Date.now()}`;
138
+ const parent = el.parentNode;
139
+ if (!parent) {
140
+ return;
141
+ }
142
+ if (el.nextSibling) {
143
+ parent.insertBefore(newEl, el.nextSibling);
144
+ } else {
145
+ parent.appendChild(newEl);
146
+ }
147
+ }
148
+ function getReloadUrl(href, src) {
149
+ let ret = "";
150
+ const normalizedHref = normalizeUrl(href);
151
+ src.some((url) => {
152
+ if (normalizedHref.indexOf(src) > -1) {
153
+ ret = url;
154
+ }
155
+ });
156
+ return ret;
157
+ }
158
+ function reloadStyle(src) {
159
+ if (!src) {
160
+ return false;
161
+ }
162
+ const elements = document.querySelectorAll("link");
163
+ let loaded = false;
164
+ forEach.call(elements, (el) => {
165
+ if (!el.href) {
166
+ return;
167
+ }
168
+ const url = getReloadUrl(el.href, src);
169
+ if (!isUrlRequest(url)) {
170
+ return;
171
+ }
172
+ if (el.visited === true) {
173
+ return;
174
+ }
175
+ if (url) {
176
+ updateCss(el, url);
177
+ loaded = true;
178
+ }
179
+ });
180
+ return loaded;
181
+ }
182
+ function reloadAll() {
183
+ const elements = document.querySelectorAll("link");
184
+ forEach.call(elements, (el) => {
185
+ if (el.visited === true) {
186
+ return;
187
+ }
188
+ updateCss(el);
189
+ });
190
+ }
191
+ function isUrlRequest(url) {
192
+ if (!/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url)) {
193
+ return false;
194
+ }
195
+ return true;
196
+ }
197
+ function cssReload(moduleId, options) {
198
+ if (noDocument) {
199
+ console.log("[HMR] No `window.document` found, CSS HMR disabled");
200
+ return noop;
201
+ }
202
+ const getScriptSrc = getCurrentScriptUrl(moduleId);
203
+ function update() {
204
+ const src = getScriptSrc(options.filename);
205
+ const reloaded = reloadStyle(src);
206
+ if (options.locals) {
207
+ console.log("[HMR] Detected local CSS Modules. Reload all CSS");
208
+ reloadAll();
209
+ return;
210
+ }
211
+ if (reloaded) {
212
+ console.log("[HMR] CSS reload %s", src && src.join(" "));
213
+ } else {
214
+ console.log("[HMR] Reload all CSS");
215
+ reloadAll();
216
+ }
217
+ }
218
+ return debounce(update, 50);
219
+ }
220
+ // Annotate the CommonJS export names for ESM import in node:
221
+ 0 && (module.exports = {
222
+ cssReload,
223
+ normalizeUrl
224
+ });
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/builtin-plugin/css-extract/loader.ts
31
+ var loader_exports = {};
32
+ __export(loader_exports, {
33
+ ABSOLUTE_PUBLIC_PATH: () => ABSOLUTE_PUBLIC_PATH,
34
+ AUTO_PUBLIC_PATH: () => AUTO_PUBLIC_PATH,
35
+ BASE_URI: () => BASE_URI,
36
+ MODULE_TYPE: () => MODULE_TYPE,
37
+ SINGLE_DOT_PATH_SEGMENT: () => SINGLE_DOT_PATH_SEGMENT,
38
+ default: () => loader_default,
39
+ hotLoader: () => hotLoader,
40
+ pitch: () => pitch
41
+ });
42
+ module.exports = __toCommonJS(loader_exports);
43
+ var import_node_path2 = __toESM(require("path"));
44
+
45
+ // src/builtin-plugin/css-extract/utils.ts
46
+ var import_node_path = __toESM(require("path"));
47
+ function isAbsolutePath(str) {
48
+ return import_node_path.default.posix.isAbsolute(str) || import_node_path.default.win32.isAbsolute(str);
49
+ }
50
+ var PLUGIN_NAME = "css-extract-rspack-plugin";
51
+ var RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/;
52
+ function isRelativePath(str) {
53
+ return RELATIVE_PATH_REGEXP.test(str);
54
+ }
55
+ function stringifyRequest(loaderContext, request) {
56
+ if (typeof loaderContext.utils !== "undefined" && typeof loaderContext.utils.contextify === "function") {
57
+ return JSON.stringify(
58
+ loaderContext.utils.contextify(
59
+ loaderContext.context || loaderContext.rootContext,
60
+ request
61
+ )
62
+ );
63
+ }
64
+ const splitted = request.split("!");
65
+ const { context } = loaderContext;
66
+ return JSON.stringify(
67
+ splitted.map((part) => {
68
+ const splittedPart = part.match(/^(.*?)(\?.*)/);
69
+ const query = splittedPart ? splittedPart[2] : "";
70
+ let singlePath = splittedPart ? splittedPart[1] : part;
71
+ if (isAbsolutePath(singlePath) && context) {
72
+ singlePath = import_node_path.default.relative(context, singlePath);
73
+ if (isAbsolutePath(singlePath)) {
74
+ return singlePath + query;
75
+ }
76
+ if (isRelativePath(singlePath) === false) {
77
+ singlePath = `./${singlePath}`;
78
+ }
79
+ }
80
+ return singlePath.replace(/\\/g, "/") + query;
81
+ }).join("!")
82
+ );
83
+ }
84
+ function stringifyLocal(value) {
85
+ return typeof value === "function" ? value.toString() : JSON.stringify(value);
86
+ }
87
+
88
+ // src/builtin-plugin/css-extract/loader.ts
89
+ var BASE_URI = "webpack://";
90
+ var MODULE_TYPE = "css/mini-extract";
91
+ var AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
92
+ var ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
93
+ var SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
94
+ function hotLoader(content, context) {
95
+ const localsJsonString = JSON.stringify(JSON.stringify(context.locals));
96
+ return `${content}
97
+ if(module.hot) {
98
+ (function() {
99
+ var localsJsonString = ${localsJsonString};
100
+ // ${Date.now()}
101
+ var cssReload = require(${stringifyRequest(
102
+ context.loaderContext,
103
+ import_node_path2.default.join(__dirname, "cssExtractHmr.js")
104
+ )}).cssReload(module.id, ${JSON.stringify(context.options ?? {})});
105
+ // only invalidate when locals change
106
+ if (
107
+ module.hot.data &&
108
+ module.hot.data.value &&
109
+ module.hot.data.value !== localsJsonString
110
+ ) {
111
+ module.hot.invalidate();
112
+ } else {
113
+ module.hot.accept();
114
+ }
115
+ module.hot.dispose(function(data) {
116
+ data.value = localsJsonString;
117
+ cssReload();
118
+ });
119
+ })();
120
+ }
121
+ `;
122
+ }
123
+ var loader = function loader2(content) {
124
+ var _a, _b, _c;
125
+ if (((_c = (_b = (_a = this._compiler) == null ? void 0 : _a.options) == null ? void 0 : _b.experiments) == null ? void 0 : _c.css) && this._module && (this._module.type === "css" || this._module.type === "css/auto" || this._module.type === "css/global" || this._module.type === "css/module")) {
126
+ return content;
127
+ }
128
+ };
129
+ var pitch = function(request, _, data) {
130
+ var _a, _b, _c;
131
+ if (((_c = (_b = (_a = this._compiler) == null ? void 0 : _a.options) == null ? void 0 : _b.experiments) == null ? void 0 : _c.css) && this._module && (this._module.type === "css" || this._module.type === "css/auto" || this._module.type === "css/global" || this._module.type === "css/module")) {
132
+ const e = new Error(
133
+ `use type 'css' and \`CssExtractRspackPlugin\` together, please set \`experiments.css\` to \`false\` or set \`{ type: "javascript/auto" }\` for rules with \`CssExtractRspackPlugin\` in your rspack config (now \`CssExtractRspackPlugin\` does nothing).`
134
+ );
135
+ e.stack = void 0;
136
+ this.emitWarning(e);
137
+ return;
138
+ }
139
+ const options = this.getOptions();
140
+ const emit = typeof options.emit !== "undefined" ? options.emit : true;
141
+ const callback = this.async();
142
+ const filepath = this.resourcePath;
143
+ const parseMeta = this.__internal__parseMeta;
144
+ let { publicPath } = this._compilation.outputOptions;
145
+ if (typeof options.publicPath === "string") {
146
+ publicPath = options.publicPath;
147
+ } else if (typeof options.publicPath === "function") {
148
+ publicPath = options.publicPath(this.resourcePath, this.rootContext);
149
+ }
150
+ if (publicPath === "auto") {
151
+ publicPath = AUTO_PUBLIC_PATH;
152
+ }
153
+ let publicPathForExtract;
154
+ if (typeof publicPath === "string") {
155
+ const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
156
+ publicPathForExtract = isAbsolutePublicPath ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(
157
+ /\./g,
158
+ SINGLE_DOT_PATH_SEGMENT
159
+ )}`;
160
+ } else {
161
+ publicPathForExtract = publicPath;
162
+ }
163
+ const handleExports = (originalExports) => {
164
+ let locals;
165
+ let namedExport;
166
+ const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
167
+ let dependencies = [];
168
+ try {
169
+ const exports2 = originalExports.__esModule ? originalExports.default : originalExports;
170
+ namedExport = // eslint-disable-next-line no-underscore-dangle
171
+ originalExports.__esModule && (!originalExports.default || !("locals" in originalExports.default));
172
+ if (namedExport) {
173
+ for (const key of Object.keys(originalExports)) {
174
+ if (key !== "default") {
175
+ if (!locals) {
176
+ locals = {};
177
+ }
178
+ locals[key] = originalExports[key];
179
+ }
180
+ }
181
+ } else {
182
+ locals = exports2 == null ? void 0 : exports2.locals;
183
+ }
184
+ if (Array.isArray(exports2) && emit) {
185
+ const identifierCountMap = /* @__PURE__ */ new Map();
186
+ dependencies = exports2.map(([id, content, media, sourceMap, supports, layer]) => {
187
+ const identifier = id;
188
+ const context = this.rootContext;
189
+ const count = identifierCountMap.get(identifier) || 0;
190
+ identifierCountMap.set(identifier, count + 1);
191
+ return {
192
+ identifier,
193
+ context,
194
+ content,
195
+ media,
196
+ supports,
197
+ layer,
198
+ identifierIndex: count,
199
+ sourceMap: sourceMap ? JSON.stringify(sourceMap) : (
200
+ // eslint-disable-next-line no-undefined
201
+ void 0
202
+ ),
203
+ filepath
204
+ };
205
+ }).filter((item) => item !== null);
206
+ }
207
+ } catch (e) {
208
+ callback(e);
209
+ return;
210
+ }
211
+ const result = function makeResult() {
212
+ if (locals) {
213
+ if (namedExport) {
214
+ const identifiers = Array.from(
215
+ function* generateIdentifiers() {
216
+ let identifierId = 0;
217
+ for (const key of Object.keys(locals)) {
218
+ identifierId += 1;
219
+ yield [`_${identifierId.toString(16)}`, key];
220
+ }
221
+ }()
222
+ );
223
+ const localsString = identifiers.map(
224
+ ([id, key]) => `
225
+ var ${id} = ${stringifyLocal(locals[key])};`
226
+ ).join("");
227
+ const exportsString = `export { ${identifiers.map(([id, key]) => `${id} as ${JSON.stringify(key)}`).join(", ")} }`;
228
+ const defaultExport = typeof options.defaultExport !== "undefined" ? options.defaultExport : false;
229
+ return defaultExport ? `${localsString}
230
+ ${exportsString}
231
+ export default { ${identifiers.map(([id, key]) => `${JSON.stringify(key)}: ${id}`).join(", ")} }
232
+ ` : `${localsString}
233
+ ${exportsString}
234
+ `;
235
+ }
236
+ return `
237
+ ${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
238
+ }
239
+ if (esModule) {
240
+ return "\nexport {};";
241
+ }
242
+ return "";
243
+ }();
244
+ let resultSource = `// extracted by ${PLUGIN_NAME}`;
245
+ resultSource += this.hot && emit ? hotLoader(result, { loaderContext: this, options, locals }) : result;
246
+ if (dependencies.length > 0) {
247
+ parseMeta[PLUGIN_NAME] = JSON.stringify(dependencies);
248
+ }
249
+ callback(null, resultSource, void 0, data);
250
+ };
251
+ this.importModule(
252
+ `${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`,
253
+ {
254
+ layer: options.layer,
255
+ publicPath: publicPathForExtract,
256
+ baseUri: `${BASE_URI}/`
257
+ },
258
+ (error, exports2) => {
259
+ if (error) {
260
+ callback(error);
261
+ return;
262
+ }
263
+ handleExports(exports2);
264
+ }
265
+ );
266
+ };
267
+ var loader_default = loader;
268
+ // Annotate the CommonJS export names for ESM import in node:
269
+ 0 && (module.exports = {
270
+ ABSOLUTE_PUBLIC_PATH,
271
+ AUTO_PUBLIC_PATH,
272
+ BASE_URI,
273
+ MODULE_TYPE,
274
+ SINGLE_DOT_PATH_SEGMENT,
275
+ hotLoader,
276
+ pitch
277
+ });