@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
@@ -1,330 +0,0 @@
1
- "use strict";
2
- /*
3
- MIT License http://www.opensource.org/licenses/mit-license.php
4
- */
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getUndoPath = exports.parseResourceWithoutFragment = exports.parseResource = exports.absolutify = exports.contextify = exports.makePathsAbsolute = exports.makePathsRelative = void 0;
10
- const node_path_1 = __importDefault(require("node:path"));
11
- const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
12
- const SEGMENTS_SPLIT_REGEXP = /([|!])/;
13
- const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
14
- const relativePathToRequest = (relativePath) => {
15
- if (relativePath === "")
16
- return "./.";
17
- if (relativePath === "..")
18
- return "../.";
19
- if (relativePath.startsWith("../"))
20
- return relativePath;
21
- return `./${relativePath}`;
22
- };
23
- /**
24
- * @param {string} context context for relative path
25
- * @param {string} maybeAbsolutePath path to make relative
26
- * @returns {string} relative path in request style
27
- */
28
- const absoluteToRequest = (context, maybeAbsolutePath) => {
29
- if (maybeAbsolutePath[0] === "/") {
30
- if (maybeAbsolutePath.length > 1 &&
31
- maybeAbsolutePath[maybeAbsolutePath.length - 1] === "/") {
32
- // this 'path' is actually a regexp generated by dynamic requires.
33
- // Don't treat it as an absolute path.
34
- return maybeAbsolutePath;
35
- }
36
- const querySplitPos = maybeAbsolutePath.indexOf("?");
37
- let resource = querySplitPos === -1
38
- ? maybeAbsolutePath
39
- : maybeAbsolutePath.slice(0, querySplitPos);
40
- resource = relativePathToRequest(node_path_1.default.posix.relative(context, resource));
41
- return querySplitPos === -1
42
- ? resource
43
- : resource + maybeAbsolutePath.slice(querySplitPos);
44
- }
45
- if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) {
46
- const querySplitPos = maybeAbsolutePath.indexOf("?");
47
- let resource = querySplitPos === -1
48
- ? maybeAbsolutePath
49
- : maybeAbsolutePath.slice(0, querySplitPos);
50
- resource = node_path_1.default.win32.relative(context, resource);
51
- if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {
52
- resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"));
53
- }
54
- return querySplitPos === -1
55
- ? resource
56
- : resource + maybeAbsolutePath.slice(querySplitPos);
57
- }
58
- // not an absolute path
59
- return maybeAbsolutePath;
60
- };
61
- /**
62
- * @param {string} context context for relative path
63
- * @param {string} relativePath path
64
- * @returns {string} absolute path
65
- */
66
- const requestToAbsolute = (context, relativePath) => {
67
- if (relativePath.startsWith("./") || relativePath.startsWith("../"))
68
- return node_path_1.default.join(context, relativePath);
69
- return relativePath;
70
- };
71
- const makeCacheable = (realFn) => {
72
- const cache = new WeakMap();
73
- const getCache = (associatedObjectForCache) => {
74
- const entry = cache.get(associatedObjectForCache);
75
- if (entry !== undefined)
76
- return entry;
77
- const map = new Map();
78
- cache.set(associatedObjectForCache, map);
79
- return map;
80
- };
81
- const fn = (str, associatedObjectForCache) => {
82
- if (!associatedObjectForCache)
83
- return realFn(str);
84
- const cache = getCache(associatedObjectForCache);
85
- const entry = cache.get(str);
86
- if (entry !== undefined)
87
- return entry;
88
- const result = realFn(str);
89
- cache.set(str, result);
90
- return result;
91
- };
92
- fn.bindCache = (associatedObjectForCache) => {
93
- const cache = getCache(associatedObjectForCache);
94
- return (str) => {
95
- const entry = cache.get(str);
96
- if (entry !== undefined)
97
- return entry;
98
- const result = realFn(str);
99
- cache.set(str, result);
100
- return result;
101
- };
102
- };
103
- return fn;
104
- };
105
- const makeCacheableWithContext = (fn) => {
106
- const cache = new WeakMap();
107
- /**
108
- * @param {string} context context used to create relative path
109
- * @param {string} identifier identifier used to create relative path
110
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
111
- * @returns {string} the returned relative path
112
- */
113
- const cachedFn = (context, identifier, associatedObjectForCache) => {
114
- if (!associatedObjectForCache)
115
- return fn(context, identifier);
116
- /** @type {Map<string, Map<string, string>> | undefined} */
117
- let innerCache = cache.get(associatedObjectForCache);
118
- if (innerCache === undefined) {
119
- innerCache = new Map();
120
- cache.set(associatedObjectForCache, innerCache);
121
- }
122
- let cachedResult;
123
- let innerSubCache = innerCache.get(context);
124
- if (innerSubCache === undefined) {
125
- innerCache.set(context, (innerSubCache = new Map()));
126
- }
127
- else {
128
- cachedResult = innerSubCache.get(identifier);
129
- }
130
- if (cachedResult !== undefined) {
131
- return cachedResult;
132
- }
133
- const result = fn(context, identifier);
134
- innerSubCache.set(identifier, result);
135
- return result;
136
- };
137
- /**
138
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
139
- * @returns {function(string, string): string} cached function
140
- */
141
- cachedFn.bindCache = (associatedObjectForCache) => {
142
- let innerCache;
143
- if (associatedObjectForCache) {
144
- innerCache = cache.get(associatedObjectForCache);
145
- if (innerCache === undefined) {
146
- innerCache = new Map();
147
- cache.set(associatedObjectForCache, innerCache);
148
- }
149
- }
150
- else {
151
- innerCache = new Map();
152
- }
153
- /**
154
- * @param {string} context context used to create relative path
155
- * @param {string} identifier identifier used to create relative path
156
- * @returns {string} the returned relative path
157
- */
158
- const boundFn = (context, identifier) => {
159
- let cachedResult;
160
- let innerSubCache = innerCache?.get(context);
161
- if (innerSubCache === undefined) {
162
- innerSubCache = new Map();
163
- innerCache?.set(context, innerSubCache);
164
- }
165
- else {
166
- cachedResult = innerSubCache.get(identifier);
167
- }
168
- if (cachedResult !== undefined) {
169
- return cachedResult;
170
- }
171
- const result = fn(context, identifier);
172
- innerSubCache.set(identifier, result);
173
- return result;
174
- };
175
- return boundFn;
176
- };
177
- /**
178
- * @param {string} context context used to create relative path
179
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
180
- * @returns {function(string): string} cached function
181
- */
182
- cachedFn.bindContextCache = (context, associatedObjectForCache) => {
183
- let innerSubCache;
184
- if (associatedObjectForCache) {
185
- let innerCache = cache.get(associatedObjectForCache);
186
- if (innerCache === undefined) {
187
- innerCache = new Map();
188
- cache.set(associatedObjectForCache, innerCache);
189
- }
190
- innerSubCache = innerCache.get(context);
191
- if (innerSubCache === undefined) {
192
- innerCache.set(context, (innerSubCache = new Map()));
193
- }
194
- }
195
- else {
196
- innerSubCache = new Map();
197
- }
198
- /**
199
- * @param {string} identifier identifier used to create relative path
200
- * @returns {string} the returned relative path
201
- */
202
- const boundFn = (identifier) => {
203
- const cachedResult = innerSubCache?.get(identifier);
204
- if (cachedResult !== undefined) {
205
- return cachedResult;
206
- }
207
- const result = fn(context, identifier);
208
- innerSubCache?.set(identifier, result);
209
- return result;
210
- };
211
- return boundFn;
212
- };
213
- return cachedFn;
214
- };
215
- /**
216
- *
217
- * @param {string} context context for relative path
218
- * @param {string} identifier identifier for path
219
- * @returns {string} a converted relative path
220
- */
221
- const _makePathsRelative = (context, identifier) => {
222
- return identifier
223
- .split(SEGMENTS_SPLIT_REGEXP)
224
- .map(str => absoluteToRequest(context, str))
225
- .join("");
226
- };
227
- exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
228
- /**
229
- *
230
- * @param {string} context context for relative path
231
- * @param {string} identifier identifier for path
232
- * @returns {string} a converted relative path
233
- */
234
- const _makePathsAbsolute = (context, identifier) => {
235
- return identifier
236
- .split(SEGMENTS_SPLIT_REGEXP)
237
- .map(str => requestToAbsolute(context, str))
238
- .join("");
239
- };
240
- exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
241
- /**
242
- * @param {string} context absolute context path
243
- * @param {string} request any request string may containing absolute paths, query string, etc.
244
- * @returns {string} a new request string avoiding absolute paths when possible
245
- */
246
- const _contextify = (context, request) => {
247
- return request
248
- .split("!")
249
- .map(r => absoluteToRequest(context, r))
250
- .join("!");
251
- };
252
- exports.contextify = makeCacheableWithContext(_contextify);
253
- /**
254
- * @param {string} context absolute context path
255
- * @param {string} request any request string
256
- * @returns {string} a new request string using absolute paths when possible
257
- */
258
- const _absolutify = (context, request) => {
259
- return request
260
- .split("!")
261
- .map(r => requestToAbsolute(context, r))
262
- .join("!");
263
- };
264
- exports.absolutify = makeCacheableWithContext(_absolutify);
265
- const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
266
- const PATH_QUERY_REGEXP = /^((?:\u200b.|[^?\u200b])*)(\?.*)?$/;
267
- /**
268
- * @param {string} str the path with query and fragment
269
- * @returns {ParsedResource} parsed parts
270
- */
271
- const _parseResource = (str) => {
272
- const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
273
- return {
274
- resource: str,
275
- path: match[1].replace(/\u200b(.)/g, "$1"),
276
- query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : "",
277
- fragment: match[3] || ""
278
- };
279
- };
280
- exports.parseResource = makeCacheable(_parseResource);
281
- /**
282
- * Parse resource, skips fragment part
283
- * @param {string} str the path with query and fragment
284
- * @returns {ParsedResourceWithoutFragment} parsed parts
285
- */
286
- const _parseResourceWithoutFragment = (str) => {
287
- const match = PATH_QUERY_REGEXP.exec(str);
288
- return {
289
- resource: str,
290
- path: match[1].replace(/\u200b(.)/g, "$1"),
291
- query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : ""
292
- };
293
- };
294
- exports.parseResourceWithoutFragment = makeCacheable(_parseResourceWithoutFragment);
295
- /**
296
- * @param filename the filename which should be undone
297
- * @param outputPath the output path that is restored (only relevant when filename contains "..")
298
- * @param enforceRelative true returns ./ for empty paths
299
- * @returns repeated ../ to leave the directory of the provided filename to be back on output dir
300
- */
301
- const getUndoPath = (filename, outputPath, enforceRelative) => {
302
- let depth = -1;
303
- let append = "";
304
- let path = outputPath.replace(/[\\/]$/, "");
305
- for (const part of filename.split(/[/\\]+/)) {
306
- if (part === "..") {
307
- if (depth > -1) {
308
- depth--;
309
- }
310
- else {
311
- const i = path.lastIndexOf("/");
312
- const j = path.lastIndexOf("\\");
313
- const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
314
- if (pos < 0)
315
- return `${path}/`;
316
- append = `${path.slice(pos + 1)}/${append}`;
317
- path = path.slice(0, pos);
318
- }
319
- }
320
- else if (part !== ".") {
321
- depth++;
322
- }
323
- }
324
- return depth > 0
325
- ? `${"../".repeat(depth)}${append}`
326
- : enforceRelative
327
- ? `./${append}`
328
- : append;
329
- };
330
- exports.getUndoPath = getUndoPath;
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsupported = exports.deprecatedWarn = exports.asArray = exports.stringifyLoaderObject = exports.indent = exports.concatErrorMsgAndStack = exports.isJsStatsError = exports.isPromiseLike = exports.serializeObject = exports.toObject = exports.toBuffer = exports.isNil = exports.mapValues = void 0;
4
- function mapValues(record, fn) {
5
- return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, fn(value)]));
6
- }
7
- exports.mapValues = mapValues;
8
- function isNil(value) {
9
- return value === null || value === undefined;
10
- }
11
- exports.isNil = isNil;
12
- const toBuffer = (bufLike) => {
13
- if (Buffer.isBuffer(bufLike)) {
14
- return bufLike;
15
- }
16
- if (typeof bufLike === "string") {
17
- return Buffer.from(bufLike);
18
- }
19
- throw new Error("Buffer or string expected");
20
- };
21
- exports.toBuffer = toBuffer;
22
- const toObject = (input) => {
23
- let s;
24
- if (Buffer.isBuffer(input)) {
25
- s = input.toString("utf8");
26
- }
27
- else if (input && typeof input === "object") {
28
- return input;
29
- }
30
- else if (typeof input === "string") {
31
- s = input;
32
- }
33
- else {
34
- throw new Error("Buffer or string or object expected");
35
- }
36
- return JSON.parse(s);
37
- };
38
- exports.toObject = toObject;
39
- function serializeObject(map) {
40
- if (isNil(map)) {
41
- return undefined;
42
- }
43
- if (typeof map === "string") {
44
- if (map) {
45
- return (0, exports.toBuffer)(map);
46
- }
47
- return undefined;
48
- }
49
- return (0, exports.toBuffer)(JSON.stringify(map));
50
- }
51
- exports.serializeObject = serializeObject;
52
- function isPromiseLike(value) {
53
- return (typeof value === "object" &&
54
- value !== null &&
55
- typeof value.then === "function");
56
- }
57
- exports.isPromiseLike = isPromiseLike;
58
- function isJsStatsError(err) {
59
- return !(err instanceof Error) && err.formatted;
60
- }
61
- exports.isJsStatsError = isJsStatsError;
62
- function concatErrorMsgAndStack(err) {
63
- if (typeof err === "string") {
64
- return new Error(err);
65
- }
66
- const hideStack = "hideStack" in err && err.hideStack;
67
- if (!hideStack && "stack" in err) {
68
- // This is intended to be different than webpack,
69
- // here we want to treat the almost the same as `Error.stack` just without the stack.
70
- // Webpack uses `Error.message`, however it does not contain the `Error.prototype.name`
71
- // `xxx` -> `Error: xxx`. So they behave the same even if `hideStack` is set to `true`.
72
- err.message = err.stack || err.toString();
73
- }
74
- else {
75
- // This is intended to be different than webpack,
76
- // here we want to treat the almost the same as `Error.stack` just without the stack.
77
- // Webpack uses `Error.message`, however it does not contain the `Error.prototype.name`
78
- // `xxx` -> `Error: xxx`. So they behave the same even if `hideStack` is set to `true`.
79
- err.message = err.toString();
80
- }
81
- // maybe `null`, use `undefined` to compatible with `Option<String>`
82
- err.stack = err.stack || undefined;
83
- return err;
84
- }
85
- exports.concatErrorMsgAndStack = concatErrorMsgAndStack;
86
- function indent(str, prefix) {
87
- const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
88
- return prefix + rem;
89
- }
90
- exports.indent = indent;
91
- function stringifyLoaderObject(o) {
92
- return o.path + o.query + o.fragment;
93
- }
94
- exports.stringifyLoaderObject = stringifyLoaderObject;
95
- function asArray(item) {
96
- return Array.isArray(item) ? item : [item];
97
- }
98
- exports.asArray = asArray;
99
- const getDeprecationStatus = () => {
100
- const defaultEnableDeprecatedWarning = true;
101
- if (process.env.RSPACK_DEP_WARNINGS === "false" ||
102
- process.env.RSPACK_DEP_WARNINGS === "0") {
103
- return false;
104
- }
105
- return ((process.env.RSPACK_DEP_WARNINGS ?? `${defaultEnableDeprecatedWarning}`) !==
106
- "false");
107
- };
108
- const yellow = (content) => `\u001b[1m\u001b[33m${content}\u001b[39m\u001b[22m`;
109
- const deprecatedWarn = (content, enable = getDeprecationStatus()) => {
110
- if (enable) {
111
- console.warn(yellow(content));
112
- console.warn(indent("Set env `RSPACK_DEP_WARNINGS` to 'false' to temporarily disable deprecation warnings.\n", " "));
113
- }
114
- };
115
- exports.deprecatedWarn = deprecatedWarn;
116
- const unsupported = (name, issue) => {
117
- let s = `${name} is not supported by rspack.`;
118
- if (issue) {
119
- s += ` Please refer to issue ${issue} for more information.`;
120
- }
121
- throw new Error(s);
122
- };
123
- exports.unsupported = unsupported;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.memoizeValue = exports.memoizeFn = exports.memoize = void 0;
4
- const memoize = (fn) => {
5
- let cache = false;
6
- let result;
7
- let callback = fn;
8
- return () => {
9
- if (cache) {
10
- return result;
11
- }
12
- result = callback();
13
- cache = true;
14
- // Allow to clean up memory for fn
15
- // and all dependent resources
16
- callback = undefined;
17
- return result;
18
- };
19
- };
20
- exports.memoize = memoize;
21
- // Lazily init a function, and cache it afterwards.
22
- const memoizeFn = (fn) => {
23
- let cache = null;
24
- return (...args) => {
25
- if (!cache) {
26
- cache = fn();
27
- }
28
- return cache(...args);
29
- };
30
- };
31
- exports.memoizeFn = memoizeFn;
32
- function memoizeValue(fn) {
33
- const getValue = (0, exports.memoize)(fn);
34
- return new Proxy({}, {
35
- get(_, property) {
36
- let res = getValue()[property];
37
- if (typeof res === "function") {
38
- res = res.bind(getValue());
39
- }
40
- return res;
41
- },
42
- set(_, property, newValue) {
43
- getValue()[property] = newValue;
44
- return true;
45
- },
46
- deleteProperty(_, property) {
47
- const value = getValue();
48
- return delete value[property];
49
- },
50
- has: (_, property) => {
51
- return property in getValue();
52
- },
53
- ownKeys: _ => {
54
- return Object.keys(getValue());
55
- },
56
- getOwnPropertyDescriptor(_, property) {
57
- return Object.getOwnPropertyDescriptor(getValue(), property);
58
- }
59
- });
60
- }
61
- exports.memoizeValue = memoizeValue;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getScheme = void 0;
4
- const backSlashCharCode = "\\".charCodeAt(0);
5
- const slashCharCode = "/".charCodeAt(0);
6
- const aLowerCaseCharCode = "a".charCodeAt(0);
7
- const zLowerCaseCharCode = "z".charCodeAt(0);
8
- const aUpperCaseCharCode = "A".charCodeAt(0);
9
- const zUpperCaseCharCode = "Z".charCodeAt(0);
10
- const _0CharCode = "0".charCodeAt(0);
11
- const _9CharCode = "9".charCodeAt(0);
12
- const plusCharCode = "+".charCodeAt(0);
13
- const hyphenCharCode = "-".charCodeAt(0);
14
- const colonCharCode = ":".charCodeAt(0);
15
- const hashCharCode = "#".charCodeAt(0);
16
- const queryCharCode = "?".charCodeAt(0);
17
- /**
18
- * Get scheme if specifier is an absolute URL specifier
19
- * e.g. Absolute specifiers like 'file:///user/webpack/index.js'
20
- * https://tools.ietf.org/html/rfc3986#section-3.1
21
- */
22
- function getScheme(specifier) {
23
- const start = specifier.charCodeAt(0);
24
- // First char maybe only a letter
25
- if ((start < aLowerCaseCharCode || start > zLowerCaseCharCode) &&
26
- (start < aUpperCaseCharCode || start > zUpperCaseCharCode)) {
27
- return undefined;
28
- }
29
- let i = 1;
30
- let ch = specifier.charCodeAt(i);
31
- while ((ch >= aLowerCaseCharCode && ch <= zLowerCaseCharCode) ||
32
- (ch >= aUpperCaseCharCode && ch <= zUpperCaseCharCode) ||
33
- (ch >= _0CharCode && ch <= _9CharCode) ||
34
- ch === plusCharCode ||
35
- ch === hyphenCharCode) {
36
- if (++i === specifier.length)
37
- return undefined;
38
- ch = specifier.charCodeAt(i);
39
- }
40
- // Scheme must end with colon
41
- if (ch !== colonCharCode)
42
- return undefined;
43
- // Check for Windows absolute path
44
- // https://url.spec.whatwg.org/#url-miscellaneous
45
- if (i === 1) {
46
- const nextChar = i + 1 < specifier.length ? specifier.charCodeAt(i + 1) : 0;
47
- if (nextChar === 0 ||
48
- nextChar === backSlashCharCode ||
49
- nextChar === slashCharCode ||
50
- nextChar === hashCharCode ||
51
- nextChar === queryCharCode) {
52
- return undefined;
53
- }
54
- }
55
- return specifier.slice(0, i).toLowerCase();
56
- }
57
- exports.getScheme = getScheme;