@rspack/core 1.1.2 → 1.1.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.
@@ -16,8 +16,10 @@ import { ChunkGraph } from "./ChunkGraph";
16
16
  import { ChunkGroup } from "./ChunkGroup";
17
17
  import type { Compiler } from "./Compiler";
18
18
  import type { ContextModuleFactory } from "./ContextModuleFactory";
19
+ import { Dependency } from "./Dependency";
19
20
  import { Entrypoint } from "./Entrypoint";
20
21
  import { type CodeGenerationResult, Module } from "./Module";
22
+ import ModuleGraph from "./ModuleGraph";
21
23
  import type { NormalModuleFactory } from "./NormalModuleFactory";
22
24
  import type { ResolverFactory } from "./ResolverFactory";
23
25
  import { type RspackError } from "./RspackError";
@@ -196,6 +198,7 @@ export declare class Compilation {
196
198
  childrenCounters: Record<string, number>;
197
199
  children: Compilation[];
198
200
  chunkGraph: ChunkGraph;
201
+ moduleGraph: ModuleGraph;
199
202
  fileSystemInfo: {
200
203
  createSnapshot(): null;
201
204
  };
@@ -391,12 +394,18 @@ export declare class Compilation {
391
394
  static PROCESS_ASSETS_STAGE_ANALYSE: number;
392
395
  static PROCESS_ASSETS_STAGE_REPORT: number;
393
396
  }
394
- export type EntryData = binding.JsEntryData;
397
+ export declare class EntryData {
398
+ dependencies: Dependency[];
399
+ includeDependencies: Dependency[];
400
+ options: binding.JsEntryOptions;
401
+ static __from_binding(binding: binding.JsEntryData): EntryData;
402
+ private constructor();
403
+ }
395
404
  export declare class Entries implements Map<string, EntryData> {
396
405
  #private;
397
406
  constructor(data: binding.JsEntries);
398
407
  clear(): void;
399
- forEach(callback: (value: binding.JsEntryData, key: string, map: Map<string, binding.JsEntryData>) => void, thisArg?: any): void;
408
+ forEach(callback: (value: EntryData, key: string, map: Map<string, EntryData>) => void, thisArg?: any): void;
400
409
  get size(): number;
401
410
  entries(): ReturnType<Map<string, EntryData>["entries"]>;
402
411
  values(): ReturnType<Map<string, EntryData>["values"]>;
@@ -1,9 +1,11 @@
1
1
  import type { JsDependency } from "@rspack/binding";
2
2
  export declare class Dependency {
3
+ #private;
3
4
  readonly type: string;
4
5
  readonly category: string;
5
6
  readonly request: string | undefined;
6
7
  critical: boolean;
7
8
  static __from_binding(binding: JsDependency): Dependency;
9
+ static __to_binding(data: Dependency): JsDependency;
8
10
  private constructor();
9
11
  }
package/dist/Module.d.ts CHANGED
@@ -76,6 +76,7 @@ export declare class Module {
76
76
  readonly blocks: DependenciesBlock[];
77
77
  readonly useSourceMap: boolean;
78
78
  static __from_binding(binding: JsModule, compilation?: Compilation): Module;
79
+ static __to_binding(module: Module): JsModule;
79
80
  constructor(module: JsModule, compilation?: Compilation);
80
81
  originalSource(): Source | null;
81
82
  identifier(): string;
@@ -0,0 +1,10 @@
1
+ import type { JsModuleGraph } from "@rspack/binding";
2
+ import { Dependency } from "./Dependency";
3
+ import { Module } from "./Module";
4
+ export default class ModuleGraph {
5
+ #private;
6
+ static __from_binding(binding: JsModuleGraph): ModuleGraph;
7
+ private constructor();
8
+ getModule(dependency: Dependency): Module | null;
9
+ getIssuer(module: Module): Module | null;
10
+ }
@@ -1,9 +1,8 @@
1
- import { BuiltinPluginName } from "@rspack/binding";
2
- import type { SourceMapDevToolPluginOptions } from "./SourceMapDevToolPlugin";
1
+ import { BuiltinPluginName, type RawSourceMapDevToolPluginOptions } from "@rspack/binding";
3
2
  export declare const EvalSourceMapDevToolPlugin: {
4
- new (options: SourceMapDevToolPluginOptions): {
3
+ new (options: RawSourceMapDevToolPluginOptions): {
5
4
  name: BuiltinPluginName;
6
- _args: [options: SourceMapDevToolPluginOptions];
5
+ _args: [options: RawSourceMapDevToolPluginOptions];
7
6
  affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
8
7
  raw(compiler: import("..").Compiler): import("@rspack/binding").BuiltinPlugin;
9
8
  apply(compiler: import("..").Compiler): void;
@@ -1,24 +1,11 @@
1
1
  import { BuiltinPluginName, type RawSourceMapDevToolPluginOptions } from "@rspack/binding";
2
- /**
3
- * Include source maps for modules based on their extension (defaults to .js and .css).
4
- */
5
- type Rules = Rule[] | Rule;
6
- /**
7
- * Include source maps for modules based on their extension (defaults to .js and .css).
8
- */
9
- type Rule = RegExp | string;
10
- export interface SourceMapDevToolPluginOptions extends Omit<RawSourceMapDevToolPluginOptions, "test" | "include" | "exclude"> {
11
- exclude?: Rules;
12
- include?: Rules;
13
- test?: Rules;
14
- }
2
+ export type { RawSourceMapDevToolPluginOptions as SourceMapDevToolPluginOptions };
15
3
  export declare const SourceMapDevToolPlugin: {
16
- new (options: SourceMapDevToolPluginOptions): {
4
+ new (options: RawSourceMapDevToolPluginOptions): {
17
5
  name: BuiltinPluginName;
18
- _args: [options: SourceMapDevToolPluginOptions];
6
+ _args: [options: RawSourceMapDevToolPluginOptions];
19
7
  affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
20
8
  raw(compiler: import("..").Compiler): import("@rspack/binding").BuiltinPlugin;
21
9
  apply(compiler: import("..").Compiler): void;
22
10
  };
23
11
  };
24
- export {};
@@ -1,10 +1,7 @@
1
- import { BuiltinPluginName } from "@rspack/binding";
2
- export declare const WebWorkerTemplatePlugin: {
3
- new (): {
4
- name: BuiltinPluginName;
5
- _args: [];
6
- affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
- raw(compiler: import("..").Compiler): import("@rspack/binding").BuiltinPlugin;
8
- apply(compiler: import("..").Compiler): void;
9
- };
10
- };
1
+ import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
+ import type { Compiler } from "../Compiler";
3
+ import { RspackBuiltinPlugin } from "./base";
4
+ export declare class WebWorkerTemplatePlugin extends RspackBuiltinPlugin {
5
+ name: BuiltinPluginName;
6
+ raw(compiler: Compiler): BuiltinPlugin | undefined;
7
+ }
package/dist/index.js CHANGED
@@ -1091,10 +1091,15 @@ var import_binding3 = require("@rspack/binding");
1091
1091
 
1092
1092
  // src/Dependency.ts
1093
1093
  var Dependency = class _Dependency {
1094
+ #inner;
1094
1095
  static __from_binding(binding3) {
1095
1096
  return new _Dependency(binding3);
1096
1097
  }
1098
+ static __to_binding(data) {
1099
+ return data.#inner;
1100
+ }
1097
1101
  constructor(binding3) {
1102
+ this.#inner = binding3;
1098
1103
  Object.defineProperties(this, {
1099
1104
  type: {
1100
1105
  enumerable: true,
@@ -1328,6 +1333,9 @@ var Module = class _Module {
1328
1333
  MODULE_MAPPINGS.set(binding3, module2);
1329
1334
  return module2;
1330
1335
  }
1336
+ static __to_binding(module2) {
1337
+ return module2.#inner;
1338
+ }
1331
1339
  constructor(module2, compilation) {
1332
1340
  this.#inner = module2;
1333
1341
  Object.defineProperties(this, {
@@ -1547,6 +1555,25 @@ var cutOffByFlag = (stack, flag) => {
1547
1555
  };
1548
1556
  var cutOffLoaderExecution = (stack) => cutOffByFlag(stack, loaderFlag);
1549
1557
 
1558
+ // src/ModuleGraph.ts
1559
+ var ModuleGraph = class _ModuleGraph {
1560
+ static __from_binding(binding3) {
1561
+ return new _ModuleGraph(binding3);
1562
+ }
1563
+ #inner;
1564
+ constructor(binding3) {
1565
+ this.#inner = binding3;
1566
+ }
1567
+ getModule(dependency) {
1568
+ const binding3 = this.#inner.getModule(Dependency.__to_binding(dependency));
1569
+ return binding3 ? Module.__from_binding(binding3) : null;
1570
+ }
1571
+ getIssuer(module2) {
1572
+ const binding3 = this.#inner.getIssuer(Module.__to_binding(module2));
1573
+ return binding3 ? Module.__from_binding(binding3) : null;
1574
+ }
1575
+ };
1576
+
1550
1577
  // src/util/index.ts
1551
1578
  function isNil(value) {
1552
1579
  return value === null || value === void 0;
@@ -2906,6 +2933,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2906
2933
  this.childrenCounters = {};
2907
2934
  this.children = [];
2908
2935
  this.chunkGraph = new ChunkGraph(this);
2936
+ this.moduleGraph = ModuleGraph.__from_binding(inner.moduleGraph);
2909
2937
  }
2910
2938
  get hash() {
2911
2939
  return __privateGet(this, _inner).hash;
@@ -3613,6 +3641,18 @@ _Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER = 3e3;
3613
3641
  _Compilation.PROCESS_ASSETS_STAGE_ANALYSE = 4e3;
3614
3642
  _Compilation.PROCESS_ASSETS_STAGE_REPORT = 5e3;
3615
3643
  var Compilation = _Compilation;
3644
+ var EntryData = class _EntryData {
3645
+ static __from_binding(binding3) {
3646
+ return new _EntryData(binding3);
3647
+ }
3648
+ constructor(binding3) {
3649
+ this.dependencies = binding3.dependencies.map(Dependency.__from_binding);
3650
+ this.includeDependencies = binding3.includeDependencies.map(
3651
+ Dependency.__from_binding
3652
+ );
3653
+ this.options = binding3.options;
3654
+ }
3655
+ };
3616
3656
  var Entries = class {
3617
3657
  #data;
3618
3658
  constructor(data) {
@@ -3622,7 +3662,8 @@ var Entries = class {
3622
3662
  this.#data.clear();
3623
3663
  }
3624
3664
  forEach(callback, thisArg) {
3625
- for (const [key, value] of this) {
3665
+ for (const [key, binding3] of this) {
3666
+ const value = EntryData.__from_binding(binding3);
3626
3667
  callback.call(thisArg, value, key, this);
3627
3668
  }
3628
3669
  }
@@ -3635,7 +3676,7 @@ var Entries = class {
3635
3676
  }
3636
3677
  }
3637
3678
  values() {
3638
- return this.#data.values()[Symbol.iterator]();
3679
+ return this.#data.values().map(EntryData.__from_binding)[Symbol.iterator]();
3639
3680
  }
3640
3681
  [Symbol.iterator]() {
3641
3682
  return this.entries();
@@ -3654,7 +3695,8 @@ var Entries = class {
3654
3695
  return this.#data.delete(key);
3655
3696
  }
3656
3697
  get(key) {
3657
- return this.#data.get(key);
3698
+ const binding3 = this.#data.get(key);
3699
+ return binding3 ? EntryData.__from_binding(binding3) : void 0;
3658
3700
  }
3659
3701
  keys() {
3660
3702
  return this.#data.keys()[Symbol.iterator]();
@@ -12060,57 +12102,9 @@ var SizeLimitsPlugin = create2(
12060
12102
 
12061
12103
  // src/builtin-plugin/SourceMapDevToolPlugin.ts
12062
12104
  var import_binding64 = require("@rspack/binding");
12063
-
12064
- // src/lib/ModuleFilenameHelpers.ts
12065
- var ModuleFilenameHelpers_exports = {};
12066
- __export(ModuleFilenameHelpers_exports, {
12067
- asRegExp: () => asRegExp,
12068
- matchObject: () => matchObject,
12069
- matchPart: () => matchPart
12070
- });
12071
- var asRegExp = (test) => {
12072
- if (typeof test === "string") {
12073
- return new RegExp(`^${test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")}`);
12074
- }
12075
- return test;
12076
- };
12077
- var matchPart = (str, test) => {
12078
- if (!test) return true;
12079
- if (Array.isArray(test)) {
12080
- return test.map(asRegExp).some((regExp) => regExp.test(str));
12081
- }
12082
- return asRegExp(test).test(str);
12083
- };
12084
- var matchObject = (obj, str) => {
12085
- if (obj.test) {
12086
- if (!matchPart(str, obj.test)) {
12087
- return false;
12088
- }
12089
- }
12090
- if (obj.include) {
12091
- if (!matchPart(str, obj.include)) {
12092
- return false;
12093
- }
12094
- }
12095
- if (obj.exclude) {
12096
- if (matchPart(str, obj.exclude)) {
12097
- return false;
12098
- }
12099
- }
12100
- return true;
12101
- };
12102
-
12103
- // src/builtin-plugin/SourceMapDevToolPlugin.ts
12104
12105
  var SourceMapDevToolPlugin = create2(
12105
12106
  import_binding64.BuiltinPluginName.SourceMapDevToolPlugin,
12106
- (options) => {
12107
- const { test, include, exclude, ...rest } = options;
12108
- const rawOptions = rest;
12109
- if (test || include || exclude) {
12110
- rawOptions.test = (text) => matchObject({ test, include, exclude }, text);
12111
- }
12112
- return rawOptions;
12113
- },
12107
+ (options) => options,
12114
12108
  "compilation"
12115
12109
  );
12116
12110
 
@@ -12376,10 +12370,16 @@ var WarnCaseSensitiveModulesPlugin = create2(
12376
12370
 
12377
12371
  // src/builtin-plugin/WebWorkerTemplatePlugin.ts
12378
12372
  var import_binding70 = require("@rspack/binding");
12379
- var WebWorkerTemplatePlugin = create2(
12380
- import_binding70.BuiltinPluginName.WebWorkerTemplatePlugin,
12381
- () => void 0
12382
- );
12373
+ var WebWorkerTemplatePlugin = class extends RspackBuiltinPlugin {
12374
+ constructor() {
12375
+ super(...arguments);
12376
+ this.name = import_binding70.BuiltinPluginName.WebWorkerTemplatePlugin;
12377
+ }
12378
+ raw(compiler) {
12379
+ compiler.options.output.chunkLoading = "import-scripts";
12380
+ return createBuiltinPlugin(this.name, void 0);
12381
+ }
12382
+ };
12383
12383
 
12384
12384
  // src/builtin-plugin/WorkerPlugin.ts
12385
12385
  var import_binding71 = require("@rspack/binding");
@@ -18368,6 +18368,45 @@ var RspackOptionsApply = class {
18368
18368
  }
18369
18369
  };
18370
18370
 
18371
+ // src/lib/ModuleFilenameHelpers.ts
18372
+ var ModuleFilenameHelpers_exports = {};
18373
+ __export(ModuleFilenameHelpers_exports, {
18374
+ asRegExp: () => asRegExp,
18375
+ matchObject: () => matchObject,
18376
+ matchPart: () => matchPart
18377
+ });
18378
+ var asRegExp = (test) => {
18379
+ if (typeof test === "string") {
18380
+ return new RegExp(`^${test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")}`);
18381
+ }
18382
+ return test;
18383
+ };
18384
+ var matchPart = (str, test) => {
18385
+ if (!test) return true;
18386
+ if (Array.isArray(test)) {
18387
+ return test.map(asRegExp).some((regExp) => regExp.test(str));
18388
+ }
18389
+ return asRegExp(test).test(str);
18390
+ };
18391
+ var matchObject = (obj, str) => {
18392
+ if (obj.test) {
18393
+ if (!matchPart(str, obj.test)) {
18394
+ return false;
18395
+ }
18396
+ }
18397
+ if (obj.include) {
18398
+ if (!matchPart(str, obj.include)) {
18399
+ return false;
18400
+ }
18401
+ }
18402
+ if (obj.exclude) {
18403
+ if (matchPart(str, obj.exclude)) {
18404
+ return false;
18405
+ }
18406
+ }
18407
+ return true;
18408
+ };
18409
+
18371
18410
  // src/lib/DllPlugin.ts
18372
18411
  var import_zod5 = __toESM(require("../compiled/zod/index.js"));
18373
18412
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -61,7 +61,7 @@
61
61
  "@module-federation/runtime-tools": "0.5.1",
62
62
  "@rspack/lite-tapable": "1.0.1",
63
63
  "caniuse-lite": "^1.0.30001616",
64
- "@rspack/binding": "1.1.2"
64
+ "@rspack/binding": "1.1.4"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@swc/helpers": ">=0.5.1"