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

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 (53) hide show
  1. package/dist/Compilation.d.ts +20 -1
  2. package/dist/Compilation.js +109 -44
  3. package/dist/Compiler.d.ts +1 -0
  4. package/dist/Compiler.js +29 -24
  5. package/dist/MultiCompiler.js +10 -6
  6. package/dist/MultiStats.d.ts +1 -1
  7. package/dist/MultiStats.js +19 -16
  8. package/dist/NormalModule.js +3 -4
  9. package/dist/Stats.d.ts +1 -1
  10. package/dist/Template.d.ts +4 -4
  11. package/dist/Template.js +6 -4
  12. package/dist/Watching.js +3 -5
  13. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -10
  14. package/dist/builtin-plugin/DynamicEntryPlugin.js +26 -15
  15. package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
  16. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +21 -4
  17. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +29 -5
  18. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +4 -6
  19. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +16 -10
  20. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +11 -9
  21. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +10 -6
  22. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +1 -1
  23. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +2 -2
  24. package/dist/builtin-plugin/css-extract/loader.js +1 -2
  25. package/dist/config/adapter.d.ts +2 -2
  26. package/dist/config/zod.d.ts +338 -62
  27. package/dist/config/zod.js +8 -5
  28. package/dist/exports.d.ts +4 -3
  29. package/dist/exports.js +5 -2
  30. package/dist/lib/Cache.js +6 -4
  31. package/dist/lib/CacheFacade.js +8 -9
  32. package/dist/lib/LoaderOptionsPlugin.d.ts +4 -2
  33. package/dist/lib/LoaderOptionsPlugin.js +0 -2
  34. package/dist/lib/cache/mergeEtags.d.ts +3 -3
  35. package/dist/lib/cache/mergeEtags.js +5 -3
  36. package/dist/loader-runner/index.js +4 -2
  37. package/dist/node/nodeConsole.js +5 -5
  38. package/dist/stats/DefaultStatsPresetPlugin.js +1 -3
  39. package/dist/stats/StatsFactory.js +3 -4
  40. package/dist/stats/StatsPrinter.js +3 -4
  41. package/dist/stats/statsFactoryUtils.d.ts +106 -19
  42. package/dist/util/assertNotNil.d.ts +1 -1
  43. package/dist/util/assetCondition.d.ts +2 -0
  44. package/dist/util/assetCondition.js +2 -0
  45. package/dist/util/cleverMerge.js +5 -4
  46. package/dist/util/createHash.js +10 -5
  47. package/dist/util/hash/wasm-hash.js +5 -4
  48. package/dist/util/identifier.d.ts +4 -4
  49. package/dist/util/identifier.js +10 -10
  50. package/dist/util/memoize.js +3 -2
  51. package/package.json +3 -3
  52. package/dist/builtin-plugin/css-extract/loader-options.json +0 -37
  53. package/dist/builtin-plugin/css-extract/plugin-options.json +0 -79
@@ -114,7 +114,10 @@ const entryDescription = zod_1.z.strictObject({
114
114
  const entryUnnamed = entryItem;
115
115
  const entryObject = zod_1.z.record(entryItem.or(entryDescription));
116
116
  const entryStatic = entryObject.or(entryUnnamed);
117
- const entry = entryStatic.or(zod_1.z.function().returns(entryStatic.or(zod_1.z.promise(entryStatic))));
117
+ const entryDynamic = zod_1.z
118
+ .function()
119
+ .returns(entryStatic.or(zod_1.z.promise(entryStatic)));
120
+ const entry = entryStatic.or(entryDynamic);
118
121
  //#endregion
119
122
  //#region Output
120
123
  const path = zod_1.z.string();
@@ -467,8 +470,7 @@ const allowTarget = zod_1.z.union([
467
470
  "es2019",
468
471
  "es2020",
469
472
  "es2021",
470
- "es2022",
471
- "browserslist"
473
+ "es2022"
472
474
  ]),
473
475
  zod_1.z.literal("node"),
474
476
  zod_1.z.literal("async-node"),
@@ -490,7 +492,9 @@ const allowTarget = zod_1.z.union([
490
492
  zod_1.z.custom(value => typeof value === "string" && /^nwjs\d+\.\d+$/.test(value)),
491
493
  zod_1.z.literal("node-webkit"),
492
494
  zod_1.z.custom(value => typeof value === "string" && /^node-webkit\d+$/.test(value)),
493
- zod_1.z.custom(value => typeof value === "string" && /^node-webkit\d+\.\d+$/.test(value))
495
+ zod_1.z.custom(value => typeof value === "string" && /^node-webkit\d+\.\d+$/.test(value)),
496
+ zod_1.z.literal("browserslist"),
497
+ zod_1.z.custom(value => typeof value === "string" && /^browserslist:(.+)$/.test(value))
494
498
  ]);
495
499
  const target = zod_1.z.union([zod_1.z.literal(false), allowTarget, allowTarget.array()]);
496
500
  //#endregion
@@ -739,7 +743,6 @@ const statsOptions = zod_1.z.strictObject({
739
743
  });
740
744
  const statsValue = zod_1.z.boolean().or(statsPresets).or(statsOptions);
741
745
  const plugin = zod_1.z.union([
742
- zod_1.z.custom(),
743
746
  zod_1.z.custom(),
744
747
  falsy
745
748
  ]);
package/dist/exports.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- declare const rspackVersion: any, webpackVersion: any;
2
- export { rspackVersion, webpackVersion as version };
1
+ declare const rspackVersion: string;
2
+ declare const version: string;
3
+ export { rspackVersion, version };
3
4
  export type { Asset, AssetInfo, Assets, CompilationParams, LogEntry } from "./Compilation";
4
5
  export { Compilation } from "./Compilation";
5
6
  export { Compiler } from "./Compiler";
@@ -14,7 +15,7 @@ export { MultiStats } from "./MultiStats";
14
15
  export { NormalModule } from "./NormalModule";
15
16
  export type { NormalModuleFactory } from "./NormalModuleFactory";
16
17
  export { RuntimeGlobals } from "./RuntimeGlobals";
17
- export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule, StatsWarnings } from "./Stats";
18
+ export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule } from "./Stats";
18
19
  export { Stats } from "./Stats";
19
20
  import * as ModuleFilenameHelpers from "./lib/ModuleFilenameHelpers";
20
21
  export { ModuleFilenameHelpers };
package/dist/exports.js CHANGED
@@ -28,9 +28,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.LightningCssMinimizerRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.web = exports.NormalModuleReplacementPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.EnvironmentPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.DynamicEntryPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.IgnorePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.Stats = exports.RuntimeGlobals = exports.NormalModule = exports.MultiStats = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compiler = exports.Compilation = exports.version = exports.rspackVersion = void 0;
30
30
  exports.experiments = void 0;
31
- const { version: rspackVersion, webpackVersion } = require("../package.json");
31
+ const package_json_1 = require("../package.json");
32
+ // this is a hack to be compatible with plugin which detect webpack's version
33
+ const rspackVersion = package_json_1.version;
32
34
  exports.rspackVersion = rspackVersion;
33
- exports.version = webpackVersion;
35
+ const version = package_json_1.webpackVersion;
36
+ exports.version = version;
34
37
  var Compilation_1 = require("./Compilation");
35
38
  Object.defineProperty(exports, "Compilation", { enumerable: true, get: function () { return Compilation_1.Compilation; } });
36
39
  var Compiler_1 = require("./Compiler");
package/dist/lib/Cache.js CHANGED
@@ -13,12 +13,13 @@ exports.Cache = void 0;
13
13
  const lite_tapable_1 = require("@rspack/lite-tapable");
14
14
  const HookWebpackError_1 = require("./HookWebpackError");
15
15
  const needCalls = (times, callback) => {
16
+ let leftTimes = times;
16
17
  return err => {
17
- if (--times === 0) {
18
+ if (--leftTimes === 0) {
18
19
  return callback();
19
20
  }
20
- if (err && times > 0) {
21
- times = 0;
21
+ if (err && leftTimes > 0) {
22
+ leftTimes = 0;
22
23
  return callback();
23
24
  }
24
25
  };
@@ -42,11 +43,12 @@ class Cache {
42
43
  */
43
44
  get(identifier, etag, callback) {
44
45
  const gotHandlers = [];
45
- this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {
46
+ this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, res) => {
46
47
  if (err) {
47
48
  callback((0, HookWebpackError_1.makeWebpackError)(err, "Cache.hooks.get"));
48
49
  return;
49
50
  }
51
+ let result = res;
50
52
  if (result === null) {
51
53
  result = undefined;
52
54
  }
@@ -63,15 +63,14 @@ class MultiItemCache {
63
63
  /**
64
64
  * @returns promise with the data
65
65
  */
66
- getPromise() {
67
- const next = async (i) => {
68
- const result_1 = await this._items[i].getPromise();
69
- if (result_1 !== undefined)
70
- return result_1;
71
- if (++i < this._items.length)
72
- return next(i);
73
- };
74
- return next(0);
66
+ async getPromise() {
67
+ for (let i = 0; i < this._items.length; i++) {
68
+ const result = await this._items[i].getPromise();
69
+ if (result !== undefined) {
70
+ return result;
71
+ }
72
+ }
73
+ return undefined;
75
74
  }
76
75
  /**
77
76
  * @param data the value to store
@@ -9,9 +9,11 @@
9
9
  */
10
10
  import type { Compiler } from "../Compiler";
11
11
  import type { MatchObject } from "./ModuleFilenameHelpers";
12
- type LoaderOptionsPluginOptions = any;
12
+ type LoaderOptionsPluginOptions = MatchObject & {
13
+ [key: string]: unknown;
14
+ };
13
15
  export declare class LoaderOptionsPlugin {
14
- options: MatchObject;
16
+ options: LoaderOptionsPluginOptions;
15
17
  /**
16
18
  * @param options options object
17
19
  */
@@ -40,8 +40,6 @@ class LoaderOptionsPlugin {
40
40
  * @param options options object
41
41
  */
42
42
  constructor(options = {}) {
43
- if (typeof options !== "object")
44
- options = {};
45
43
  if (!options.test) {
46
44
  options.test = {
47
45
  test: () => true
@@ -9,9 +9,9 @@
9
9
  */
10
10
  import type { Etag } from "../Cache";
11
11
  /**
12
- * @param a first
13
- * @param b second
12
+ * @param first first
13
+ * @param second second
14
14
  * @returns result
15
15
  */
16
- export declare const mergeEtags: (a: Etag, b: Etag) => Etag;
16
+ export declare const mergeEtags: (first: Etag, second: Etag) => Etag;
17
17
  export default mergeEtags;
@@ -26,11 +26,13 @@ class MergedEtag {
26
26
  const dualObjectMap = new WeakMap();
27
27
  const objectStringMap = new WeakMap();
28
28
  /**
29
- * @param a first
30
- * @param b second
29
+ * @param first first
30
+ * @param second second
31
31
  * @returns result
32
32
  */
33
- const mergeEtags = (a, b) => {
33
+ const mergeEtags = (first, second) => {
34
+ let a = first;
35
+ let b = second;
34
36
  if (typeof a === "string") {
35
37
  if (typeof b === "string") {
36
38
  return `${a}|${b}`;
@@ -506,7 +506,8 @@ async function runLoaders(compiler, context) {
506
506
  return compiler._lastCompilation.getLogger([name, resource].filter(Boolean).join("|"));
507
507
  };
508
508
  loaderContext.rootContext = compiler.context;
509
- loaderContext.emitError = function emitError(error) {
509
+ loaderContext.emitError = function emitError(err) {
510
+ let error = err;
510
511
  if (!(error instanceof Error)) {
511
512
  error = new RspackError_1.NonErrorEmittedError(error);
512
513
  }
@@ -521,7 +522,8 @@ async function runLoaders(compiler, context) {
521
522
  severity: binding_1.JsRspackSeverity.Error
522
523
  });
523
524
  };
524
- loaderContext.emitWarning = function emitWarning(warning) {
525
+ loaderContext.emitWarning = function emitWarning(warn) {
526
+ let warning = warn;
525
527
  if (!(warning instanceof Error)) {
526
528
  warning = new RspackError_1.NonErrorEmittedError(warning);
527
529
  }
@@ -42,14 +42,14 @@ function default_1({ colors, appendOnly, stream }) {
42
42
  const indent = (str, prefix, colorPrefix, colorSuffix) => {
43
43
  if (str === "")
44
44
  return str;
45
- prefix = currentIndent + prefix;
45
+ const prefixWithIndent = currentIndent + prefix;
46
46
  if (colors) {
47
- return (prefix +
47
+ return (prefixWithIndent +
48
48
  colorPrefix +
49
49
  str.replace(/\n/g, `${colorSuffix}\n${prefix}${colorPrefix}`) +
50
50
  colorSuffix);
51
51
  }
52
- return prefix + str.replace(/\n/g, `\n${prefix}`);
52
+ return prefixWithIndent + str.replace(/\n/g, `\n${prefix}`);
53
53
  };
54
54
  const clearStatusMessage = () => {
55
55
  if (hasStatusMessage) {
@@ -120,8 +120,8 @@ function default_1({ colors, appendOnly, stream }) {
120
120
  })),
121
121
  status: appendOnly
122
122
  ? writeColored("<s> ", "", "")
123
- : (name, ...args) => {
124
- args = args.filter(Boolean);
123
+ : (name, ...argsWithEmpty) => {
124
+ const args = argsWithEmpty.filter(Boolean);
125
125
  if (name === undefined && args.length === 0) {
126
126
  clearStatusMessage();
127
127
  currentStatusMessage = undefined;
@@ -271,9 +271,7 @@ const NORMALIZER = {
271
271
  });
272
272
  },
273
273
  logging: (value) => {
274
- if (value === true)
275
- value = "log";
276
- return value;
274
+ return value === true ? "log" : value;
277
275
  },
278
276
  loggingDebug: (value) => {
279
277
  const array = !Array.isArray(value) ? (value ? [value] : []) : value;
@@ -71,10 +71,9 @@ class StatsFactory {
71
71
  }
72
72
  }
73
73
  _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;
74
+ return this._getAllLevelHooks(hookMap, cache, type).reduce((data, hook) => {
75
+ return fn(hook, data);
76
+ }, data);
78
77
  }
79
78
  _forEachLevelFilter(hookMap, cache, type, items, fn, forceClone) {
80
79
  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) {
@@ -3,14 +3,82 @@ import type * as binding from "@rspack/binding";
3
3
  import type { Compilation, NormalizedStatsOptions } from "../Compilation";
4
4
  import { type Comparator } from "../util/comparators";
5
5
  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[];
6
+ export type KnownStatsChunkGroup = {
7
+ name?: string;
8
+ chunks?: (string | number)[];
9
+ assets?: {
10
+ name: string;
11
+ size?: number;
12
+ }[];
13
+ filteredAssets?: number;
14
+ assetsSize?: number;
15
+ auxiliaryAssets?: {
16
+ name: string;
17
+ size?: number;
18
+ }[];
19
+ filteredAuxiliaryAssets?: number;
20
+ auxiliaryAssetsSize?: number;
21
+ children?: {
22
+ preload?: StatsChunkGroup[];
23
+ prefetch?: StatsChunkGroup[];
24
+ };
25
+ childAssets?: {
26
+ [index: string]: string[];
27
+ };
28
+ };
29
+ export type KnownStatsChunk = {
30
+ type: string;
31
+ rendered: boolean;
32
+ initial: boolean;
33
+ entry: boolean;
34
+ reason?: string;
35
+ size: number;
36
+ sizes?: Record<string, number>;
37
+ names?: string[];
38
+ idHints?: string[];
39
+ runtime?: string[];
40
+ files?: string[];
41
+ auxiliaryFiles?: string[];
42
+ hash?: string;
43
+ childrenByOrder?: Record<string, (string | number)[]>;
44
+ id?: string | number;
45
+ siblings?: (string | number)[];
46
+ parents?: (string | number)[];
47
+ children?: (string | number)[];
48
+ modules?: StatsModule[];
49
+ filteredModules?: number;
50
+ origins?: StatsChunkOrigin[];
51
+ };
52
+ export type KnownAssetInfo = {
53
+ immutable?: boolean;
54
+ minimized?: boolean;
55
+ fullhash?: string | string[];
56
+ chunkhash?: string | string[];
57
+ contenthash?: string | string[];
58
+ sourceFilename?: string;
59
+ size?: number;
60
+ development?: boolean;
61
+ hotModuleReplacement?: boolean;
62
+ javascriptModule?: boolean;
63
+ related?: Record<string, string | string[]>;
64
+ };
65
+ export type AssetInfo = KnownAssetInfo & Record<string, any>;
66
+ export type StatsChunkGroup = KnownStatsChunkGroup & Record<string, any>;
67
+ export type KnownStatsAsset = {
68
+ type: string;
69
+ name: string;
70
+ info: AssetInfo;
71
+ size: number;
72
+ emitted: boolean;
73
+ chunkNames?: (string | number)[];
74
+ chunkIdHints?: (string | number)[];
75
+ chunks?: (string | null | undefined)[];
76
+ auxiliaryChunkNames?: (string | number)[];
77
+ auxiliaryChunks?: (string | null | undefined)[];
78
+ auxiliaryChunkIdHints?: (string | number)[];
79
+ filteredRelated?: number;
80
+ isOverSizeLimit?: boolean;
10
81
  };
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
82
  export type StatsAsset = KnownStatsAsset & Record<string, any>;
15
83
  export type StatsChunk = KnownStatsChunk & Record<string, any>;
16
84
  export type KnownStatsModule = {
@@ -61,15 +129,28 @@ export type KnownStatsProfile = {
61
129
  building: number;
62
130
  };
63
131
  export type StatsModule = KnownStatsModule & Record<string, any>;
64
- export type StatsModuleIssuer = Omit<binding.JsStatsModuleIssuer, "identifier"> & {
132
+ export type KnownStatsModuleIssuer = {
65
133
  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"> & {
134
+ name?: string;
135
+ id?: string | number;
136
+ };
137
+ export type StatsModuleIssuer = KnownStatsModuleIssuer & Record<string, any>;
138
+ export type KnownStatsError = {
139
+ message: string;
140
+ chunkName?: string;
141
+ chunkEntry?: boolean;
142
+ chunkInitial?: boolean;
143
+ file?: string;
71
144
  moduleIdentifier?: string;
72
- } & Record<string, any>;
145
+ moduleName?: string;
146
+ loc?: string;
147
+ chunkId?: string | number;
148
+ moduleId?: string | number;
149
+ moduleTrace?: StatsModuleTraceItem[];
150
+ details?: any;
151
+ stack?: string;
152
+ };
153
+ export type StatsError = KnownStatsError & Record<string, any>;
73
154
  export type StatsModuleTraceItem = {
74
155
  originIdentifier?: string;
75
156
  originName?: string;
@@ -78,9 +159,15 @@ export type StatsModuleTraceItem = {
78
159
  originId?: string;
79
160
  moduleId?: string;
80
161
  };
81
- export type StatsModuleReason = Omit<binding.JsStatsModuleReason, "moduleIdentifier"> & {
162
+ export type KnownStatsModuleReason = {
82
163
  moduleIdentifier?: string;
83
- } & Record<string, any>;
164
+ module?: string;
165
+ moduleName?: string;
166
+ type?: string;
167
+ userRequest?: string;
168
+ moduleId?: string | null;
169
+ };
170
+ export type StatsModuleReason = KnownStatsModuleReason & Record<string, any>;
84
171
  export type KnownStatsChunkOrigin = {
85
172
  module: string;
86
173
  moduleIdentifier: string;
@@ -112,7 +199,7 @@ export type KnownStatsCompilation = {
112
199
  namedChunkGroups?: Record<string, StatsChunkGroup>;
113
200
  errors?: StatsError[];
114
201
  errorsCount?: number;
115
- warnings?: StatsWarnings[];
202
+ warnings?: StatsError[];
116
203
  warningsCount?: number;
117
204
  filteredModules?: number;
118
205
  children?: StatsCompilation[];
@@ -137,7 +224,7 @@ export type KnownStatsLoggingEntry = {
137
224
  type ExtractorsByOption<T, O> = {
138
225
  [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void;
139
226
  };
140
- export type PreprocessedAsset = StatsAsset & {
227
+ export type PreprocessedAsset = binding.JsStatsAsset & {
141
228
  type: string;
142
229
  related: PreprocessedAsset[];
143
230
  info: binding.JsStatsAssetInfo;
@@ -157,7 +244,7 @@ export type SimpleExtractors = {
157
244
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
158
245
  chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
159
246
  error: ExtractorsByOption<binding.JsStatsError, StatsError>;
160
- warning: ExtractorsByOption<binding.JsStatsWarning, StatsWarnings>;
247
+ warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>;
161
248
  moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>;
162
249
  };
163
250
  export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];
@@ -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.3",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -59,8 +59,8 @@
59
59
  "dependencies": {
60
60
  "@module-federation/runtime-tools": "0.2.3",
61
61
  "caniuse-lite": "^1.0.30001616",
62
- "@rspack/lite-tapable": "1.0.0-beta.2",
63
- "@rspack/binding": "1.0.0-beta.2"
62
+ "@rspack/binding": "1.0.0-beta.3",
63
+ "@rspack/lite-tapable": "1.0.0-beta.3"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@swc/helpers": ">=0.5.1"