@rspack/core 1.0.0-beta.2 → 1.0.0-beta.4

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 (65) hide show
  1. package/dist/Compilation.d.ts +21 -8
  2. package/dist/Compilation.js +114 -57
  3. package/dist/Compiler.d.ts +1 -0
  4. package/dist/Compiler.js +29 -24
  5. package/dist/DependenciesBlock.d.ts +8 -0
  6. package/dist/DependenciesBlock.js +30 -0
  7. package/dist/Dependency.d.ts +8 -0
  8. package/dist/Dependency.js +32 -0
  9. package/dist/Module.d.ts +6 -3
  10. package/dist/Module.js +13 -0
  11. package/dist/MultiCompiler.js +10 -6
  12. package/dist/MultiStats.d.ts +1 -1
  13. package/dist/MultiStats.js +19 -16
  14. package/dist/NormalModule.js +3 -4
  15. package/dist/Stats.d.ts +1 -1
  16. package/dist/Template.d.ts +4 -4
  17. package/dist/Template.js +6 -4
  18. package/dist/Watching.js +3 -5
  19. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -10
  20. package/dist/builtin-plugin/DynamicEntryPlugin.js +26 -15
  21. package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
  22. package/dist/builtin-plugin/ExternalsPlugin.d.ts +4 -4
  23. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +21 -4
  24. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +29 -5
  25. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +4 -6
  26. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +16 -10
  27. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +11 -9
  28. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +28 -17
  29. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +1 -1
  30. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +2 -2
  31. package/dist/builtin-plugin/css-extract/loader.js +1 -2
  32. package/dist/config/adapter.d.ts +2 -2
  33. package/dist/config/defaults.js +9 -6
  34. package/dist/config/zod.d.ts +537 -141
  35. package/dist/config/zod.js +18 -10
  36. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  37. package/dist/exports.d.ts +4 -3
  38. package/dist/exports.js +5 -2
  39. package/dist/lib/Cache.js +6 -4
  40. package/dist/lib/CacheFacade.js +8 -9
  41. package/dist/lib/LoaderOptionsPlugin.d.ts +4 -2
  42. package/dist/lib/LoaderOptionsPlugin.js +0 -2
  43. package/dist/lib/cache/mergeEtags.d.ts +3 -3
  44. package/dist/lib/cache/mergeEtags.js +5 -3
  45. package/dist/loader-runner/index.js +4 -2
  46. package/dist/node/nodeConsole.js +5 -5
  47. package/dist/stats/DefaultStatsFactoryPlugin.d.ts +0 -10
  48. package/dist/stats/DefaultStatsFactoryPlugin.js +130 -90
  49. package/dist/stats/DefaultStatsPresetPlugin.js +17 -18
  50. package/dist/stats/StatsFactory.js +8 -10
  51. package/dist/stats/StatsPrinter.js +3 -4
  52. package/dist/stats/statsFactoryUtils.d.ts +119 -19
  53. package/dist/stats/statsFactoryUtils.js +62 -1
  54. package/dist/util/assertNotNil.d.ts +1 -1
  55. package/dist/util/assetCondition.d.ts +2 -0
  56. package/dist/util/assetCondition.js +2 -0
  57. package/dist/util/cleverMerge.js +5 -4
  58. package/dist/util/createHash.js +10 -5
  59. package/dist/util/hash/wasm-hash.js +5 -4
  60. package/dist/util/identifier.d.ts +4 -4
  61. package/dist/util/identifier.js +10 -10
  62. package/dist/util/memoize.js +3 -2
  63. package/package.json +3 -3
  64. package/dist/builtin-plugin/css-extract/loader-options.json +0 -37
  65. package/dist/builtin-plugin/css-extract/plugin-options.json +0 -79
@@ -39,12 +39,13 @@ const NAMED_PRESETS = {
39
39
  orphanModules: true,
40
40
  runtimeModules: true,
41
41
  // exclude: false,
42
- // errorsSpace: Infinity,
43
- // warningsSpace: Infinity,
42
+ excludeModules: false,
43
+ errorsSpace: Number.POSITIVE_INFINITY,
44
+ warningsSpace: Number.POSITIVE_INFINITY,
44
45
  modulesSpace: Number.POSITIVE_INFINITY,
45
- // chunkModulesSpace: Infinity,
46
+ chunkModulesSpace: Number.POSITIVE_INFINITY,
46
47
  assetsSpace: Number.POSITIVE_INFINITY,
47
- // reasonsSpace: Infinity,
48
+ reasonsSpace: Number.POSITIVE_INFINITY,
48
49
  children: true
49
50
  },
50
51
  detailed: {
@@ -66,20 +67,20 @@ const NAMED_PRESETS = {
66
67
  publicPath: true,
67
68
  logging: true,
68
69
  runtimeModules: true,
69
- // exclude: false,
70
- // errorsSpace: 1000,
71
- // warningsSpace: 1000,
70
+ excludeModules: false,
71
+ errorsSpace: 1000,
72
+ warningsSpace: 1000,
72
73
  modulesSpace: 1000,
73
- assetsSpace: 1000
74
- // reasonsSpace: 1000
74
+ assetsSpace: 1000,
75
+ reasonsSpace: 1000
75
76
  },
76
77
  minimal: {
77
78
  all: false,
78
79
  version: true,
79
80
  timings: true,
80
81
  modules: true,
81
- // errorsSpace: 0,
82
- // warningsSpace: 0,
82
+ errorsSpace: 0,
83
+ warningsSpace: 0,
83
84
  modulesSpace: 0,
84
85
  assets: true,
85
86
  assetsSpace: 0,
@@ -93,7 +94,7 @@ const NAMED_PRESETS = {
93
94
  all: false,
94
95
  errors: true,
95
96
  errorsCount: true,
96
- // errorsSpace: Infinity,
97
+ errorsSpace: Number.POSITIVE_INFINITY,
97
98
  moduleTrace: true,
98
99
  logging: "error"
99
100
  },
@@ -101,10 +102,10 @@ const NAMED_PRESETS = {
101
102
  all: false,
102
103
  errors: true,
103
104
  errorsCount: true,
104
- // errorsSpace: Infinity,
105
+ errorsSpace: Number.POSITIVE_INFINITY,
105
106
  warnings: true,
106
107
  warningsCount: true,
107
- // warningsSpace: Infinity,
108
+ warningsSpace: Number.POSITIVE_INFINITY,
108
109
  logging: "warn"
109
110
  },
110
111
  summary: {
@@ -197,7 +198,7 @@ const DEFAULTS = {
197
198
  cachedModules: ({ all, cached }, { forToString }) => cached !== undefined ? cached : forToString ? all === true : all !== false,
198
199
  moduleAssets: OFF_FOR_TO_STRING,
199
200
  depth: OFF_FOR_TO_STRING,
200
- // cachedAssets: OFF_FOR_TO_STRING,
201
+ cachedAssets: OFF_FOR_TO_STRING,
201
202
  reasons: OFF_FOR_TO_STRING,
202
203
  reasonsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
203
204
  groupReasonsByOrigin: ON_FOR_TO_STRING,
@@ -271,9 +272,7 @@ const NORMALIZER = {
271
272
  });
272
273
  },
273
274
  logging: (value) => {
274
- if (value === true)
275
- value = "log";
276
- return value;
275
+ return value === true ? "log" : value;
277
276
  },
278
277
  loggingDebug: (value) => {
279
278
  const array = !Array.isArray(value) ? (value ? [value] : []) : value;
@@ -39,12 +39,11 @@ class StatsFactory {
39
39
  ]))
40
40
  });
41
41
  const hooks = this.hooks;
42
- this._caches = Object.keys(hooks).reduce((prev, curr) => {
43
- return {
44
- ...prev,
45
- [curr]: new Map()
46
- };
47
- }, {});
42
+ const caches = {};
43
+ for (const key of Object.keys(hooks)) {
44
+ caches[key] = new Map();
45
+ }
46
+ this._caches = caches;
48
47
  this._inCreate = false;
49
48
  }
50
49
  _getAllLevelHooks(hookMap, cache, type) {
@@ -71,10 +70,9 @@ class StatsFactory {
71
70
  }
72
71
  }
73
72
  _forEachLevelWaterfall(hookMap, cache, type, data, fn) {
74
- for (const hook of this._getAllLevelHooks(hookMap, cache, type)) {
75
- data = fn(hook, data);
76
- }
77
- return data;
73
+ return this._getAllLevelHooks(hookMap, cache, type).reduce((data, hook) => {
74
+ return fn(hook, data);
75
+ }, data);
78
76
  }
79
77
  _forEachLevelFilter(hookMap, cache, type, items, fn, forceClone) {
80
78
  const hooks = this._getAllLevelHooks(hookMap, cache, type);
@@ -71,10 +71,9 @@ class StatsPrinter {
71
71
  }
72
72
  }
73
73
  _forEachLevelWaterfall(hookMap, type, data, fn) {
74
- for (const hook of this._getAllLevelHooks(hookMap, type)) {
75
- data = fn(hook, data);
76
- }
77
- return data;
74
+ return this._getAllLevelHooks(hookMap, type).reduce((data, hook) => {
75
+ return fn(hook, data);
76
+ }, data);
78
77
  }
79
78
  print(type, object, baseContext) {
80
79
  if (this._inPrint) {
@@ -1,16 +1,89 @@
1
1
  /// <reference types="node" />
2
2
  import type * as binding from "@rspack/binding";
3
+ import type { JsOriginRecord } from "@rspack/binding";
3
4
  import type { Compilation, NormalizedStatsOptions } from "../Compilation";
4
5
  import { type Comparator } from "../util/comparators";
5
6
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
6
- export type KnownStatsChunkGroup = binding.JsStatsChunkGroup;
7
- export type KnownStatsChunk = Omit<binding.JsStatsChunk, "sizes" | "origins"> & {
8
- sizes: Record<string, number>;
9
- origins: StatsChunkOrigin[];
7
+ export type KnownStatsChunkGroup = {
8
+ name?: string;
9
+ chunks?: (string | number)[];
10
+ assets?: {
11
+ name: string;
12
+ size?: number;
13
+ }[];
14
+ filteredAssets?: number;
15
+ assetsSize?: number;
16
+ auxiliaryAssets?: {
17
+ name: string;
18
+ size?: number;
19
+ }[];
20
+ filteredAuxiliaryAssets?: number;
21
+ auxiliaryAssetsSize?: number;
22
+ children?: {
23
+ preload?: StatsChunkGroup[];
24
+ prefetch?: StatsChunkGroup[];
25
+ };
26
+ childAssets?: {
27
+ preload?: string[];
28
+ prefetch?: string[];
29
+ };
30
+ isOverSizeLimit?: boolean;
31
+ };
32
+ export type KnownStatsChunk = {
33
+ type: string;
34
+ rendered: boolean;
35
+ initial: boolean;
36
+ entry: boolean;
37
+ reason?: string;
38
+ size: number;
39
+ sizes?: Record<string, number>;
40
+ names?: string[];
41
+ idHints?: string[];
42
+ runtime?: string[];
43
+ files?: string[];
44
+ auxiliaryFiles?: string[];
45
+ hash?: string;
46
+ childrenByOrder?: Record<string, (string | number)[]>;
47
+ id?: string | number;
48
+ siblings?: (string | number)[];
49
+ parents?: (string | number)[];
50
+ children?: (string | number)[];
51
+ modules?: StatsModule[];
52
+ filteredModules?: number;
53
+ origins?: StatsChunkOrigin[];
54
+ };
55
+ export type KnownAssetInfo = {
56
+ immutable?: boolean;
57
+ minimized?: boolean;
58
+ fullhash?: string | string[];
59
+ chunkhash?: string | string[];
60
+ contenthash?: string | string[];
61
+ sourceFilename?: string;
62
+ size?: number;
63
+ development?: boolean;
64
+ hotModuleReplacement?: boolean;
65
+ javascriptModule?: boolean;
66
+ related?: Record<string, string | string[]>;
67
+ };
68
+ export type AssetInfo = KnownAssetInfo & Record<string, any>;
69
+ export type StatsChunkGroup = KnownStatsChunkGroup & Record<string, any>;
70
+ export type KnownStatsAsset = {
71
+ type: string;
72
+ name: string;
73
+ info: AssetInfo;
74
+ size: number;
75
+ emitted: boolean;
76
+ cached: boolean;
77
+ related?: StatsAsset[];
78
+ chunkNames?: (string | number)[];
79
+ chunkIdHints?: (string | number)[];
80
+ chunks?: (string | null | undefined)[];
81
+ auxiliaryChunkNames?: (string | number)[];
82
+ auxiliaryChunks?: (string | null | undefined)[];
83
+ auxiliaryChunkIdHints?: (string | number)[];
84
+ filteredRelated?: number;
85
+ isOverSizeLimit?: boolean;
10
86
  };
11
- export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related">;
12
- export type StatsChunkGroup = binding.JsStatsChunkGroup & Record<string, any>;
13
- export type KnownStatsAsset = Omit<binding.JsStatsAsset, "info">;
14
87
  export type StatsAsset = KnownStatsAsset & Record<string, any>;
15
88
  export type StatsChunk = KnownStatsChunk & Record<string, any>;
16
89
  export type KnownStatsModule = {
@@ -61,15 +134,28 @@ export type KnownStatsProfile = {
61
134
  building: number;
62
135
  };
63
136
  export type StatsModule = KnownStatsModule & Record<string, any>;
64
- export type StatsModuleIssuer = Omit<binding.JsStatsModuleIssuer, "identifier"> & {
137
+ export type KnownStatsModuleIssuer = {
65
138
  identifier?: string;
66
- } & Record<string, any>;
67
- export type StatsError = Omit<binding.JsStatsError, "moduleIdentifier"> & {
68
- moduleIdentifier?: string;
69
- } & Record<string, any>;
70
- export type StatsWarnings = Omit<binding.JsStatsWarning, "moduleIdentifier"> & {
139
+ name?: string;
140
+ id?: string | number;
141
+ };
142
+ export type StatsModuleIssuer = KnownStatsModuleIssuer & Record<string, any>;
143
+ export type KnownStatsError = {
144
+ message: string;
145
+ chunkName?: string;
146
+ chunkEntry?: boolean;
147
+ chunkInitial?: boolean;
148
+ file?: string;
71
149
  moduleIdentifier?: string;
72
- } & Record<string, any>;
150
+ moduleName?: string;
151
+ loc?: string;
152
+ chunkId?: string | number;
153
+ moduleId?: string | number;
154
+ moduleTrace?: StatsModuleTraceItem[];
155
+ details?: any;
156
+ stack?: string;
157
+ };
158
+ export type StatsError = KnownStatsError & Record<string, any>;
73
159
  export type StatsModuleTraceItem = {
74
160
  originIdentifier?: string;
75
161
  originName?: string;
@@ -78,9 +164,18 @@ export type StatsModuleTraceItem = {
78
164
  originId?: string;
79
165
  moduleId?: string;
80
166
  };
81
- export type StatsModuleReason = Omit<binding.JsStatsModuleReason, "moduleIdentifier"> & {
167
+ export type KnownStatsModuleReason = {
82
168
  moduleIdentifier?: string;
83
- } & Record<string, any>;
169
+ module?: string;
170
+ moduleName?: string;
171
+ resolvedModuleIdentifier?: string;
172
+ resolvedModule?: string;
173
+ type?: string;
174
+ userRequest?: string;
175
+ moduleId?: string | null;
176
+ resolvedModuleId?: string | number | null;
177
+ };
178
+ export type StatsModuleReason = KnownStatsModuleReason & Record<string, any>;
84
179
  export type KnownStatsChunkOrigin = {
85
180
  module: string;
86
181
  moduleIdentifier: string;
@@ -112,7 +207,7 @@ export type KnownStatsCompilation = {
112
207
  namedChunkGroups?: Record<string, StatsChunkGroup>;
113
208
  errors?: StatsError[];
114
209
  errorsCount?: number;
115
- warnings?: StatsWarnings[];
210
+ warnings?: StatsError[];
116
211
  warningsCount?: number;
117
212
  filteredModules?: number;
118
213
  children?: StatsCompilation[];
@@ -137,7 +232,7 @@ export type KnownStatsLoggingEntry = {
137
232
  type ExtractorsByOption<T, O> = {
138
233
  [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void;
139
234
  };
140
- export type PreprocessedAsset = StatsAsset & {
235
+ export type PreprocessedAsset = binding.JsStatsAsset & {
141
236
  type: string;
142
237
  related: PreprocessedAsset[];
143
238
  info: binding.JsStatsAssetInfo;
@@ -156,8 +251,9 @@ export type SimpleExtractors = {
156
251
  profile: ExtractorsByOption<binding.JsStatsModuleProfile, StatsProfile>;
157
252
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
158
253
  chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
254
+ chunkOrigin: ExtractorsByOption<JsOriginRecord, StatsChunkOrigin>;
159
255
  error: ExtractorsByOption<binding.JsStatsError, StatsError>;
160
- warning: ExtractorsByOption<binding.JsStatsWarning, StatsWarnings>;
256
+ warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>;
161
257
  moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>;
162
258
  };
163
259
  export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];
@@ -188,4 +284,8 @@ export declare const mergeToObject: (items: {
188
284
  name: string;
189
285
  }[]) => Object;
190
286
  export declare function resolveStatsMillisecond(s: binding.JsStatsMillisecond): number;
287
+ export declare const errorsSpaceLimit: (errors: StatsError[], max: number) => {
288
+ errors: StatsError[];
289
+ filtered: number;
290
+ };
191
291
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveStatsMillisecond = exports.mergeToObject = exports.moduleGroup = exports.assetGroup = exports.sortByField = exports.countWithChildren = exports.spaceLimited = exports.collapse = exports.getTotalItems = exports.iterateConfig = exports.uniqueOrderedArray = exports.uniqueArray = void 0;
3
+ exports.errorsSpaceLimit = exports.resolveStatsMillisecond = exports.mergeToObject = exports.moduleGroup = exports.assetGroup = exports.sortByField = exports.countWithChildren = exports.spaceLimited = exports.collapse = exports.getTotalItems = exports.iterateConfig = exports.uniqueOrderedArray = exports.uniqueArray = void 0;
4
4
  const comparators_1 = require("../util/comparators");
5
5
  const uniqueArray = (items, selector) => {
6
6
  const set = new Set();
@@ -279,3 +279,64 @@ function resolveStatsMillisecond(s) {
279
279
  return s.secs * 1000 + s.subsecMillis;
280
280
  }
281
281
  exports.resolveStatsMillisecond = resolveStatsMillisecond;
282
+ const errorsSpaceLimit = (errors, max) => {
283
+ let filtered = 0;
284
+ // Can not fit into limit
285
+ // print only messages
286
+ if (errors.length + 1 >= max) {
287
+ return {
288
+ errors: errors.map(error => {
289
+ if (typeof error === "string" || !error.details)
290
+ return error;
291
+ filtered++;
292
+ return { ...error, details: "" };
293
+ }),
294
+ filtered
295
+ };
296
+ }
297
+ let fullLength = errors.length;
298
+ let result = errors;
299
+ let i = 0;
300
+ for (; i < errors.length; i++) {
301
+ const error = errors[i];
302
+ if (typeof error !== "string" && error.details) {
303
+ const splitted = error.details.split("\n");
304
+ const len = splitted.length;
305
+ fullLength += len;
306
+ if (fullLength > max) {
307
+ result = i > 0 ? errors.slice(0, i) : [];
308
+ const overLimit = fullLength - max + 1;
309
+ const error = errors[i++];
310
+ result.push({
311
+ ...error,
312
+ details: error.details.split("\n").slice(0, -overLimit).join("\n"),
313
+ filteredDetails: overLimit
314
+ });
315
+ filtered = errors.length - i;
316
+ for (; i < errors.length; i++) {
317
+ const error = errors[i];
318
+ if (typeof error === "string" || !error.details)
319
+ result.push(error);
320
+ result.push({ ...error, details: "" });
321
+ }
322
+ break;
323
+ }
324
+ if (fullLength === max) {
325
+ result = errors.slice(0, ++i);
326
+ filtered = errors.length - i;
327
+ for (; i < errors.length; i++) {
328
+ const error = errors[i];
329
+ if (typeof error === "string" || !error.details)
330
+ result.push(error);
331
+ result.push({ ...error, details: "" });
332
+ }
333
+ break;
334
+ }
335
+ }
336
+ }
337
+ return {
338
+ errors: result,
339
+ filtered
340
+ };
341
+ };
342
+ exports.errorsSpaceLimit = errorsSpaceLimit;
@@ -1 +1 @@
1
- export declare function assertNotNill(value: any): asserts value;
1
+ export declare function assertNotNill(value: unknown): asserts value;
@@ -0,0 +1,2 @@
1
+ export type AssetCondition = string | RegExp;
2
+ export type AssetConditions = AssetCondition | AssetCondition[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -247,11 +247,12 @@ const _cleverMerge = (first, second, internalCaching = false) => {
247
247
  : parseObject(first);
248
248
  const { static: firstInfo, dynamic: firstDynamicInfo } = firstObject;
249
249
  // If the first argument has a dynamic part we modify the dynamic part to merge the second argument
250
+ let secondObj = second;
250
251
  if (firstDynamicInfo !== undefined) {
251
252
  let { byProperty, fn } = firstDynamicInfo;
252
253
  const fnInfo = fn[DYNAMIC_INFO];
253
254
  if (fnInfo) {
254
- second = internalCaching
255
+ secondObj = internalCaching
255
256
  ? (0, exports.cachedCleverMerge)(fnInfo[1], second)
256
257
  : (0, exports.cleverMerge)(fnInfo[1], second);
257
258
  fn = fnInfo[0];
@@ -259,10 +260,10 @@ const _cleverMerge = (first, second, internalCaching = false) => {
259
260
  const newFn = (...args) => {
260
261
  const fnResult = fn(...args);
261
262
  return internalCaching
262
- ? (0, exports.cachedCleverMerge)(fnResult, second)
263
- : (0, exports.cleverMerge)(fnResult, second);
263
+ ? (0, exports.cachedCleverMerge)(fnResult, secondObj)
264
+ : (0, exports.cleverMerge)(fnResult, secondObj);
264
265
  };
265
- newFn[DYNAMIC_INFO] = [fn, second];
266
+ newFn[DYNAMIC_INFO] = [fn, secondObj];
266
267
  return serializeObject(firstObject.static, { byProperty, fn: newFn });
267
268
  }
268
269
  // If the first part is static only, we merge the static parts and keep the dynamic part of the second argument
@@ -113,12 +113,17 @@ class DebugHash extends hash_1.default {
113
113
  * @returns updated hash
114
114
  */
115
115
  update(data, _inputEncoding) {
116
- if (typeof data !== "string")
117
- data = data.toString("utf-8");
118
- if (data.startsWith("debug-digest-")) {
119
- data = Buffer.from(data.slice("debug-digest-".length), "hex").toString();
116
+ let normalizedData;
117
+ if (typeof data !== "string") {
118
+ normalizedData = data.toString("utf-8");
120
119
  }
121
- this.string += `[${data}](${new Error().stack?.split("\n", 3)[2]})\n`;
120
+ else {
121
+ normalizedData = data;
122
+ }
123
+ if (normalizedData.startsWith("debug-digest-")) {
124
+ normalizedData = Buffer.from(normalizedData.slice("debug-digest-".length), "hex").toString();
125
+ }
126
+ this.string += `[${normalizedData}](${new Error().stack?.split("\n", 3)[2]})\n`;
122
127
  return this;
123
128
  }
124
129
  /**
@@ -43,11 +43,12 @@ class WasmHash {
43
43
  */
44
44
  update(data, encoding) {
45
45
  if (typeof data === "string") {
46
- while (data.length > exports.MAX_SHORT_STRING) {
47
- this._updateWithShortString(data.slice(0, exports.MAX_SHORT_STRING), encoding);
48
- data = data.slice(exports.MAX_SHORT_STRING);
46
+ let normalizedData = data;
47
+ while (normalizedData.length > exports.MAX_SHORT_STRING) {
48
+ this._updateWithShortString(normalizedData.slice(0, exports.MAX_SHORT_STRING), encoding);
49
+ normalizedData = normalizedData.slice(exports.MAX_SHORT_STRING);
49
50
  }
50
- this._updateWithShortString(data, encoding);
51
+ this._updateWithShortString(normalizedData, encoding);
51
52
  return this;
52
53
  }
53
54
  this._updateWithBuffer(data);
@@ -70,10 +70,10 @@ export declare const parseResourceWithoutFragment: {
70
70
  bindCache(associatedObjectForCache: object): (str: string) => ParsedResourceWithoutFragment;
71
71
  };
72
72
  /**
73
- * @param {string} filename the filename which should be undone
74
- * @param {string} outputPath the output path that is restored (only relevant when filename contains "..")
75
- * @param {boolean} enforceRelative true returns ./ for empty paths
76
- * @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
73
+ * @param filename the filename which should be undone
74
+ * @param outputPath the output path that is restored (only relevant when filename contains "..")
75
+ * @param enforceRelative true returns ./ for empty paths
76
+ * @returns repeated ../ to leave the directory of the provided filename to be back on output dir
77
77
  */
78
78
  export declare const getUndoPath: (filename: string, outputPath: string, enforceRelative: boolean) => string;
79
79
  export {};
@@ -293,28 +293,28 @@ const _parseResourceWithoutFragment = (str) => {
293
293
  };
294
294
  exports.parseResourceWithoutFragment = makeCacheable(_parseResourceWithoutFragment);
295
295
  /**
296
- * @param {string} filename the filename which should be undone
297
- * @param {string} outputPath the output path that is restored (only relevant when filename contains "..")
298
- * @param {boolean} enforceRelative true returns ./ for empty paths
299
- * @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
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
300
  */
301
301
  const getUndoPath = (filename, outputPath, enforceRelative) => {
302
302
  let depth = -1;
303
303
  let append = "";
304
- outputPath = outputPath.replace(/[\\/]$/, "");
304
+ let path = outputPath.replace(/[\\/]$/, "");
305
305
  for (const part of filename.split(/[/\\]+/)) {
306
306
  if (part === "..") {
307
307
  if (depth > -1) {
308
308
  depth--;
309
309
  }
310
310
  else {
311
- const i = outputPath.lastIndexOf("/");
312
- const j = outputPath.lastIndexOf("\\");
311
+ const i = path.lastIndexOf("/");
312
+ const j = path.lastIndexOf("\\");
313
313
  const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
314
314
  if (pos < 0)
315
- return `${outputPath}/`;
316
- append = `${outputPath.slice(pos + 1)}/${append}`;
317
- outputPath = outputPath.slice(0, pos);
315
+ return `${path}/`;
316
+ append = `${path.slice(pos + 1)}/${append}`;
317
+ path = path.slice(0, pos);
318
318
  }
319
319
  }
320
320
  else if (part !== ".") {
@@ -4,15 +4,16 @@ exports.memoizeValue = exports.memoizeFn = exports.memoize = void 0;
4
4
  const memoize = (fn) => {
5
5
  let cache = false;
6
6
  let result;
7
+ let callback = fn;
7
8
  return () => {
8
9
  if (cache) {
9
10
  return result;
10
11
  }
11
- result = fn();
12
+ result = callback();
12
13
  cache = true;
13
14
  // Allow to clean up memory for fn
14
15
  // and all dependent resources
15
- fn = undefined;
16
+ callback = undefined;
16
17
  return result;
17
18
  };
18
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -58,9 +58,9 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@module-federation/runtime-tools": "0.2.3",
61
+ "@rspack/lite-tapable": "1.0.0-beta.5",
61
62
  "caniuse-lite": "^1.0.30001616",
62
- "@rspack/lite-tapable": "1.0.0-beta.2",
63
- "@rspack/binding": "1.0.0-beta.2"
63
+ "@rspack/binding": "1.0.0-beta.4"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@swc/helpers": ">=0.5.1"
@@ -1,37 +0,0 @@
1
- {
2
- "title": "Mini CSS Extract Plugin Loader options",
3
- "type": "object",
4
- "additionalProperties": false,
5
- "properties": {
6
- "publicPath": {
7
- "anyOf": [
8
- {
9
- "type": "string"
10
- },
11
- {
12
- "instanceof": "Function"
13
- }
14
- ],
15
- "description": "Specifies a custom public path for the external resources like images, files, etc inside CSS.",
16
- "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#publicpath"
17
- },
18
- "emit": {
19
- "type": "boolean",
20
- "description": "If true, emits a file (writes a file to the filesystem). If false, the plugin will extract the CSS but will not emit the file",
21
- "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#emit"
22
- },
23
- "esModule": {
24
- "type": "boolean",
25
- "description": "Generates JS modules that use the ES modules syntax.",
26
- "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#esmodule"
27
- },
28
- "layer": {
29
- "type": "string"
30
- },
31
- "defaultExport": {
32
- "type": "boolean",
33
- "description": "Duplicate the named export with CSS modules locals to the default export (only when `esModules: true` for css-loader).",
34
- "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#defaultexports"
35
- }
36
- }
37
- }