@rspack/core 1.1.1 → 1.1.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.
package/dist/Chunk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type JsChunk, type JsChunkPathData, type JsCompilation } from "@rspack/binding";
1
+ import { type JsChunk, type JsCompilation } from "@rspack/binding";
2
2
  import { Compilation } from ".";
3
3
  import { ChunkGroup } from "./ChunkGroup";
4
4
  export declare class Chunk {
@@ -37,5 +37,4 @@ export declare class Chunk {
37
37
  * @internal
38
38
  */
39
39
  __internal__innerUkey(): number;
40
- __internal_to_path_data_chunk(): JsChunkPathData;
41
40
  }
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type * as binding from "@rspack/binding";
11
- import { type ExternalObject, type JsCompilation, type JsPathData, type JsRuntimeModule } from "@rspack/binding";
11
+ import { type ExternalObject, type JsCompilation, type JsRuntimeModule } from "@rspack/binding";
12
12
  import * as liteTapable from "@rspack/lite-tapable";
13
13
  import type { Source } from "../compiled/webpack-sources";
14
14
  import { Chunk } from "./Chunk";
@@ -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";
@@ -37,8 +39,21 @@ export interface Asset {
37
39
  source: Source;
38
40
  info: AssetInfo;
39
41
  }
40
- export type PathData = Omit<JsPathData, "chunk"> & {
41
- chunk?: Chunk | binding.JsChunkPathData;
42
+ export type PathDataChunkLike = {
43
+ id?: string;
44
+ name?: string;
45
+ hash?: string;
46
+ contentHash?: Record<string, string>;
47
+ };
48
+ export type PathData = {
49
+ filename?: string;
50
+ hash?: string;
51
+ contentHash?: string;
52
+ runtime?: string;
53
+ url?: string;
54
+ id?: string;
55
+ chunk?: Chunk | PathDataChunkLike;
56
+ contentHashType?: string;
42
57
  };
43
58
  export interface LogEntry {
44
59
  type: string;
@@ -183,6 +198,7 @@ export declare class Compilation {
183
198
  childrenCounters: Record<string, number>;
184
199
  children: Compilation[];
185
200
  chunkGraph: ChunkGraph;
201
+ moduleGraph: ModuleGraph;
186
202
  fileSystemInfo: {
187
203
  createSnapshot(): null;
188
204
  };
@@ -378,12 +394,18 @@ export declare class Compilation {
378
394
  static PROCESS_ASSETS_STAGE_ANALYSE: number;
379
395
  static PROCESS_ASSETS_STAGE_REPORT: number;
380
396
  }
381
- 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
+ }
382
404
  export declare class Entries implements Map<string, EntryData> {
383
405
  #private;
384
406
  constructor(data: binding.JsEntries);
385
407
  clear(): void;
386
- 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;
387
409
  get size(): number;
388
410
  entries(): ReturnType<Map<string, EntryData>["entries"]>;
389
411
  values(): ReturnType<Map<string, EntryData>["values"]>;
@@ -1,9 +1,11 @@
1
- import { type JsDependency, JsDependencyMut } from "@rspack/binding";
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
- static __from_binding(binding: JsDependencyMut | JsDependency): Dependency;
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
+ }
@@ -83,7 +83,12 @@ export type LoaderOptions = {
83
83
  targets?: Targets | string[] | string;
84
84
  include?: FeatureOptions;
85
85
  exclude?: FeatureOptions;
86
+ /**
87
+ * @deprecated Use `drafts` instead.
88
+ * This will be removed in the next major version.
89
+ */
86
90
  draft?: Drafts;
91
+ drafts?: Drafts;
87
92
  nonStandard?: NonStandard;
88
93
  pseudoClasses?: PseudoClasses;
89
94
  unusedSymbols?: string[];
@@ -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;
@@ -11,7 +11,12 @@ export type LightningCssMinimizerRspackPluginOptions = {
11
11
  targets?: string[] | string;
12
12
  include?: FeatureOptions;
13
13
  exclude?: FeatureOptions;
14
+ /**
15
+ * @deprecated Use `drafts` instead.
16
+ * This will be removed in the next major version.
17
+ */
14
18
  draft?: Drafts;
19
+ drafts?: Drafts;
15
20
  nonStandard?: NonStandard;
16
21
  pseudoClasses?: PseudoClasses;
17
22
  unusedSymbols?: string[];
@@ -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 {};
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type { Compilation } from "../Compilation";
11
- import type { AssetModuleFilename, Bail, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryDescription, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, ImportMetaName, Incremental, InfrastructureLogging, LazyCompilationOptions, LibraryOptions, Loader, Mode, Name, NoParseOption, Node, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./types";
11
+ import type { AssetModuleFilename, Bail, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryDescription, Environment, ExperimentCacheOptions, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, ImportMetaName, Incremental, InfrastructureLogging, LazyCompilationOptions, LibraryOptions, Loader, Mode, Name, NoParseOption, Node, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./types";
12
12
  export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized;
13
13
  export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>;
14
14
  export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
@@ -77,6 +77,7 @@ export interface ModuleOptionsNormalized {
77
77
  noParse?: NoParseOption;
78
78
  }
79
79
  export interface ExperimentsNormalized {
80
+ cache?: ExperimentCacheOptions;
80
81
  lazyCompilation?: false | LazyCompilationOptions;
81
82
  asyncWebAssembly?: boolean;
82
83
  outputModule?: boolean;
@@ -887,7 +887,7 @@ export type Target = false | AllowTarget | AllowTarget[];
887
887
  * `amd`, `umd`, `system` and `jsonp` externals depend on the `output.libraryTarget` being set to the same value e.g. you can only consume amd externals within an amd library.
888
888
  * @default 'var'
889
889
  */
890
- export type ExternalsType = "var" | "module" | "assign" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "amd" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "promise" | "import" | "module-import" | "script" | "node-commonjs";
890
+ export type ExternalsType = "var" | "module" | "assign" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "amd" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "promise" | "import" | "module-import" | "script" | "node-commonjs" | "commonjs-import";
891
891
  /**
892
892
  * External item object when both libraryTarget and externalsType is 'umd'
893
893
  */
@@ -1683,6 +1683,31 @@ export type Optimization = {
1683
1683
  * */
1684
1684
  emitOnErrors?: boolean;
1685
1685
  };
1686
+ /**
1687
+ * Options for caching snapshots and intermediate products during the build process.
1688
+ * @description Controls whether caching is enabled or disabled.
1689
+ * @default true in development mode, false in production mode
1690
+ * @example
1691
+ * // Enable caching
1692
+ * cache: true
1693
+ *
1694
+ * // Disable caching
1695
+ * cache: false
1696
+ */
1697
+ export type ExperimentCacheOptions = boolean | {
1698
+ type: "memory";
1699
+ } | {
1700
+ type: "persistent";
1701
+ snapshot: {
1702
+ immutablePaths: Array<string | RegExp>;
1703
+ unmanagedPaths: Array<string | RegExp>;
1704
+ managedPaths: Array<string | RegExp>;
1705
+ };
1706
+ storage: {
1707
+ type: "filesystem";
1708
+ directory: string;
1709
+ };
1710
+ };
1686
1711
  /**
1687
1712
  * Options for future Rspack features.
1688
1713
  */
@@ -1784,10 +1809,6 @@ export type Incremental = {
1784
1809
  * Enable incremental make.
1785
1810
  */
1786
1811
  make?: boolean;
1787
- /**
1788
- * Enable incremental asset emission.
1789
- */
1790
- emitAssets?: boolean;
1791
1812
  /**
1792
1813
  * Enable inference of async modules.
1793
1814
  */
@@ -1800,6 +1821,10 @@ export type Incremental = {
1800
1821
  * Enables diagnostics for dependencies.
1801
1822
  */
1802
1823
  dependenciesDiagnostics?: boolean;
1824
+ /**
1825
+ * Enable incremental build chunk graph.
1826
+ */
1827
+ buildChunkGraph?: boolean;
1803
1828
  /**
1804
1829
  * Enable incremental module hashes.
1805
1830
  */
@@ -1813,14 +1838,30 @@ export type Incremental = {
1813
1838
  */
1814
1839
  modulesRuntimeRequirements?: boolean;
1815
1840
  /**
1816
- * Enable incremental build chunk graph.
1841
+ * Enable incremental chunk runtime requirements.
1817
1842
  */
1818
- buildChunkGraph?: boolean;
1843
+ chunksRuntimeRequirements?: boolean;
1844
+ /**
1845
+ * Enable incremental chunk hashes.
1846
+ */
1847
+ chunksHashes?: boolean;
1848
+ /**
1849
+ * Enable incremental chunk render.
1850
+ */
1851
+ chunksRender?: boolean;
1852
+ /**
1853
+ * Enable incremental asset emission.
1854
+ */
1855
+ emitAssets?: boolean;
1819
1856
  };
1820
1857
  /**
1821
1858
  * Experimental features configuration.
1822
1859
  */
1823
1860
  export type Experiments = {
1861
+ /**
1862
+ * Enable new cache.
1863
+ */
1864
+ cache?: ExperimentCacheOptions;
1824
1865
  /**
1825
1866
  * Enable lazy compilation.
1826
1867
  */