@rspack-debug/browser 2.0.0-rc.0 → 2.0.0-rc.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.
@@ -1,5 +1,6 @@
1
- import type { Dependency, JsModuleGraph, ModuleGraphConnection } from './binding';
1
+ import type { Dependency, JsModuleGraph } from './binding';
2
2
  import { ExportsInfo } from './ExportsInfo';
3
+ import type { ModuleGraphConnection } from './ModuleGraphConnection';
3
4
  import type { Module } from './Module';
4
5
  export default class ModuleGraph {
5
6
  #private;
@@ -0,0 +1,10 @@
1
+ import binding, { ModuleGraphConnection as BindingModuleGraphConnection } from './binding';
2
+ type ModuleGraphConnectionConstructor = typeof BindingModuleGraphConnection & {
3
+ readonly TRANSITIVE_ONLY: typeof binding.TRANSITIVE_ONLY_SYMBOL;
4
+ readonly CIRCULAR_CONNECTION: typeof binding.CIRCULAR_CONNECTION_SYMBOL;
5
+ };
6
+ export interface ModuleGraphConnection extends BindingModuleGraphConnection {
7
+ }
8
+ export declare const ModuleGraphConnection: ModuleGraphConnectionConstructor;
9
+ export type ConnectionState = boolean | typeof ModuleGraphConnection.TRANSITIVE_ONLY | typeof ModuleGraphConnection.CIRCULAR_CONNECTION;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type RawHashedModuleIdsPluginOptions } from '../binding';
2
+ export declare const HashedModuleIdsPlugin: {
3
+ new (options?: RawHashedModuleIdsPluginOptions | undefined): {
4
+ name: string;
5
+ _args: [options?: RawHashedModuleIdsPluginOptions | undefined];
6
+ affectedHooks: keyof import("..").CompilerHooks | undefined;
7
+ raw(compiler: import("..").Compiler): import("../binding").BuiltinPlugin;
8
+ apply(compiler: import("..").Compiler): void;
9
+ };
10
+ };
@@ -1,9 +1,9 @@
1
- export declare const SideEffectsFlagPlugin: {
2
- new (): {
3
- name: string;
4
- _args: [];
5
- affectedHooks: keyof import("..").CompilerHooks | undefined;
6
- raw(compiler: import("..").Compiler): import("../binding").BuiltinPlugin;
7
- apply(compiler: import("..").Compiler): void;
8
- };
9
- };
1
+ import { type BuiltinPlugin, BuiltinPluginName } from '../binding';
2
+ import { RspackBuiltinPlugin } from './base';
3
+ export declare class SideEffectsFlagPlugin extends RspackBuiltinPlugin {
4
+ private analyzeSideEffectsFree;
5
+ name: BuiltinPluginName;
6
+ affectedHooks: "compilation";
7
+ constructor(analyzeSideEffectsFree?: boolean);
8
+ raw(): BuiltinPlugin;
9
+ }
@@ -36,6 +36,7 @@ export * from './FetchCompileAsyncWasmPlugin';
36
36
  export * from './FileUriPlugin';
37
37
  export * from './FlagDependencyExportsPlugin';
38
38
  export * from './FlagDependencyUsagePlugin';
39
+ export * from './HashedModuleIdsPlugin';
39
40
  export * from './HotModuleReplacementPlugin';
40
41
  export * from './HttpExternalsRspackPlugin';
41
42
  export * from './HttpUriPlugin';
@@ -82,5 +83,4 @@ export * from './SplitChunksPlugin';
82
83
  export * from './SubresourceIntegrityPlugin';
83
84
  export * from './SwcJsMinimizerPlugin';
84
85
  export * from './URLPlugin';
85
- export * from './WebWorkerTemplatePlugin';
86
86
  export * from './WorkerPlugin';
@@ -186,7 +186,7 @@ export interface LoaderContext<OptionsType = {}> {
186
186
  */
187
187
  request: string;
188
188
  /**
189
- * An array of all the loaders. It is writeable in the pitch phase.
189
+ * An array of all the loaders. It is writable in the pitch phase.
190
190
  * loaders = [{request: string, path: string, query: string, module: function}]
191
191
  *
192
192
  * In the example:
@@ -10,7 +10,7 @@
10
10
  import type { ReadStream } from 'node:fs';
11
11
  import type { IncomingMessage, ServerResponse } from 'node:http';
12
12
  import type { ServerOptions } from 'node:https';
13
- import type { Server as ConnectApplication, NextFunction } from 'connect-next';
13
+ import type { NextFunction } from 'connect-next';
14
14
  import type { Filter as ProxyFilter, Options as ProxyOptions } from 'http-proxy-middleware';
15
15
  import type { Options as OpenOptions } from 'open';
16
16
  import type { Compiler, Configuration, LiteralUnion, MultiCompiler, MultiStats, Stats, Watching } from '..';
@@ -153,7 +153,7 @@ export type DevServerClient = {
153
153
  webSocketTransport?: LiteralUnion<'ws', string>;
154
154
  webSocketURL?: string | DevServerWebSocketURL;
155
155
  };
156
- export type DevServerOptions<A extends BasicApplication = ConnectApplication, S extends BasicServer = BasicServer> = {
156
+ export type DevServerOptions<A extends BasicApplication = BasicApplication, S extends BasicServer = BasicServer> = {
157
157
  ipc?: string | boolean;
158
158
  host?: DevServerHost;
159
159
  port?: Port;
@@ -102,6 +102,7 @@ export interface ExperimentsNormalized {
102
102
  useInputFileSystem?: false | RegExp[];
103
103
  nativeWatcher?: boolean;
104
104
  deferImport?: boolean;
105
+ pureFunctions?: boolean;
105
106
  }
106
107
  export type IgnoreWarningsNormalized = ((warning: WebpackError, compilation: Compilation) => boolean)[];
107
108
  export type OptimizationRuntimeChunkNormalized = false | {
@@ -137,7 +138,7 @@ export interface RspackOptionsNormalized {
137
138
  incremental?: false | Incremental;
138
139
  watch?: Watch;
139
140
  watchOptions: WatchOptions;
140
- devServer?: DevServer;
141
+ devServer?: false | DevServer;
141
142
  ignoreWarnings?: IgnoreWarningsNormalized;
142
143
  performance?: Performance;
143
144
  amd?: Amd;
@@ -153,7 +153,7 @@ export type EntryStatic = EntryObject | EntryUnnamed;
153
153
  export type EntryDynamic = () => EntryStatic | Promise<EntryStatic>;
154
154
  /** The entry options for building */
155
155
  export type Entry = EntryStatic | EntryDynamic;
156
- /** The output directory as an absolute path. */
156
+ /** The output directory. Relative paths are resolved against `context`. */
157
157
  export type Path = string;
158
158
  /** Tells Rspack to include comments in bundles with information about the contained modules. */
159
159
  export type Pathinfo = boolean | 'verbose';
@@ -210,7 +210,7 @@ export type WorkerPublicPath = string;
210
210
  /** Controls [Trusted Types](https://web.dev/articles/trusted-types) compatibility. */
211
211
  export type TrustedTypes = {
212
212
  /**
213
- * The name of the Trusted Types policy created by webpack to serve bundle chunks.
213
+ * The name of the Trusted Types policy created by Rspack to serve bundle chunks.
214
214
  */
215
215
  policyName?: string;
216
216
  /**
@@ -288,7 +288,7 @@ export type Environment = {
288
288
  module?: boolean;
289
289
  /**
290
290
  * Determines if the node: prefix is generated for core module imports in environments that support it.
291
- * This is only applicable to Webpack runtime code.
291
+ * This is only applicable to Rspack runtime code.
292
292
  * */
293
293
  nodePrefixForCoreModules?: boolean;
294
294
  /** The environment supports optional chaining ('obj?.a' or 'obj?.()'). */
@@ -298,7 +298,7 @@ export type Environment = {
298
298
  };
299
299
  export type Output = {
300
300
  /**
301
- * The output directory as an absolute path.
301
+ * The output directory. Relative paths are resolved against `context`.
302
302
  * @default path.resolve(process.cwd(), 'dist')
303
303
  * */
304
304
  path?: Path;
@@ -631,8 +631,30 @@ export type RuleSetLoaderWithOptions = {
631
631
  };
632
632
  export type RuleSetUseItem = RuleSetLoader | RuleSetLoaderWithOptions;
633
633
  export type RuleSetUse = RuleSetUseItem | RuleSetUseItem[] | ((data: RawFuncUseCtx) => RuleSetUseItem[]);
634
+ export type RuleSetRuleUseAndLoader = {
635
+ /** A loader name */
636
+ loader: RuleSetLoader;
637
+ /** A loader options */
638
+ options?: RuleSetLoaderOptions;
639
+ /** An array to pass the Loader package name and its options. */
640
+ use?: never;
641
+ } | {
642
+ /** A loader name */
643
+ loader?: never;
644
+ /** A loader options */
645
+ options?: never;
646
+ /** An array to pass the Loader package name and its options. */
647
+ use: RuleSetUse;
648
+ } | {
649
+ /** A loader name */
650
+ loader?: never;
651
+ /** A loader options */
652
+ options?: never;
653
+ /** An array to pass the Loader package name and its options. */
654
+ use?: never;
655
+ };
634
656
  /** Rule defines the conditions for matching a module and the behavior of handling those modules. */
635
- export type RuleSetRule = {
657
+ export type RuleSetRule = RuleSetRuleUseAndLoader & {
636
658
  /** Matches all modules that match this resource, and will match against Resource. */
637
659
  test?: RuleSetCondition;
638
660
  /** Excludes all modules that match this condition and will match against the absolute path of the resource */
@@ -663,12 +685,6 @@ export type RuleSetRule = {
663
685
  type?: string;
664
686
  /** Used to mark the layer of the matching module. */
665
687
  layer?: string;
666
- /** A loader name */
667
- loader?: RuleSetLoader;
668
- /** A loader options */
669
- options?: RuleSetLoaderOptions;
670
- /** An array to pass the Loader package name and its options. */
671
- use?: RuleSetUse;
672
688
  /**
673
689
  * Parser options for the specific modules that matched by the rule conditions
674
690
  * It will override the parser options in module.parser.
@@ -807,7 +823,6 @@ export type JavascriptParserOptions = {
807
823
  dynamicImportFetchPriority?: 'low' | 'high' | 'auto';
808
824
  /**
809
825
  * Enable or disable evaluating import.meta. Set to 'preserve-unknown' to preserve unknown properties for runtime evaluation.
810
- * @default 'preserve-unknown'
811
826
  */
812
827
  importMeta?: boolean | 'preserve-unknown';
813
828
  /**
@@ -898,6 +913,11 @@ export type JavascriptParserOptions = {
898
913
  * @default false
899
914
  */
900
915
  importMetaResolve?: boolean;
916
+ /**
917
+ * Flag top-level exported functions as side-effect-free for pure-function-based tree shaking.
918
+ * @experimental
919
+ */
920
+ pureFunctions?: string[];
901
921
  };
902
922
  export type JsonParserOptions = {
903
923
  /**
@@ -1354,6 +1374,8 @@ export type MemoryCacheOptions = {
1354
1374
  */
1355
1375
  export type CacheOptions = boolean | MemoryCacheOptions | PersistentCacheOptions;
1356
1376
  export type StatsPresets = 'normal' | 'none' | 'verbose' | 'errors-only' | 'errors-warnings' | 'minimal' | 'detailed' | 'summary';
1377
+ type AssetFilterItemTypes = RegExp | string | ((name: string, asset: any) => boolean);
1378
+ type AssetFilterTypes = boolean | AssetFilterItemTypes | AssetFilterItemTypes[];
1357
1379
  type ModuleFilterItemTypes = RegExp | string | ((name: string, module: any, type: any) => boolean);
1358
1380
  type ModuleFilterTypes = boolean | ModuleFilterItemTypes | ModuleFilterItemTypes[];
1359
1381
  export type StatsColorOptions = {
@@ -1638,7 +1660,7 @@ export type StatsOptions = {
1638
1660
  * Exclude the matching assets information.
1639
1661
  * @default false
1640
1662
  */
1641
- excludeAssets?: ModuleFilterTypes;
1663
+ excludeAssets?: AssetFilterTypes;
1642
1664
  /**
1643
1665
  * Specifies the sorting order for modules.
1644
1666
  * @default 'id'
@@ -1818,6 +1840,13 @@ type SharedOptimizationSplitChunksCacheGroup = {
1818
1840
  */
1819
1841
  minSize?: OptimizationSplitChunksSizes;
1820
1842
  minSizeReduction?: OptimizationSplitChunksSizes;
1843
+ /**
1844
+ * Size threshold at which splitting is enforced and other restrictions
1845
+ * (minRemainingSize, maxAsyncRequests, maxInitialRequests) are ignored.
1846
+ * The value is `50000` in production mode.
1847
+ * The value is `30000` in others mode.
1848
+ */
1849
+ enforceSizeThreshold?: OptimizationSplitChunksSizes;
1821
1850
  /** Maximum size, in bytes, for a chunk to be generated. */
1822
1851
  maxSize?: OptimizationSplitChunksSizes;
1823
1852
  /** Maximum size, in bytes, for a async chunk to be generated. */
@@ -1900,8 +1929,10 @@ export type OptimizationSplitChunksOptions = {
1900
1929
  export type Optimization = {
1901
1930
  /**
1902
1931
  * Which algorithm to use when choosing module ids.
1932
+ * Setting to `false` disables the built-in algorithm, allowing a custom plugin
1933
+ * (e.g. HashedModuleIdsPlugin) to provide module ids instead.
1903
1934
  */
1904
- moduleIds?: 'named' | 'natural' | 'deterministic';
1935
+ moduleIds?: false | 'named' | 'natural' | 'deterministic' | 'hashed';
1905
1936
  /**
1906
1937
  * Which algorithm to use when choosing chunk ids.
1907
1938
  */
@@ -2199,19 +2230,24 @@ export type Experiments = {
2199
2230
  * @default false
2200
2231
  */
2201
2232
  deferImport?: boolean;
2233
+ /**
2234
+ * Enable pure-function-based side-effects analysis.
2235
+ * @default false
2236
+ */
2237
+ pureFunctions?: boolean;
2202
2238
  };
2203
2239
  export type Watch = boolean;
2204
2240
  /** Options for watch mode. */
2205
2241
  export type WatchOptions = {
2206
2242
  /**
2207
2243
  * Add a delay before rebuilding once the first file changed.
2208
- * This allows webpack to aggregate any other changes made during this time period into one rebuild.
2244
+ * This allows Rspack to aggregate any other changes made during this time period into one rebuild.
2209
2245
  * @default 5
2210
2246
  */
2211
2247
  aggregateTimeout?: number;
2212
2248
  /**
2213
2249
  * Follow symlinks while looking for files.
2214
- * This is usually not needed as webpack already resolves symlinks ('resolve.symlinks' and 'resolve.alias').
2250
+ * This is usually not needed as Rspack already resolves symlinks ('resolve.symlinks' and 'resolve.alias').
2215
2251
  */
2216
2252
  followSymlinks?: boolean;
2217
2253
  /**
@@ -2270,13 +2306,13 @@ export type Performance = false | {
2270
2306
  */
2271
2307
  hints?: false | 'warning' | 'error';
2272
2308
  /**
2273
- * File size limit (in bytes) when exceeded, that webpack will provide performance hints.
2274
- * @default 250000
2309
+ * File size limit (in bytes) when exceeded, Rspack will provide performance hints.
2310
+ * @default 307200 (300 KiB)
2275
2311
  */
2276
2312
  maxAssetSize?: number;
2277
2313
  /**
2278
2314
  * Total size of an entry point (in bytes).
2279
- * @default 250000
2315
+ * @default 512000 (500 KiB)
2280
2316
  */
2281
2317
  maxEntrypointSize?: number;
2282
2318
  };
@@ -2400,7 +2436,7 @@ export type RspackOptions = {
2400
2436
  /**
2401
2437
  * Configuration for the development server.
2402
2438
  */
2403
- devServer?: DevServer;
2439
+ devServer?: false | DevServer;
2404
2440
  /**
2405
2441
  * Options for module configuration.
2406
2442
  */
package/dist/exports.d.ts CHANGED
@@ -16,6 +16,7 @@ export { ExternalModule } from './ExternalModule';
16
16
  export type { ResolveData, ResourceDataWithData } from './Module';
17
17
  export { Module } from './Module';
18
18
  export type { default as ModuleGraph } from './ModuleGraph';
19
+ export { ModuleGraphConnection, type ConnectionState, } from './ModuleGraphConnection';
19
20
  export { MultiStats } from './MultiStats';
20
21
  export { NormalModule } from './NormalModule';
21
22
  export type { NormalModuleFactory } from './NormalModuleFactory';
@@ -56,9 +57,11 @@ export { LoaderOptionsPlugin } from './lib/LoaderOptionsPlugin';
56
57
  export { LoaderTargetPlugin } from './lib/LoaderTargetPlugin';
57
58
  export type { OutputFileSystem, WatchFileSystem } from './util/fs';
58
59
  import { FetchCompileAsyncWasmPlugin, lazyCompilationMiddleware, rsc, SubresourceIntegrityPlugin } from './builtin-plugin';
60
+ import JsonpTemplatePlugin from './web/JsonpTemplatePlugin';
59
61
  export { SubresourceIntegrityPlugin };
60
62
  interface Web {
61
63
  FetchCompileAsyncWasmPlugin: typeof FetchCompileAsyncWasmPlugin;
64
+ JsonpTemplatePlugin: typeof JsonpTemplatePlugin;
62
65
  }
63
66
  export declare const web: Web;
64
67
  import { NodeTargetPlugin } from './builtin-plugin';
@@ -76,6 +79,11 @@ interface Electron {
76
79
  ElectronTargetPlugin: typeof ElectronTargetPlugin;
77
80
  }
78
81
  export declare const electron: Electron;
82
+ import { HashedModuleIdsPlugin } from './builtin-plugin';
83
+ interface Ids {
84
+ HashedModuleIdsPlugin: typeof HashedModuleIdsPlugin;
85
+ }
86
+ export declare const ids: Ids;
79
87
  import { EnableLibraryPlugin } from './builtin-plugin';
80
88
  interface Library {
81
89
  EnableLibraryPlugin: typeof EnableLibraryPlugin;
@@ -92,7 +100,7 @@ interface JavaScript {
92
100
  JavascriptModulesPlugin: typeof JavascriptModulesPlugin;
93
101
  }
94
102
  export declare const javascript: JavaScript;
95
- import { WebWorkerTemplatePlugin } from './builtin-plugin';
103
+ import WebWorkerTemplatePlugin from './webworker/WebWorkerTemplatePlugin';
96
104
  interface Webworker {
97
105
  WebWorkerTemplatePlugin: typeof WebWorkerTemplatePlugin;
98
106
  }