@rspack/browser 2.1.0-beta.0 → 2.1.0

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/Module.d.ts CHANGED
@@ -5,7 +5,6 @@ import './BuildInfo';
5
5
  export type ResourceDataWithData = ResourceData & {
6
6
  data?: Record<string, any>;
7
7
  };
8
- export type CreateData = binding.JsCreateData;
9
8
  export type ContextInfo = binding.ContextInfo;
10
9
  export type ResolveData = binding.JsResolveData;
11
10
  export declare class ContextModuleFactoryBeforeResolveData {
@@ -1,9 +1,28 @@
1
+ import { EventEmitter } from 'node:events';
1
2
  import binding from './binding';
2
3
  import type Watchpack from 'watchpack';
3
4
  import type { FileSystemInfoEntry, InputFileSystem, Watcher, WatchFileSystem } from './util/fs';
5
+ /**
6
+ * Minimal watchpack-compatible shim exposed as `NativeWatchFileSystem.watcher`.
7
+ *
8
+ * It proxies the watchpack-private surface that `ts-checker-rspack-plugin` and
9
+ * `fork-ts-checker-webpack-plugin` rely on — `on`/`once` for `change`/`remove`,
10
+ * plus `_onChange`/`_onRemove` to inject events — onto the native watcher, so
11
+ * those plugins keep working under `experiments.nativeWatcher` unmodified.
12
+ *
13
+ * APIs that iterate `fileWatchers`/`directoryWatchers` are intentionally not
14
+ * supported; plugins needing those should use `WatchFileSystem.emit` instead.
15
+ */
16
+ declare class NativeWatcherShim extends EventEmitter {
17
+ #private;
18
+ constructor(trigger: (kind: 'change' | 'remove', path: string) => void);
19
+ _onChange(item: string, _mtime?: number, file?: string, _type?: string): void;
20
+ _onRemove(item: string, file?: string, _type?: string): void;
21
+ }
4
22
  export default class NativeWatchFileSystem implements WatchFileSystem {
5
23
  #private;
6
24
  constructor(inputFileSystem: InputFileSystem);
25
+ get watcher(): NativeWatcherShim | undefined;
7
26
  watch(files: Iterable<string> & {
8
27
  added?: Iterable<string>;
9
28
  removed?: Iterable<string>;
@@ -16,8 +35,18 @@ export default class NativeWatchFileSystem implements WatchFileSystem {
16
35
  }, startTime: number, options: Watchpack.WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
17
36
  getNativeWatcher(options: Watchpack.WatchOptions): binding.NativeWatcher;
18
37
  triggerEvent(kind: 'change' | 'remove' | 'create', path: string): void;
38
+ on(event: 'change', listener: (filename: string, mtime: number) => void): this;
39
+ on(event: 'remove', listener: (filename: string) => void): this;
40
+ on(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
41
+ once(event: 'change', listener: (filename: string, mtime: number) => void): this;
42
+ once(event: 'remove', listener: (filename: string) => void): this;
43
+ once(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
44
+ emit(event: 'change', filename: string, mtime: number): boolean;
45
+ emit(event: 'remove', filename: string): boolean;
46
+ emit(event: 'aggregated', changes: Set<string>, removals: Set<string>): boolean;
19
47
  formatWatchDependencies(dependencies: Iterable<string> & {
20
48
  added?: Iterable<string>;
21
49
  removed?: Iterable<string>;
22
50
  }): [string[], string[]];
23
51
  }
52
+ export {};
@@ -345,7 +345,6 @@ declare enum RuntimeGlobals {
345
345
  makeDeferredNamespaceObjectSymbol = 76
346
346
  }
347
347
  export declare const isReservedRuntimeGlobal: (r: string, compilerRuntimeGlobals: Record<string, string>) => boolean;
348
- export declare function renderModulePrefix(_compilerOptions: RspackOptionsNormalized): string;
349
348
  export declare enum RuntimeVariable {
350
349
  Require = 0,
351
350
  Context = 1,
@@ -1,4 +1,4 @@
1
- import type { Config, EnvConfig, EsParserConfig, JscConfig, ModuleConfig, ParserConfig, TerserEcmaVersion, TransformConfig, TsParserConfig } from '@swc/types';
1
+ import type { Config, EnvConfig, EsParserConfig, JscConfig, ModuleConfig, ParserConfig, TransformConfig, TsParserConfig } from '@swc/types';
2
2
  import type { CollectTypeScriptInfoOptions } from './collectTypeScriptInfo';
3
3
  import type { PluginImportOptions } from './pluginImport';
4
4
  export type SwcLoaderEnvConfig = EnvConfig;
@@ -57,62 +57,4 @@ export interface ReactServerComponentsOptions {
57
57
  */
58
58
  disableClientApiChecks?: boolean;
59
59
  }
60
- export interface TerserCompressOptions {
61
- arguments?: boolean;
62
- arrows?: boolean;
63
- booleans?: boolean;
64
- booleans_as_integers?: boolean;
65
- collapse_vars?: boolean;
66
- comparisons?: boolean;
67
- computed_props?: boolean;
68
- conditionals?: boolean;
69
- dead_code?: boolean;
70
- defaults?: boolean;
71
- directives?: boolean;
72
- drop_console?: boolean;
73
- drop_debugger?: boolean;
74
- ecma?: TerserEcmaVersion;
75
- evaluate?: boolean;
76
- expression?: boolean;
77
- global_defs?: any;
78
- hoist_funs?: boolean;
79
- hoist_props?: boolean;
80
- hoist_vars?: boolean;
81
- ie8?: boolean;
82
- if_return?: boolean;
83
- inline?: 0 | 1 | 2 | 3;
84
- join_vars?: boolean;
85
- keep_classnames?: boolean;
86
- keep_fargs?: boolean;
87
- keep_fnames?: boolean;
88
- keep_infinity?: boolean;
89
- loops?: boolean;
90
- negate_iife?: boolean;
91
- passes?: number;
92
- properties?: boolean;
93
- pure_getters?: any;
94
- pure_funcs?: string[];
95
- reduce_funcs?: boolean;
96
- reduce_vars?: boolean;
97
- sequences?: any;
98
- side_effects?: boolean;
99
- switches?: boolean;
100
- top_retain?: any;
101
- toplevel?: any;
102
- typeofs?: boolean;
103
- unsafe?: boolean;
104
- unsafe_passes?: boolean;
105
- unsafe_arrows?: boolean;
106
- unsafe_comps?: boolean;
107
- unsafe_function?: boolean;
108
- unsafe_math?: boolean;
109
- unsafe_symbols?: boolean;
110
- unsafe_methods?: boolean;
111
- unsafe_proto?: boolean;
112
- unsafe_regexp?: boolean;
113
- unsafe_undefined?: boolean;
114
- unused?: boolean;
115
- const_to_let?: boolean;
116
- module?: boolean;
117
- }
118
60
  export {};
@@ -182,7 +182,7 @@ export interface TerserCompressOptions {
182
182
  unsafe_passes?: boolean;
183
183
  unsafe_arrows?: boolean;
184
184
  unsafe_comps?: boolean;
185
- unsafe_function?: boolean;
185
+ unsafe_Function?: boolean;
186
186
  unsafe_math?: boolean;
187
187
  unsafe_symbols?: boolean;
188
188
  unsafe_methods?: boolean;
@@ -40,7 +40,7 @@ export type HtmlRspackPluginOptions = {
40
40
  * Modern browsers support non-blocking JavaScript loading ([`defer` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#defer)) to improve the page startup performance.
41
41
  *
42
42
  * Setting this option to `'module'` adds attribute `type="module"` to the `script`. This also implies `defer` attribute on the `script`, since modules are automatically deferred.
43
- * @default "defer"
43
+ * @default "module" when `output.module` is enabled, otherwise "defer"
44
44
  * */
45
45
  scriptLoading?: 'blocking' | 'defer' | 'module' | 'systemjs-module';
46
46
  /** Allows you to add only some chunks. */
@@ -83,6 +83,8 @@ export type CacheNormalized = false | {
83
83
  type: 'persistent';
84
84
  buildDependencies: string[];
85
85
  version?: string;
86
+ maxAge?: number;
87
+ maxVersions?: number;
86
88
  snapshot: {
87
89
  immutablePaths?: (string | RegExp)[];
88
90
  unmanagedPaths?: (string | RegExp)[];
@@ -91,8 +93,6 @@ export type CacheNormalized = false | {
91
93
  storage: {
92
94
  type: 'filesystem';
93
95
  directory?: string;
94
- maxAge?: number;
95
- maxGenerations?: number;
96
96
  };
97
97
  portable?: boolean;
98
98
  readonly?: boolean;
@@ -39,7 +39,7 @@ export type ChunkLoading = false | ChunkLoadingType;
39
39
  /** Whether to create a load-on-demand asynchronous chunk for entry. */
40
40
  export type AsyncChunks = boolean;
41
41
  /** Option to set the method of loading WebAssembly Modules. */
42
- export type WasmLoadingType = LiteralUnion<'fetch-streaming' | 'fetch' | 'async-node', string>;
42
+ export type WasmLoadingType = 'fetch' | 'async-node' | 'universal';
43
43
  /** Option to set the method of loading WebAssembly Modules. */
44
44
  export type WasmLoading = false | WasmLoadingType;
45
45
  export type ScriptType = false | 'text/javascript' | 'module';
@@ -194,7 +194,7 @@ export type StrictModuleErrorHandling = boolean;
194
194
  /** Indicates what global object will be used to mount the library. */
195
195
  export type GlobalObject = string;
196
196
  /** List of wasm loading types enabled for use by entry points. */
197
- export type EnabledWasmLoadingTypes = string[];
197
+ export type EnabledWasmLoadingTypes = ('...' | WasmLoadingType)[];
198
198
  /** The name of the native import() function. */
199
199
  export type ImportFunctionName = string;
200
200
  /** The name of the native import.meta object. */
@@ -1378,18 +1378,6 @@ export type CacheStorageOptions = {
1378
1378
  * @default 'node_modules/.cache/rspack/<name>-<mode>-<compilerIndex>'
1379
1379
  */
1380
1380
  directory?: string;
1381
- /**
1382
- * Maximum age of unused filesystem cache in seconds. Must be an integer
1383
- * between 0 and 4294967295.
1384
- * @default 7 * 24 * 60 * 60
1385
- */
1386
- maxAge?: number;
1387
- /**
1388
- * Maximum number of filesystem cache generations to retain in the cache
1389
- * directory. Must be an integer between 0 and 4294967295.
1390
- * @default No generation count limit; maxAge cleanup still applies
1391
- */
1392
- maxGenerations?: number;
1393
1381
  };
1394
1382
  /**
1395
1383
  * Persistent cache options.
@@ -1409,6 +1397,19 @@ export type PersistentCacheOptions = {
1409
1397
  * @default ""
1410
1398
  */
1411
1399
  version?: string;
1400
+ /**
1401
+ * Maximum age of unused filesystem cache in seconds. Must be an integer
1402
+ * between 1 and 4294967295, or Infinity to disable age-based cleanup.
1403
+ * @default 7 * 24 * 60 * 60
1404
+ */
1405
+ maxAge?: number;
1406
+ /**
1407
+ * Maximum number of filesystem cache versions to retain in the cache
1408
+ * directory. Must be an integer between 1 and 4294967295, or Infinity to
1409
+ * disable version-based cleanup.
1410
+ * @default 3
1411
+ */
1412
+ maxVersions?: number;
1412
1413
  /**
1413
1414
  * Snapshot options for determining which files have been modified.
1414
1415
  */