@rspack/core 1.0.0-alpha.4 → 1.0.0-alpha.5

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.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ThreadsafeWritableNodeFS = void 0;
7
- const util_1 = __importDefault(require("util"));
7
+ const node_util_1 = __importDefault(require("node:util"));
8
8
  const fs_1 = require("./util/fs");
9
9
  const memoize_1 = require("./util/memoize");
10
10
  const NOOP_FILESYSTEM = {
@@ -21,11 +21,11 @@ class ThreadsafeWritableNodeFS {
21
21
  Object.assign(this, NOOP_FILESYSTEM);
22
22
  return;
23
23
  }
24
- this.writeFile = (0, memoize_1.memoizeFn)(() => util_1.default.promisify(fs.writeFile.bind(fs)));
25
- this.removeFile = (0, memoize_1.memoizeFn)(() => util_1.default.promisify(fs.unlink.bind(fs)));
26
- this.mkdir = (0, memoize_1.memoizeFn)(() => util_1.default.promisify(fs.mkdir.bind(fs)));
27
- this.mkdirp = (0, memoize_1.memoizeFn)(() => util_1.default.promisify(fs_1.mkdirp.bind(null, fs)));
28
- this.removeDirAll = (0, memoize_1.memoizeFn)(() => util_1.default.promisify(fs_1.rmrf.bind(null, fs)));
24
+ this.writeFile = (0, memoize_1.memoizeFn)(() => node_util_1.default.promisify(fs.writeFile.bind(fs)));
25
+ this.removeFile = (0, memoize_1.memoizeFn)(() => node_util_1.default.promisify(fs.unlink.bind(fs)));
26
+ this.mkdir = (0, memoize_1.memoizeFn)(() => node_util_1.default.promisify(fs.mkdir.bind(fs)));
27
+ this.mkdirp = (0, memoize_1.memoizeFn)(() => node_util_1.default.promisify(fs_1.mkdirp.bind(null, fs)));
28
+ this.removeDirAll = (0, memoize_1.memoizeFn)(() => node_util_1.default.promisify(fs_1.rmrf.bind(null, fs)));
29
29
  }
30
30
  static __to_binding(fs) {
31
31
  return new this(fs);
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.NormalModule = void 0;
30
- const util_1 = __importDefault(require("util"));
30
+ const node_util_1 = __importDefault(require("node:util"));
31
31
  const liteTapable = __importStar(require("@rspack/lite-tapable"));
32
32
  const Compilation_1 = require("./Compilation");
33
33
  const compilationHooksMap = new WeakMap();
@@ -45,14 +45,14 @@ const deprecateAllProperties = (obj, message, code) => {
45
45
  if (typeof descriptor.value === "function") {
46
46
  Object.defineProperty(newObj, name, {
47
47
  ...descriptor,
48
- value: util_1.default.deprecate(descriptor.value, message, code)
48
+ value: node_util_1.default.deprecate(descriptor.value, message, code)
49
49
  });
50
50
  }
51
51
  else if (descriptor.get || descriptor.set) {
52
52
  Object.defineProperty(newObj, name, {
53
53
  ...descriptor,
54
- get: descriptor.get && util_1.default.deprecate(descriptor.get, message, code),
55
- set: descriptor.set && util_1.default.deprecate(descriptor.set, message, code)
54
+ get: descriptor.get && node_util_1.default.deprecate(descriptor.get, message, code),
55
+ set: descriptor.set && node_util_1.default.deprecate(descriptor.set, message, code)
56
56
  });
57
57
  }
58
58
  else {
@@ -60,9 +60,9 @@ const deprecateAllProperties = (obj, message, code) => {
60
60
  Object.defineProperty(newObj, name, {
61
61
  configurable: descriptor.configurable,
62
62
  enumerable: descriptor.enumerable,
63
- get: util_1.default.deprecate(() => value, message, code),
63
+ get: node_util_1.default.deprecate(() => value, message, code),
64
64
  set: descriptor.writable
65
- ? util_1.default.deprecate((v) => (value = v), message, code)
65
+ ? node_util_1.default.deprecate((v) => (value = v), message, code)
66
66
  : undefined
67
67
  });
68
68
  }
package/dist/Watching.js CHANGED
@@ -25,7 +25,7 @@ exports.Watching = void 0;
25
25
  * Copyright (c) JS Foundation and other contributors
26
26
  * https://github.com/webpack/webpack/blob/main/LICENSE
27
27
  */
28
- const assert_1 = __importDefault(require("assert"));
28
+ const node_assert_1 = __importDefault(require("node:assert"));
29
29
  const _1 = require(".");
30
30
  class Watching {
31
31
  constructor(compiler, watchOptions, handler) {
@@ -186,7 +186,7 @@ class Watching {
186
186
  if (error) {
187
187
  return handleError(error);
188
188
  }
189
- (0, assert_1.default)(compilation);
189
+ (0, node_assert_1.default)(compilation);
190
190
  compilation.startTime = startTime;
191
191
  compilation.endTime = Date.now();
192
192
  stats = new _1.Stats(compilation);
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SplitChunksPlugin = void 0;
7
- const assert_1 = __importDefault(require("assert"));
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
8
  const binding_1 = require("@rspack/binding");
9
9
  const Chunk_1 = require("../Chunk");
10
10
  const Module_1 = require("../Module");
@@ -19,7 +19,7 @@ class SplitChunksPlugin extends base_1.RspackBuiltinPlugin {
19
19
  }
20
20
  raw(compiler) {
21
21
  const rawOptions = toRawSplitChunksOptions(this.options, compiler);
22
- (0, assert_1.default)(typeof rawOptions !== "undefined");
22
+ (0, node_assert_1.default)(typeof rawOptions !== "undefined");
23
23
  return (0, base_1.createBuiltinPlugin)(this.name, rawOptions);
24
24
  }
25
25
  }
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.pitch = exports.SINGLE_DOT_PATH_SEGMENT = exports.BASE_URI = exports.ABSOLUTE_PUBLIC_PATH = exports.AUTO_PUBLIC_PATH = exports.MODULE_TYPE = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const index_1 = require("./index");
9
9
  const loader_options_json_1 = __importDefault(require("./loader-options.json"));
10
10
  const utils_1 = require("./utils");
@@ -21,7 +21,7 @@ function hotLoader(content, context) {
21
21
  return `${content}
22
22
  if(module.hot) {
23
23
  // ${Date.now()}
24
- var cssReload = require(${(0, utils_1.stringifyRequest)(context.loaderContext, path_1.default.join(__dirname, "./hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({
24
+ var cssReload = require(${(0, utils_1.stringifyRequest)(context.loaderContext, node_path_1.default.join(__dirname, "./hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({
25
25
  ...context.options,
26
26
  locals: !!context.locals
27
27
  })});
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.stringifyLocal = exports.stringifyRequest = exports.isRelativePath = exports.isAbsolutePath = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  function isAbsolutePath(str) {
9
- return path_1.default.posix.isAbsolute(str) || path_1.default.win32.isAbsolute(str);
9
+ return node_path_1.default.posix.isAbsolute(str) || node_path_1.default.win32.isAbsolute(str);
10
10
  }
11
11
  exports.isAbsolutePath = isAbsolutePath;
12
12
  const RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/;
@@ -28,7 +28,7 @@ function stringifyRequest(loaderContext, request) {
28
28
  const query = splittedPart ? splittedPart[2] : "";
29
29
  let singlePath = splittedPart ? splittedPart[1] : part;
30
30
  if (isAbsolutePath(singlePath) && context) {
31
- singlePath = path_1.default.relative(context, singlePath);
31
+ singlePath = node_path_1.default.relative(context, singlePath);
32
32
  if (isAbsolutePath(singlePath)) {
33
33
  // If singlePath still matches an absolute path, singlePath was on a different drive than context.
34
34
  // In this case, we leave the path platform-specific without replacing any separators.
@@ -2,9 +2,9 @@
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node" />
5
- import type { IncomingMessage, ServerOptions as ServerOptionsImport, ServerResponse } from "http";
6
- import type { ListenOptions, Server } from "net";
7
- import type { SecureContextOptions, TlsOptions } from "tls";
5
+ import type { IncomingMessage, ServerOptions as ServerOptionsImport, ServerResponse } from "node:http";
6
+ import type { ListenOptions, Server } from "node:net";
7
+ import type { SecureContextOptions, TlsOptions } from "node:tls";
8
8
  import type { Compiler } from "../..";
9
9
  export interface LazyCompilationDefaultBackendOptions {
10
10
  /**
@@ -16,7 +16,7 @@ const getBackend = (options) => (compiler, callback) => {
16
16
  const createServer = typeof options.server === "function"
17
17
  ? options.server
18
18
  : (() => {
19
- const http = isHttps ? require("https") : require("http");
19
+ const http = isHttps ? require("node:https") : require("node:http");
20
20
  return http.createServer.bind(http, options.server);
21
21
  })();
22
22
  const listen = typeof options.listen === "function"
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getRawChunkLoading = exports.getRawLibrary = exports.getRawResolve = exports.getRawOptions = void 0;
7
- const assert_1 = __importDefault(require("assert"));
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
8
  const Stats_1 = require("../Stats");
9
9
  const util_1 = require("../util");
10
10
  const identifier_1 = require("../util/identifier");
11
11
  const adapterRuleUse_1 = require("./adapterRuleUse");
12
12
  const getRawOptions = (options, compiler) => {
13
- (0, assert_1.default)(!(0, util_1.isNil)(options.context) && !(0, util_1.isNil)(options.devtool) && !(0, util_1.isNil)(options.cache), "context, devtool, cache should not be nil after defaults");
13
+ (0, node_assert_1.default)(!(0, util_1.isNil)(options.context) && !(0, util_1.isNil)(options.devtool) && !(0, util_1.isNil)(options.cache), "context, devtool, cache should not be nil after defaults");
14
14
  const devtool = options.devtool === false ? "" : options.devtool;
15
15
  const mode = options.mode;
16
16
  const experiments = getRawExperiments(options.experiments);
@@ -86,7 +86,7 @@ function getRawResolveByDependency(byDependency) {
86
86
  return Object.fromEntries(Object.entries(byDependency).map(([k, v]) => [k, getRawResolve(v)]));
87
87
  }
88
88
  function getRawTsConfig(tsConfig) {
89
- (0, assert_1.default)(typeof tsConfig !== "string", "should resolve string tsConfig in normalization");
89
+ (0, node_assert_1.default)(typeof tsConfig !== "string", "should resolve string tsConfig in normalization");
90
90
  if (tsConfig === undefined)
91
91
  return tsConfig;
92
92
  const { configFile, references } = tsConfig;
@@ -209,7 +209,7 @@ function getRawLibraryName(name) {
209
209
  throw new Error("unreachable");
210
210
  }
211
211
  function getRawModule(module, options) {
212
- (0, assert_1.default)(!(0, util_1.isNil)(module.defaultRules), "module.defaultRules should not be nil after defaults");
212
+ (0, node_assert_1.default)(!(0, util_1.isNil)(module.defaultRules), "module.defaultRules should not be nil after defaults");
213
213
  // "..." in defaultRules will be flatten in `applyModuleDefaults`, and "..." in rules is empty, so it's safe to use `as RuleSetRule[]` at here
214
214
  const ruleSet = [
215
215
  { rules: module.defaultRules },
@@ -607,7 +607,7 @@ function getRawCssAutoOrModuleGeneratorOptions(options) {
607
607
  };
608
608
  }
609
609
  function getRawOptimization(optimization) {
610
- (0, assert_1.default)(!(0, util_1.isNil)(optimization.removeAvailableModules) &&
610
+ (0, node_assert_1.default)(!(0, util_1.isNil)(optimization.removeAvailableModules) &&
611
611
  !(0, util_1.isNil)(optimization.sideEffects) &&
612
612
  !(0, util_1.isNil)(optimization.realContentHash) &&
613
613
  !(0, util_1.isNil)(optimization.providedExports) &&
@@ -629,7 +629,7 @@ function getRawSnapshotOptions(_snapshot) {
629
629
  }
630
630
  function getRawExperiments(experiments) {
631
631
  const { topLevelAwait, rspackFuture } = experiments;
632
- (0, assert_1.default)(!(0, util_1.isNil)(topLevelAwait) && !(0, util_1.isNil)(rspackFuture));
632
+ (0, node_assert_1.default)(!(0, util_1.isNil)(topLevelAwait) && !(0, util_1.isNil)(rspackFuture));
633
633
  return {
634
634
  topLevelAwait,
635
635
  rspackFuture: getRawRspackFutureOptions(rspackFuture)
@@ -642,7 +642,7 @@ function getRawNode(node) {
642
642
  if (node === false) {
643
643
  return undefined;
644
644
  }
645
- (0, assert_1.default)(!(0, util_1.isNil)(node.__dirname) && !(0, util_1.isNil)(node.global) && !(0, util_1.isNil)(node.__filename));
645
+ (0, node_assert_1.default)(!(0, util_1.isNil)(node.__dirname) && !(0, util_1.isNil)(node.global) && !(0, util_1.isNil)(node.__filename));
646
646
  return {
647
647
  dirname: String(node.__dirname),
648
648
  filename: String(node.__filename),
@@ -9,7 +9,7 @@
9
9
  */
10
10
  "use strict";
11
11
  const browserslist = require("../../compiled/browserslist");
12
- const path = require("path");
12
+ const path = require("node:path");
13
13
  /** @typedef {import("./target").ApiTargetProperties} ApiTargetProperties */
14
14
  /** @typedef {import("./target").EcmaTargetProperties} EcmaTargetProperties */
15
15
  /** @typedef {import("./target").PlatformTargetProperties} PlatformTargetProperties */
@@ -13,9 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.applyRspackOptionsBaseDefaults = exports.applyRspackOptionsDefaults = void 0;
16
- const assert_1 = __importDefault(require("assert"));
17
- const fs_1 = __importDefault(require("fs"));
18
- const path_1 = __importDefault(require("path"));
16
+ const node_assert_1 = __importDefault(require("node:assert"));
17
+ const node_fs_1 = __importDefault(require("node:fs"));
18
+ const node_path_1 = __importDefault(require("node:path"));
19
19
  const ModuleTypeConstants_1 = require("../ModuleTypeConstants");
20
20
  const builtin_plugin_1 = require("../builtin-plugin");
21
21
  const util_1 = require("../util");
@@ -29,7 +29,7 @@ const applyRspackOptionsDefaults = (options) => {
29
29
  return (0, target_1.getDefaultTarget)(options.context);
30
30
  });
31
31
  const { mode, target } = options;
32
- (0, assert_1.default)(!(0, util_1.isNil)(target));
32
+ (0, node_assert_1.default)(!(0, util_1.isNil)(target));
33
33
  const targetProperties = target === false
34
34
  ? false
35
35
  : typeof target === "string"
@@ -357,9 +357,9 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
357
357
  });
358
358
  if (libraryName)
359
359
  return libraryName;
360
- const pkgPath = path_1.default.resolve(context, "package.json");
360
+ const pkgPath = node_path_1.default.resolve(context, "package.json");
361
361
  try {
362
- const packageInfo = JSON.parse(fs_1.default.readFileSync(pkgPath, "utf-8"));
362
+ const packageInfo = JSON.parse(node_fs_1.default.readFileSync(pkgPath, "utf-8"));
363
363
  return packageInfo.name || "";
364
364
  }
365
365
  catch (err) {
@@ -412,7 +412,7 @@ const applyOutputDefaults = (output, { context, outputModule, targetProperties:
412
412
  F(output, "chunkLoadingGlobal", () => "webpackChunk" + uniqueNameId);
413
413
  D(output, "assetModuleFilename", "[hash][ext][query]");
414
414
  D(output, "webassemblyModuleFilename", "[hash].module.wasm");
415
- F(output, "path", () => path_1.default.join(process.cwd(), "dist"));
415
+ F(output, "path", () => node_path_1.default.join(process.cwd(), "dist"));
416
416
  F(output, "pathinfo", () => development);
417
417
  D(output, "publicPath", tp && (tp.document || tp.importScripts) ? "auto" : "");
418
418
  D(output, "hashFunction", futureDefaults ? "xxhash64" : "md4");
@@ -1063,7 +1063,7 @@ declare const path: z.ZodString;
1063
1063
  export type Path = z.infer<typeof path>;
1064
1064
  declare const pathinfo: z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"verbose">]>;
1065
1065
  export type Pathinfo = z.infer<typeof pathinfo>;
1066
- declare const assetModuleFilename: z.ZodString;
1066
+ declare const assetModuleFilename: z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<import("@rspack/binding").JsPathData, z.ZodTypeDef, import("@rspack/binding").JsPathData>, z.ZodOptional<z.ZodType<JsAssetInfo, z.ZodTypeDef, JsAssetInfo>>], z.ZodUnknown>, z.ZodString>]>;
1067
1067
  export type AssetModuleFilename = z.infer<typeof assetModuleFilename>;
1068
1068
  declare const webassemblyModuleFilename: z.ZodString;
1069
1069
  export type WebassemblyModuleFilename = z.infer<typeof webassemblyModuleFilename>;
@@ -1193,7 +1193,7 @@ declare const output: z.ZodObject<{
1193
1193
  hotUpdateMainFilename: z.ZodOptional<z.ZodString>;
1194
1194
  hotUpdateChunkFilename: z.ZodOptional<z.ZodString>;
1195
1195
  hotUpdateGlobal: z.ZodOptional<z.ZodString>;
1196
- assetModuleFilename: z.ZodOptional<z.ZodString>;
1196
+ assetModuleFilename: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<import("@rspack/binding").JsPathData, z.ZodTypeDef, import("@rspack/binding").JsPathData>, z.ZodOptional<z.ZodType<JsAssetInfo, z.ZodTypeDef, JsAssetInfo>>], z.ZodUnknown>, z.ZodString>]>>;
1197
1197
  uniqueName: z.ZodOptional<z.ZodString>;
1198
1198
  chunkLoadingGlobal: z.ZodOptional<z.ZodString>;
1199
1199
  enabledLibraryTypes: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEnum<["var", "module", "assign", "assign-properties", "this", "window", "self", "global", "commonjs", "commonjs2", "commonjs-module", "commonjs-static", "amd", "amd-require", "umd", "umd2", "jsonp", "system"]>, z.ZodString]>, "many">>;
@@ -1386,7 +1386,7 @@ declare const output: z.ZodObject<{
1386
1386
  hotUpdateMainFilename?: string | undefined;
1387
1387
  hotUpdateChunkFilename?: string | undefined;
1388
1388
  hotUpdateGlobal?: string | undefined;
1389
- assetModuleFilename?: string | undefined;
1389
+ assetModuleFilename?: string | ((args_0: import("@rspack/binding").JsPathData, args_1: JsAssetInfo | undefined, ...args_2: unknown[]) => string) | undefined;
1390
1390
  uniqueName?: string | undefined;
1391
1391
  chunkLoadingGlobal?: string | undefined;
1392
1392
  enabledLibraryTypes?: string[] | undefined;
@@ -1477,7 +1477,7 @@ declare const output: z.ZodObject<{
1477
1477
  hotUpdateMainFilename?: string | undefined;
1478
1478
  hotUpdateChunkFilename?: string | undefined;
1479
1479
  hotUpdateGlobal?: string | undefined;
1480
- assetModuleFilename?: string | undefined;
1480
+ assetModuleFilename?: string | ((args_0: import("@rspack/binding").JsPathData, args_1: JsAssetInfo | undefined, ...args_2: unknown[]) => string) | undefined;
1481
1481
  uniqueName?: string | undefined;
1482
1482
  chunkLoadingGlobal?: string | undefined;
1483
1483
  enabledLibraryTypes?: string[] | undefined;
@@ -5967,7 +5967,7 @@ export declare const rspackOptions: z.ZodObject<{
5967
5967
  hotUpdateMainFilename: z.ZodOptional<z.ZodString>;
5968
5968
  hotUpdateChunkFilename: z.ZodOptional<z.ZodString>;
5969
5969
  hotUpdateGlobal: z.ZodOptional<z.ZodString>;
5970
- assetModuleFilename: z.ZodOptional<z.ZodString>;
5970
+ assetModuleFilename: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodType<import("@rspack/binding").JsPathData, z.ZodTypeDef, import("@rspack/binding").JsPathData>, z.ZodOptional<z.ZodType<JsAssetInfo, z.ZodTypeDef, JsAssetInfo>>], z.ZodUnknown>, z.ZodString>]>>;
5971
5971
  uniqueName: z.ZodOptional<z.ZodString>;
5972
5972
  chunkLoadingGlobal: z.ZodOptional<z.ZodString>;
5973
5973
  enabledLibraryTypes: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEnum<["var", "module", "assign", "assign-properties", "this", "window", "self", "global", "commonjs", "commonjs2", "commonjs-module", "commonjs-static", "amd", "amd-require", "umd", "umd2", "jsonp", "system"]>, z.ZodString]>, "many">>;
@@ -6160,7 +6160,7 @@ export declare const rspackOptions: z.ZodObject<{
6160
6160
  hotUpdateMainFilename?: string | undefined;
6161
6161
  hotUpdateChunkFilename?: string | undefined;
6162
6162
  hotUpdateGlobal?: string | undefined;
6163
- assetModuleFilename?: string | undefined;
6163
+ assetModuleFilename?: string | ((args_0: import("@rspack/binding").JsPathData, args_1: JsAssetInfo | undefined, ...args_2: unknown[]) => string) | undefined;
6164
6164
  uniqueName?: string | undefined;
6165
6165
  chunkLoadingGlobal?: string | undefined;
6166
6166
  enabledLibraryTypes?: string[] | undefined;
@@ -6251,7 +6251,7 @@ export declare const rspackOptions: z.ZodObject<{
6251
6251
  hotUpdateMainFilename?: string | undefined;
6252
6252
  hotUpdateChunkFilename?: string | undefined;
6253
6253
  hotUpdateGlobal?: string | undefined;
6254
- assetModuleFilename?: string | undefined;
6254
+ assetModuleFilename?: string | ((args_0: import("@rspack/binding").JsPathData, args_1: JsAssetInfo | undefined, ...args_2: unknown[]) => string) | undefined;
6255
6255
  uniqueName?: string | undefined;
6256
6256
  chunkLoadingGlobal?: string | undefined;
6257
6257
  enabledLibraryTypes?: string[] | undefined;
@@ -8054,7 +8054,7 @@ export declare const rspackOptions: z.ZodObject<{
8054
8054
  hotUpdateMainFilename?: string | undefined;
8055
8055
  hotUpdateChunkFilename?: string | undefined;
8056
8056
  hotUpdateGlobal?: string | undefined;
8057
- assetModuleFilename?: string | undefined;
8057
+ assetModuleFilename?: string | ((args_0: import("@rspack/binding").JsPathData, args_1: JsAssetInfo | undefined, ...args_2: unknown[]) => string) | undefined;
8058
8058
  uniqueName?: string | undefined;
8059
8059
  chunkLoadingGlobal?: string | undefined;
8060
8060
  enabledLibraryTypes?: string[] | undefined;
@@ -8579,7 +8579,7 @@ export declare const rspackOptions: z.ZodObject<{
8579
8579
  hotUpdateMainFilename?: string | undefined;
8580
8580
  hotUpdateChunkFilename?: string | undefined;
8581
8581
  hotUpdateGlobal?: string | undefined;
8582
- assetModuleFilename?: string | undefined;
8582
+ assetModuleFilename?: string | ((args_0: import("@rspack/binding").JsPathData, args_1: JsAssetInfo | undefined, ...args_2: unknown[]) => string) | undefined;
8583
8583
  uniqueName?: string | undefined;
8584
8584
  chunkLoadingGlobal?: string | undefined;
8585
8585
  enabledLibraryTypes?: string[] | undefined;
@@ -118,7 +118,7 @@ const entry = entryStatic.or(zod_1.z.function().returns(entryStatic.or(zod_1.z.p
118
118
  //#region Output
119
119
  const path = zod_1.z.string();
120
120
  const pathinfo = zod_1.z.boolean().or(zod_1.z.literal("verbose"));
121
- const assetModuleFilename = zod_1.z.string();
121
+ const assetModuleFilename = filename;
122
122
  const webassemblyModuleFilename = zod_1.z.string();
123
123
  const chunkFilename = filename;
124
124
  const crossOriginLoading = zod_1.z
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const assert_1 = __importDefault(require("assert"));
15
+ const node_assert_1 = __importDefault(require("node:assert"));
16
16
  const builtin_plugin_1 = require("../builtin-plugin");
17
17
  class EntryOptionPlugin {
18
18
  apply(compiler) {
@@ -29,7 +29,7 @@ class EntryOptionPlugin {
29
29
  for (const name of Object.keys(entry)) {
30
30
  const desc = entry[name];
31
31
  const options = EntryOptionPlugin.entryDescriptionToOptions(compiler, name, desc);
32
- (0, assert_1.default)(desc.import !== undefined, "desc.import should not be `undefined` once `EntryOptionPlugin.applyEntryOption` is called");
32
+ (0, node_assert_1.default)(desc.import !== undefined, "desc.import should not be `undefined` once `EntryOptionPlugin.applyEntryOption` is called");
33
33
  for (const entry of desc.import) {
34
34
  new builtin_plugin_1.EntryPlugin(context, entry, options).apply(compiler);
35
35
  }
@@ -3,7 +3,7 @@
3
3
  Author Jarid Margolin @jaridmargolin
4
4
  */
5
5
  "use strict";
6
- const inspect = require("util").inspect.custom;
6
+ const inspect = require("node:util").inspect.custom;
7
7
  // /** @typedef {import("./Chunk")} Chunk */
8
8
  // /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
9
9
  // /** @typedef {import("./Module")} Module */
@@ -26,15 +26,15 @@ var _LoaderObject_loaderItem;
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.parsePathQueryFragment = exports.runLoaders = exports.LoaderObject = void 0;
28
28
  const node_querystring_1 = __importDefault(require("node:querystring"));
29
- const assert_1 = __importDefault(require("assert"));
30
- const util_1 = require("util");
29
+ const node_assert_1 = __importDefault(require("node:assert"));
30
+ const node_util_1 = require("node:util");
31
31
  const binding_1 = require("@rspack/binding");
32
32
  const webpack_sources_1 = require("../../compiled/webpack-sources");
33
33
  const Module_1 = require("../Module");
34
34
  const NormalModule_1 = require("../NormalModule");
35
35
  const RspackError_1 = require("../RspackError");
36
36
  const adapterRuleUse_1 = require("../config/adapterRuleUse");
37
- const util_2 = require("../util");
37
+ const util_1 = require("../util");
38
38
  const createHash_1 = require("../util/createHash");
39
39
  const identifier_1 = require("../util/identifier");
40
40
  const memoize_1 = require("../util/memoize");
@@ -123,14 +123,14 @@ class LoaderObject {
123
123
  return __classPrivateFieldGet(this, _LoaderObject_loaderItem, "f").pitchExecuted;
124
124
  }
125
125
  set pitchExecuted(value) {
126
- (0, assert_1.default)(value);
126
+ (0, node_assert_1.default)(value);
127
127
  __classPrivateFieldGet(this, _LoaderObject_loaderItem, "f").pitchExecuted = true;
128
128
  }
129
129
  get normalExecuted() {
130
130
  return __classPrivateFieldGet(this, _LoaderObject_loaderItem, "f").normalExecuted;
131
131
  }
132
132
  set normalExecuted(value) {
133
- (0, assert_1.default)(value);
133
+ (0, node_assert_1.default)(value);
134
134
  __classPrivateFieldGet(this, _LoaderObject_loaderItem, "f").normalExecuted = true;
135
135
  }
136
136
  // A data object shared between the pitch and the normal phase
@@ -167,14 +167,14 @@ exports.LoaderObject = LoaderObject;
167
167
  _LoaderObject_loaderItem = new WeakMap();
168
168
  class JsSourceMap {
169
169
  static __from_binding(map) {
170
- return (0, util_2.isNil)(map) ? undefined : (0, util_2.toObject)(map);
170
+ return (0, util_1.isNil)(map) ? undefined : (0, util_1.toObject)(map);
171
171
  }
172
172
  static __to_binding(map) {
173
- return (0, util_2.serializeObject)(map);
173
+ return (0, util_1.serializeObject)(map);
174
174
  }
175
175
  }
176
- const loadLoaderAsync = (0, util_1.promisify)(loadLoader_1.default);
177
- const runSyncOrAsync = (0, util_1.promisify)(function runSyncOrAsync(fn, context, args, callback) {
176
+ const loadLoaderAsync = (0, node_util_1.promisify)(loadLoader_1.default);
177
+ const runSyncOrAsync = (0, node_util_1.promisify)(function runSyncOrAsync(fn, context, args, callback) {
178
178
  let isSync = true;
179
179
  let isDone = false;
180
180
  let isError = false; // internal error
@@ -516,9 +516,9 @@ async function runLoaders(compiler, context) {
516
516
  }
517
517
  const hasStack = !!error.stack;
518
518
  error.name = "ModuleError";
519
- error.message = `${error.message} (from: ${(0, util_2.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;
519
+ error.message = `${error.message} (from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;
520
520
  !hasStack && Error.captureStackTrace(error);
521
- error = (0, util_2.concatErrorMsgAndStack)(error);
521
+ error = (0, util_1.concatErrorMsgAndStack)(error);
522
522
  error.moduleIdentifier = this._module.identifier();
523
523
  compiler._lastCompilation.__internal__pushDiagnostic({
524
524
  error,
@@ -531,9 +531,9 @@ async function runLoaders(compiler, context) {
531
531
  }
532
532
  const hasStack = !!warning.stack;
533
533
  warning.name = "ModuleWarning";
534
- warning.message = `${warning.message} (from: ${(0, util_2.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;
534
+ warning.message = `${warning.message} (from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;
535
535
  hasStack && Error.captureStackTrace(warning);
536
- warning = (0, util_2.concatErrorMsgAndStack)(warning);
536
+ warning = (0, util_1.concatErrorMsgAndStack)(warning);
537
537
  warning.moduleIdentifier = this._module.identifier();
538
538
  compiler._lastCompilation.__internal__pushDiagnostic({
539
539
  error: warning,
@@ -661,8 +661,8 @@ async function runLoaders(compiler, context) {
661
661
  const hasArg = args.some(value => value !== undefined);
662
662
  if (hasArg) {
663
663
  const [content, sourceMap, additionalData] = args;
664
- context.content = (0, util_2.isNil)(content) ? null : (0, util_2.toBuffer)(content);
665
- context.sourceMap = (0, util_2.serializeObject)(sourceMap);
664
+ context.content = (0, util_1.isNil)(content) ? null : (0, util_1.toBuffer)(content);
665
+ context.sourceMap = (0, util_1.serializeObject)(sourceMap);
666
666
  context.additionalData = additionalData;
667
667
  break;
668
668
  }
@@ -691,7 +691,7 @@ async function runLoaders(compiler, context) {
691
691
  [content, sourceMap, additionalData] =
692
692
  (await runSyncOrAsync(fn, loaderContext, args)) || [];
693
693
  }
694
- context.content = (0, util_2.isNil)(content) ? null : (0, util_2.toBuffer)(content);
694
+ context.content = (0, util_1.isNil)(content) ? null : (0, util_1.toBuffer)(content);
695
695
  context.sourceMap = JsSourceMap.__to_binding(sourceMap);
696
696
  context.additionalData = additionalData;
697
697
  break;
@@ -16,7 +16,7 @@ module.exports = function loadLoader(loader, callback) {
16
16
  if (loader.type === "module") {
17
17
  try {
18
18
  if (url === undefined)
19
- url = require("url");
19
+ url = require("node:url");
20
20
  var loaderUrl = url.pathToFileURL(loader.path);
21
21
  /** @type {Promise<any>} */
22
22
  var modulePromise = eval("import(" + JSON.stringify(loaderUrl.toString()) + ")");
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const util_1 = __importDefault(require("util"));
15
+ const node_util_1 = __importDefault(require("node:util"));
16
16
  const watchpack_1 = __importDefault(require("../../compiled/watchpack"));
17
17
  class NodeWatchFileSystem {
18
18
  constructor(inputFileSystem) {
@@ -91,7 +91,7 @@ class NodeWatchFileSystem {
91
91
  this.watcher.pause();
92
92
  }
93
93
  },
94
- getAggregatedRemovals: util_1.default.deprecate(() => {
94
+ getAggregatedRemovals: node_util_1.default.deprecate(() => {
95
95
  const items = this.watcher && this.watcher.aggregatedRemovals;
96
96
  if (items && this.inputFileSystem && this.inputFileSystem.purge) {
97
97
  const fs = this.inputFileSystem;
@@ -101,7 +101,7 @@ class NodeWatchFileSystem {
101
101
  }
102
102
  return items;
103
103
  }, "Watcher.getAggregatedRemovals is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_GET_AGGREGATED_REMOVALS"),
104
- getAggregatedChanges: util_1.default.deprecate(() => {
104
+ getAggregatedChanges: node_util_1.default.deprecate(() => {
105
105
  const items = this.watcher && this.watcher.aggregatedChanges;
106
106
  if (items && this.inputFileSystem && this.inputFileSystem.purge) {
107
107
  const fs = this.inputFileSystem;
@@ -111,10 +111,10 @@ class NodeWatchFileSystem {
111
111
  }
112
112
  return items;
113
113
  }, "Watcher.getAggregatedChanges is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_GET_AGGREGATED_CHANGES"),
114
- getFileTimeInfoEntries: util_1.default.deprecate(() => {
114
+ getFileTimeInfoEntries: node_util_1.default.deprecate(() => {
115
115
  return fetchTimeInfo().fileTimeInfoEntries;
116
116
  }, "Watcher.getFileTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_FILE_TIME_INFO_ENTRIES"),
117
- getContextTimeInfoEntries: util_1.default.deprecate(() => {
117
+ getContextTimeInfoEntries: node_util_1.default.deprecate(() => {
118
118
  return fetchTimeInfo().contextTimeInfoEntries;
119
119
  }, "Watcher.getContextTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_CONTEXT_TIME_INFO_ENTRIES"),
120
120
  getInfo: () => {
@@ -31,7 +31,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
31
  __setModuleDefault(result, mod);
32
32
  return result;
33
33
  };
34
- const util = __importStar(require("util"));
34
+ const util = __importStar(require("node:util"));
35
35
  const truncateArgs_1 = require("../logging/truncateArgs");
36
36
  module.exports = ({ colors, appendOnly, stream }) => {
37
37
  // @ts-expect-error
package/dist/rspack.js CHANGED
@@ -13,8 +13,8 @@ exports.Stats = exports.rspack = exports.MultiStats = exports.createMultiCompile
13
13
  * Copyright (c) JS Foundation and other contributors
14
14
  * https://github.com/webpack/webpack/blob/main/LICENSE
15
15
  */
16
- const assert_1 = __importDefault(require("assert"));
17
- const util_1 = __importDefault(require("util"));
16
+ const node_assert_1 = __importDefault(require("node:assert"));
17
+ const node_util_1 = __importDefault(require("node:util"));
18
18
  const Compiler_1 = require("./Compiler");
19
19
  const MultiCompiler_1 = require("./MultiCompiler");
20
20
  const MultiStats_1 = __importDefault(require("./MultiStats"));
@@ -24,7 +24,7 @@ Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { r
24
24
  const config_1 = require("./config");
25
25
  const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin"));
26
26
  const rspackOptionsApply_1 = require("./rspackOptionsApply");
27
- const util_2 = require("./util");
27
+ const util_1 = require("./util");
28
28
  const validate_1 = require("./util/validate");
29
29
  function createMultiCompiler(options) {
30
30
  const compilers = options.map(createCompiler);
@@ -40,7 +40,7 @@ exports.createMultiCompiler = createMultiCompiler;
40
40
  function createCompiler(userOptions) {
41
41
  const options = (0, config_1.getNormalizedRspackOptions)(userOptions);
42
42
  (0, config_1.applyRspackOptionsBaseDefaults)(options);
43
- (0, assert_1.default)(!(0, util_2.isNil)(options.context));
43
+ (0, node_assert_1.default)(!(0, util_1.isNil)(options.context));
44
44
  const compiler = new Compiler_1.Compiler(options.context, options);
45
45
  new NodeEnvironmentPlugin_1.default({
46
46
  infrastructureLogging: options.infrastructureLogging
@@ -68,7 +68,7 @@ function isMultiRspackOptions(o) {
68
68
  }
69
69
  function rspack(options, callback) {
70
70
  try {
71
- for (const o of (0, util_2.asArray)(options)) {
71
+ for (const o of (0, util_1.asArray)(options)) {
72
72
  (0, validate_1.validate)(o, config_1.rspackOptions);
73
73
  }
74
74
  }
@@ -114,7 +114,7 @@ function rspack(options, callback) {
114
114
  else {
115
115
  const { compiler, watch } = create();
116
116
  if (watch) {
117
- util_1.default.deprecate(() => { }, "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
117
+ node_util_1.default.deprecate(() => { }, "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
118
118
  }
119
119
  return compiler;
120
120
  }
@@ -13,7 +13,7 @@ exports.RspackOptionsApply = void 0;
13
13
  * Copyright (c) JS Foundation and other contributors
14
14
  * https://github.com/webpack/webpack/blob/main/LICENSE
15
15
  */
16
- const assert_1 = __importDefault(require("assert"));
16
+ const node_assert_1 = __importDefault(require("node:assert"));
17
17
  const graceful_fs_1 = __importDefault(require("../compiled/graceful-fs"));
18
18
  const Module_1 = require("./Module");
19
19
  const builtin_plugin_1 = require("./builtin-plugin");
@@ -26,12 +26,12 @@ const assertNotNil_1 = require("./util/assertNotNil");
26
26
  class RspackOptionsApply {
27
27
  constructor() { }
28
28
  process(options, compiler) {
29
- (0, assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
29
+ (0, node_assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
30
30
  compiler.outputPath = options.output.path;
31
31
  compiler.name = options.name;
32
32
  compiler.outputFileSystem = graceful_fs_1.default;
33
33
  if (options.externals) {
34
- (0, assert_1.default)(options.externalsType, "options.externalsType should have value after `applyRspackOptionsDefaults`");
34
+ (0, node_assert_1.default)(options.externalsType, "options.externalsType should have value after `applyRspackOptionsDefaults`");
35
35
  new builtin_plugin_1.ExternalsPlugin(options.externalsType, options.externals).apply(compiler);
36
36
  }
37
37
  if (options.externalsPresets.node) {
@@ -183,9 +183,9 @@ const ASSETS_GROUPERS = {
183
183
  });
184
184
  };
185
185
  groupByNames("chunkNames");
186
- // groupByNames("auxiliaryChunkNames");
187
- // groupByNames("chunkIdHints");
188
- // groupByNames("auxiliaryChunkIdHints");
186
+ groupByNames("auxiliaryChunkNames");
187
+ groupByNames("chunkIdHints");
188
+ groupByNames("auxiliaryChunkIdHints");
189
189
  },
190
190
  excludeAssets: (groupConfigs, context, { excludeAssets }) => {
191
191
  groupConfigs.push({
@@ -623,22 +623,51 @@ const SIMPLE_EXTRACTORS = {
623
623
  object.outputPath = compilation.outputOptions.path;
624
624
  },
625
625
  assets: (object, compilation, context, options, factory) => {
626
- const { assets, assetsByChunkName } = context
626
+ const { assets: compilationAssets, assetsByChunkName } = context
627
627
  .getInner(compilation)
628
628
  .getAssets();
629
+ const assetMap = new Map();
630
+ const assets = new Set();
631
+ for (const asset of compilationAssets) {
632
+ const item = {
633
+ ...asset,
634
+ type: "asset",
635
+ related: []
636
+ };
637
+ assets.add(item);
638
+ assetMap.set(asset.name, item);
639
+ }
640
+ for (const item of assetMap.values()) {
641
+ const related = item.info.related;
642
+ if (!related)
643
+ continue;
644
+ for (const { name: type, value: relatedEntry } of related) {
645
+ const deps = Array.isArray(relatedEntry)
646
+ ? relatedEntry
647
+ : [relatedEntry];
648
+ for (const dep of deps) {
649
+ const depItem = assetMap.get(dep);
650
+ if (!depItem)
651
+ continue;
652
+ assets.delete(depItem);
653
+ depItem.type = type;
654
+ item.related = item.related || [];
655
+ item.related.push(depItem);
656
+ }
657
+ }
658
+ }
629
659
  object.assetsByChunkName = assetsByChunkName.reduce((acc, cur) => {
630
660
  acc[cur.name] = cur.files;
631
661
  return acc;
632
662
  }, {});
633
- const groupedAssets = factory.create(`${context.type}.assets`, assets, {
663
+ const groupedAssets = factory.create(`${context.type}.assets`, Array.from(assets), {
634
664
  ...context
635
665
  // compilationFileToChunks
636
666
  // compilationAuxiliaryFileToChunks
637
667
  });
638
668
  const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Number.POSITIVE_INFINITY);
639
- // object.filteredAssets = limited.filteredChildren;
640
- // const limited = spaceLimited(groupedAssets, options.assetsSpace);
641
669
  object.assets = limited.children;
670
+ object.filteredAssets = limited.filteredChildren;
642
671
  },
643
672
  chunks: (object, compilation, context, options, factory) => {
644
673
  const { type } = context;
@@ -738,15 +767,21 @@ const SIMPLE_EXTRACTORS = {
738
767
  asset$visible: {
739
768
  _: (object, asset) => {
740
769
  object.chunkNames = asset.chunkNames;
741
- // - chunkIdHints
742
- // - auxiliaryChunkNames
743
- // - auxiliaryChunkIdHints
744
- // - filteredRelated
770
+ object.chunkIdHints = asset.chunkIdHints.filter(Boolean);
771
+ object.auxiliaryChunkNames = asset.auxiliaryChunkNames;
772
+ object.auxiliaryChunkIdHints =
773
+ asset.auxiliaryChunkIdHints.filter(Boolean);
774
+ },
775
+ relatedAssets: (object, asset, context, options, factory) => {
776
+ const { type } = context;
777
+ object.related = factory.create(`${type.slice(0, -8)}.related`, asset.related, context);
778
+ object.filteredRelated = asset.related
779
+ ? asset.related.length - object.related.length
780
+ : undefined;
745
781
  },
746
- // relatedAssets
747
782
  ids: (object, asset) => {
748
783
  object.chunks = asset.chunks;
749
- // - auxiliaryChunks
784
+ object.auxiliaryChunks = asset.auxiliaryChunks;
750
785
  }
751
786
  },
752
787
  chunkGroup: {
@@ -81,7 +81,7 @@ const SIMPLE_PRINTERS = {
81
81
  statusMessage = `compiled ${green("successfully")}`;
82
82
  }
83
83
  else {
84
- statusMessage = `compiled`;
84
+ statusMessage = "compiled";
85
85
  }
86
86
  if (builtAtMessage ||
87
87
  versionMessage ||
@@ -2,20 +2,19 @@ import type * as binding from "@rspack/binding";
2
2
  import type { Compilation, NormalizedStatsOptions } from "../Compilation";
3
3
  import { type Comparator } from "../util/comparators";
4
4
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
5
+ type Writable<T> = {
6
+ -readonly [K in keyof T]: T[K];
7
+ };
5
8
  export type KnownStatsChunkGroup = binding.JsStatsChunkGroup;
6
- export type KnownStatsChunk = Omit<binding.JsStatsChunk, "sizes"> & {
9
+ export type KnownStatsChunk = Omit<Writable<binding.JsStatsChunk>, "sizes"> & {
7
10
  sizes: Record<string, number>;
8
11
  };
9
- export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related"> & {
10
- related: Record<string, string[]>;
11
- };
12
+ export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related">;
12
13
  export type StatsChunkGroup = binding.JsStatsChunkGroup & Record<string, any>;
13
- export type KnownStatsAsset = Omit<binding.JsStatsAsset, "info"> & {
14
- info: KnownStatsAssetInfo;
15
- };
14
+ export type KnownStatsAsset = Omit<binding.JsStatsAsset, "info">;
16
15
  export type StatsAsset = KnownStatsAsset & Record<string, any>;
17
16
  export type StatsChunk = KnownStatsChunk & Record<string, any>;
18
- export type KnownStatsModule = Omit<binding.JsStatsModule, "usedExports" | "providedExports" | "optimizationBailout" | "sizes"> & {
17
+ export type KnownStatsModule = Omit<Writable<binding.JsStatsModule>, "usedExports" | "providedExports" | "optimizationBailout" | "sizes"> & {
19
18
  profile?: StatsProfile;
20
19
  usedExports?: null | string[] | boolean;
21
20
  providedExports?: null | string[];
@@ -42,7 +41,7 @@ export type StatsModuleTraceItem = {
42
41
  originId?: string;
43
42
  moduleId?: string;
44
43
  };
45
- export type StatsModuleReason = binding.JsStatsModuleReason & Record<string, any>;
44
+ export type StatsModuleReason = Writable<binding.JsStatsModuleReason> & Record<string, any>;
46
45
  export type KnownStatsCompilation = {
47
46
  /**
48
47
  * webpack version.
@@ -98,7 +97,7 @@ export type KnownStatsChunkOrigin = {
98
97
  type ExtractorsByOption<T, O> = {
99
98
  [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void;
100
99
  };
101
- type PreprocessedAsset = StatsAsset & {
100
+ export type PreprocessedAsset = StatsAsset & {
102
101
  type: string;
103
102
  related: PreprocessedAsset[];
104
103
  info: binding.JsStatsAssetInfo;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.checkVersion = void 0;
7
- const fs_1 = require("fs");
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const NodePlatformArchToAbi = {
10
10
  android: {
11
11
  arm64: "",
@@ -39,11 +39,11 @@ function isMusl() {
39
39
  // For Node 10
40
40
  if (!process.report || typeof process.report.getReport !== "function") {
41
41
  try {
42
- const lddPath = require("child_process")
42
+ const lddPath = require("node:child_process")
43
43
  .execSync("which ldd")
44
44
  .toString()
45
45
  .trim();
46
- return (0, fs_1.readFileSync)(lddPath, "utf8").includes("musl");
46
+ return (0, node_fs_1.readFileSync)(lddPath, "utf8").includes("musl");
47
47
  }
48
48
  catch (e) {
49
49
  return true;
@@ -96,8 +96,8 @@ const checkVersion = () => {
96
96
  }
97
97
  let ADDON_VERSION;
98
98
  try {
99
- const BINDING_PKG_DIR = path_1.default.dirname(require.resolve("@rspack/binding/package.json"));
100
- const isLocal = (0, fs_1.readdirSync)(BINDING_PKG_DIR).some(item => item === `rspack.${platformArchAbi}.node`);
99
+ const BINDING_PKG_DIR = node_path_1.default.dirname(require.resolve("@rspack/binding/package.json"));
100
+ const isLocal = (0, node_fs_1.readdirSync)(BINDING_PKG_DIR).some(item => item === `rspack.${platformArchAbi}.node`);
101
101
  if (isLocal) {
102
102
  // Treat addon version the same as binding version if running locally
103
103
  ADDON_VERSION = BINDING_VERSION;
@@ -159,11 +159,11 @@ const createHash = algorithm => {
159
159
  return new BatchedHash(createMd4());
160
160
  case "native-md4":
161
161
  if (crypto === undefined)
162
- crypto = require("crypto");
162
+ crypto = require("node:crypto");
163
163
  return new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
164
164
  default:
165
165
  if (crypto === undefined)
166
- crypto = require("crypto");
166
+ crypto = require("node:crypto");
167
167
  return new BulkUpdateDecorator(() => crypto.createHash(algorithm), algorithm);
168
168
  }
169
169
  };
package/dist/util/fs.js CHANGED
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.mkdirp = exports.rmrf = void 0;
16
- const assert_1 = __importDefault(require("assert"));
17
- const path_1 = __importDefault(require("path"));
16
+ const node_assert_1 = __importDefault(require("node:assert"));
17
+ const node_path_1 = __importDefault(require("node:path"));
18
18
  function rmrf(fs, p, callback) {
19
19
  fs.stat(p, (err, stats) => {
20
20
  if (err) {
@@ -34,7 +34,7 @@ function rmrf(fs, p, callback) {
34
34
  }
35
35
  else {
36
36
  files.forEach(file => {
37
- (0, assert_1.default)(typeof file === "string");
37
+ (0, node_assert_1.default)(typeof file === "string");
38
38
  const fullPath = join(fs, p, file);
39
39
  rmrf(fs, fullPath, err => {
40
40
  if (err) {
@@ -59,11 +59,11 @@ const join = (fs, rootPath, filename) => {
59
59
  if (fs && fs.join) {
60
60
  return fs.join(rootPath, filename);
61
61
  }
62
- else if (path_1.default.posix.isAbsolute(rootPath)) {
63
- return path_1.default.posix.join(rootPath, filename);
62
+ else if (node_path_1.default.posix.isAbsolute(rootPath)) {
63
+ return node_path_1.default.posix.join(rootPath, filename);
64
64
  }
65
- else if (path_1.default.win32.isAbsolute(rootPath)) {
66
- return path_1.default.win32.join(rootPath, filename);
65
+ else if (node_path_1.default.win32.isAbsolute(rootPath)) {
66
+ return node_path_1.default.win32.join(rootPath, filename);
67
67
  }
68
68
  else {
69
69
  throw new Error(`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`);
@@ -73,11 +73,11 @@ const dirname = (fs, absPath) => {
73
73
  if (fs && fs.dirname) {
74
74
  return fs.dirname(absPath);
75
75
  }
76
- else if (path_1.default.posix.isAbsolute(absPath)) {
77
- return path_1.default.posix.dirname(absPath);
76
+ else if (node_path_1.default.posix.isAbsolute(absPath)) {
77
+ return node_path_1.default.posix.dirname(absPath);
78
78
  }
79
- else if (path_1.default.win32.isAbsolute(absPath)) {
80
- return path_1.default.win32.dirname(absPath);
79
+ else if (node_path_1.default.win32.isAbsolute(absPath)) {
80
+ return node_path_1.default.win32.dirname(absPath);
81
81
  }
82
82
  else {
83
83
  throw new Error(`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`);
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getUndoPath = exports.parseResourceWithoutFragment = exports.parseResource = exports.absolutify = exports.contextify = exports.makePathsAbsolute = exports.makePathsRelative = void 0;
10
- const path_1 = __importDefault(require("path"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
11
  const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
12
12
  const SEGMENTS_SPLIT_REGEXP = /([|!])/;
13
13
  const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
@@ -37,7 +37,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
37
37
  let resource = querySplitPos === -1
38
38
  ? maybeAbsolutePath
39
39
  : maybeAbsolutePath.slice(0, querySplitPos);
40
- resource = relativePathToRequest(path_1.default.posix.relative(context, resource));
40
+ resource = relativePathToRequest(node_path_1.default.posix.relative(context, resource));
41
41
  return querySplitPos === -1
42
42
  ? resource
43
43
  : resource + maybeAbsolutePath.slice(querySplitPos);
@@ -47,7 +47,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
47
47
  let resource = querySplitPos === -1
48
48
  ? maybeAbsolutePath
49
49
  : maybeAbsolutePath.slice(0, querySplitPos);
50
- resource = path_1.default.win32.relative(context, resource);
50
+ resource = node_path_1.default.win32.relative(context, resource);
51
51
  if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {
52
52
  resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"));
53
53
  }
@@ -65,7 +65,7 @@ const absoluteToRequest = (context, maybeAbsolutePath) => {
65
65
  */
66
66
  const requestToAbsolute = (context, relativePath) => {
67
67
  if (relativePath.startsWith("./") || relativePath.startsWith("../"))
68
- return path_1.default.join(context, relativePath);
68
+ return node_path_1.default.join(context, relativePath);
69
69
  return relativePath;
70
70
  };
71
71
  const makeCacheable = (realFn) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.5",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -58,8 +58,8 @@
58
58
  "dependencies": {
59
59
  "@module-federation/runtime-tools": "0.2.3",
60
60
  "caniuse-lite": "^1.0.30001616",
61
- "@rspack/lite-tapable": "1.0.0-alpha.4",
62
- "@rspack/binding": "1.0.0-alpha.4"
61
+ "@rspack/binding": "1.0.0-alpha.5",
62
+ "@rspack/lite-tapable": "1.0.0-alpha.5"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@swc/helpers": ">=0.5.1"