@rspack/browser 1.6.8 → 1.7.0-beta.1

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.
@@ -289,9 +289,14 @@ export declare class Compilation {
289
289
  getLogger(name: string | (() => string)): Logger;
290
290
  fileDependencies: {
291
291
  [Symbol.iterator](): Generator<string, void, unknown>;
292
- has(dep: string): boolean;
292
+ has: (dep: string) => boolean;
293
293
  add: (dep: string) => void;
294
294
  addAll: (deps: Iterable<string>) => void;
295
+ delete: (dep: string) => boolean;
296
+ keys(): SetIterator<string>;
297
+ values(): SetIterator<string>;
298
+ entries(): SetIterator<[string, string]>;
299
+ readonly size: number;
295
300
  };
296
301
  get __internal__addedFileDependencies(): string[];
297
302
  get __internal__removedFileDependencies(): string[];
@@ -301,21 +306,36 @@ export declare class Compilation {
301
306
  get __internal__removedMissingDependencies(): string[];
302
307
  contextDependencies: {
303
308
  [Symbol.iterator](): Generator<string, void, unknown>;
304
- has(dep: string): boolean;
309
+ has: (dep: string) => boolean;
305
310
  add: (dep: string) => void;
306
311
  addAll: (deps: Iterable<string>) => void;
312
+ delete: (dep: string) => boolean;
313
+ keys(): SetIterator<string>;
314
+ values(): SetIterator<string>;
315
+ entries(): SetIterator<[string, string]>;
316
+ readonly size: number;
307
317
  };
308
318
  missingDependencies: {
309
319
  [Symbol.iterator](): Generator<string, void, unknown>;
310
- has(dep: string): boolean;
320
+ has: (dep: string) => boolean;
311
321
  add: (dep: string) => void;
312
322
  addAll: (deps: Iterable<string>) => void;
323
+ delete: (dep: string) => boolean;
324
+ keys(): SetIterator<string>;
325
+ values(): SetIterator<string>;
326
+ entries(): SetIterator<[string, string]>;
327
+ readonly size: number;
313
328
  };
314
329
  buildDependencies: {
315
330
  [Symbol.iterator](): Generator<string, void, unknown>;
316
- has(dep: string): boolean;
331
+ has: (dep: string) => boolean;
317
332
  add: (dep: string) => void;
318
333
  addAll: (deps: Iterable<string>) => void;
334
+ delete: (dep: string) => boolean;
335
+ keys(): SetIterator<string>;
336
+ values(): SetIterator<string>;
337
+ entries(): SetIterator<[string, string]>;
338
+ readonly size: number;
319
339
  };
320
340
  getStats(): Stats;
321
341
  createChildCompiler(name: string, outputOptions: OutputNormalized, plugins: RspackPluginInstance[]): Compiler;
@@ -25,6 +25,6 @@ export interface ResolveRequest {
25
25
  export declare class Resolver {
26
26
  #private;
27
27
  constructor(binding: binding.JsResolver);
28
- resolveSync(context: object, path: string, request: string): string | false;
29
- resolve(context: object, path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void;
28
+ resolveSync(_context: object, path: string, request: string): string | false;
29
+ resolve(_context: object, path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void;
30
30
  }
@@ -351,6 +351,6 @@ export declare enum RuntimeVariable {
351
351
  StartupExec = 5
352
352
  }
353
353
  export declare function renderRuntimeVariables(variable: RuntimeVariable, _compilerOptions?: RspackOptionsNormalized): string;
354
- export declare function createCompilerRuntimeGlobals(compilerOptions?: RspackOptionsNormalized): typeof RuntimeGlobals;
355
- declare const DefaultRuntimeGlobals: typeof RuntimeGlobals;
354
+ export declare function createCompilerRuntimeGlobals(compilerOptions?: RspackOptionsNormalized): Record<keyof typeof RuntimeGlobals, string>;
355
+ declare const DefaultRuntimeGlobals: Record<"publicPath" | "chunkName" | "moduleId" | "module" | "exports" | "require" | "global" | "system" | "requireScope" | "thisAsExports" | "returnExportsFromRuntime" | "moduleLoaded" | "entryModuleId" | "moduleCache" | "moduleFactories" | "moduleFactoriesAddOnly" | "ensureChunk" | "ensureChunkHandlers" | "ensureChunkIncludeEntries" | "prefetchChunk" | "prefetchChunkHandlers" | "preloadChunk" | "preloadChunkHandlers" | "definePropertyGetters" | "makeNamespaceObject" | "createFakeNamespaceObject" | "compatGetDefaultExport" | "harmonyModuleDecorator" | "nodeModuleDecorator" | "getFullHash" | "wasmInstances" | "instantiateWasm" | "uncaughtErrorHandler" | "scriptNonce" | "loadScript" | "createScript" | "createScriptUrl" | "getTrustedTypesPolicy" | "hasFetchPriority" | "runtimeId" | "getChunkScriptFilename" | "getChunkCssFilename" | "rspackVersion" | "hasCssModules" | "rspackUniqueId" | "getChunkUpdateScriptFilename" | "getChunkUpdateCssFilename" | "startup" | "startupNoDefault" | "startupOnlyAfter" | "startupOnlyBefore" | "chunkCallback" | "startupEntrypoint" | "startupChunkDependencies" | "onChunksLoaded" | "externalInstallChunk" | "interceptModuleExecution" | "shareScopeMap" | "initializeSharing" | "currentRemoteGetScope" | "getUpdateManifestFilename" | "hmrDownloadManifest" | "hmrDownloadUpdateHandlers" | "hmrModuleData" | "hmrInvalidateModuleHandlers" | "hmrRuntimeStatePrefix" | "amdDefine" | "amdOptions" | "hasOwnProperty" | "systemContext" | "baseURI" | "relativeUrl" | "asyncModule" | "asyncModuleExportSymbol" | "makeDeferredNamespaceObject" | "makeDeferredNamespaceObjectSymbol", string>;
356
356
  export { DefaultRuntimeGlobals as RuntimeGlobals };
@@ -1,4 +1,12 @@
1
1
  import { type Compiler, MultiCompiler } from "../..";
2
2
  import type { MiddlewareHandler } from "../../config/devServer";
3
3
  export declare const LAZY_COMPILATION_PREFIX = "/lazy-compilation-using-";
4
+ /**
5
+ * Create a middleware that handles lazy compilation requests from the client.
6
+ * This function returns an Express-style middleware that listens for
7
+ * requests triggered by lazy compilation in the dev server client,
8
+ * then invokes the Rspack compiler to compile modules on demand.
9
+ * Use this middleware when integrating lazy compilation into a
10
+ * custom development server instead of relying on the built-in server.
11
+ */
4
12
  export declare const lazyCompilationMiddleware: (compiler: Compiler | MultiCompiler) => MiddlewareHandler;
@@ -17,7 +17,7 @@ export type EntryNormalized = EntryDynamicNormalized | EntryStaticNormalized;
17
17
  export interface EntryStaticNormalized {
18
18
  [k: string]: EntryDescriptionNormalized;
19
19
  }
20
- export type EntryDescriptionNormalized = Pick<EntryDescription, "runtime" | "chunkLoading" | "asyncChunks" | "publicPath" | "baseUri" | "filename" | "library" | "layer"> & {
20
+ export type EntryDescriptionNormalized = Pick<EntryDescription, "runtime" | "chunkLoading" | "wasmLoading" | "asyncChunks" | "publicPath" | "baseUri" | "filename" | "library" | "layer"> & {
21
21
  import?: string[];
22
22
  dependOn?: string[];
23
23
  };
@@ -111,18 +111,23 @@ export interface ExperimentsNormalized {
111
111
  */
112
112
  layers?: boolean;
113
113
  incremental?: false | Incremental;
114
- /**
115
- * @deprecated This option is deprecated, as it has a huge regression in some edge cases where the chunk graph has lots of cycles. We will improve performance of build_chunk_graph.
116
- */
117
- parallelCodeSplitting?: boolean;
118
114
  futureDefaults?: boolean;
119
115
  rspackFuture?: RspackFutureOptions;
120
116
  buildHttp?: HttpUriPluginOptions;
121
117
  parallelLoader?: boolean;
122
118
  useInputFileSystem?: false | RegExp[];
119
+ /**
120
+ * @deprecated This option is deprecated, it's already stable and enabled by default, Rspack will remove this option in future version
121
+ */
123
122
  inlineConst?: boolean;
123
+ /**
124
+ * @deprecated This option is deprecated, it's already stable and enabled by default, Rspack will remove this option in future version
125
+ */
124
126
  inlineEnum?: boolean;
125
127
  typeReexportsPresence?: boolean;
128
+ /**
129
+ * @deprecated This option is deprecated, it's already stable and enabled by default, Rspack will remove this option in future version
130
+ */
126
131
  lazyBarrel?: boolean;
127
132
  nativeWatcher?: boolean;
128
133
  deferImport?: boolean;
@@ -461,7 +461,13 @@ export type Output = {
461
461
  /** An optional salt to update the hash. */
462
462
  hashSalt?: HashSalt;
463
463
  /**
464
- * Create async chunks that are loaded on demand.
464
+ * Controls whether dynamically imported modules are emitted as separate async chunks or bundled into
465
+ * existing chunks.
466
+ * - `true`: Modules loaded via `import()` are split into independent async chunks. These chunks are
467
+ * emitted as separate files and are loaded on demand at runtime. This enables code splitting and keeps
468
+ * the initial bundle smaller.
469
+ * - `false`: Dynamically imported modules are bundled into existing chunks instead of being emitted as
470
+ * separate files. No additional async chunk files are generated.
465
471
  * @default true
466
472
  * */
467
473
  asyncChunks?: AsyncChunks;
@@ -858,8 +864,6 @@ export type JavascriptParserOptions = {
858
864
  * Enable magic comments for CommonJS require() expressions.
859
865
  */
860
866
  commonjsMagicComments?: boolean;
861
- /** Inline const values in this module */
862
- inlineConst?: boolean;
863
867
  /** Whether to tolerant exportsPresence for type reexport */
864
868
  typeReexportsPresence?: "no-tolerant" | "tolerant" | "tolerant-no-check";
865
869
  /** Whether to enable JSX parsing */
@@ -1881,6 +1885,13 @@ export type Optimization = {
1881
1885
  * The value is `false` in development mode.
1882
1886
  */
1883
1887
  mangleExports?: "size" | "deterministic" | boolean;
1888
+ /**
1889
+ * Allows to inline exports when possible to reduce code size.
1890
+ *
1891
+ * The value is `true` in production mode.
1892
+ * The value is `false` in development mode.
1893
+ */
1894
+ inlineExports?: boolean;
1884
1895
  /**
1885
1896
  * Tells Rspack to set process.env.NODE_ENV to a given string value.
1886
1897
  * @default false
@@ -2092,6 +2103,7 @@ export type Experiments = {
2092
2103
  outputModule?: boolean;
2093
2104
  /**
2094
2105
  * Enable top-level await.
2106
+ * @deprecated This option is deprecated, top-level await is enabled by default.
2095
2107
  * @default true
2096
2108
  */
2097
2109
  topLevelAwait?: boolean;
@@ -2118,11 +2130,6 @@ export type Experiments = {
2118
2130
  * Enable incremental builds.
2119
2131
  */
2120
2132
  incremental?: IncrementalPresets | Incremental;
2121
- /**
2122
- * Enable multi-threaded code splitting algorithm.
2123
- * @deprecated This option is deprecated, it has a huge regression in some edge cases where the chunk graph has lots of cycles. We'll improve the performance of build_chunk_graph in the future instead
2124
- */
2125
- parallelCodeSplitting?: boolean;
2126
2133
  /**
2127
2134
  * Enable future default options.
2128
2135
  * @default false
@@ -2155,21 +2162,25 @@ export type Experiments = {
2155
2162
  /**
2156
2163
  * Enable inline const feature
2157
2164
  * @default false
2165
+ * @deprecated This option is deprecated, it's already stable and enabled by default, Rspack will remove this option in future version
2158
2166
  */
2159
2167
  inlineConst?: boolean;
2160
2168
  /**
2161
2169
  * Enable inline enum feature
2162
2170
  * @default false
2171
+ * @deprecated This option is deprecated, it's already stable. Rspack will remove this option in future version
2163
2172
  */
2164
2173
  inlineEnum?: boolean;
2165
2174
  /**
2166
2175
  * Enable type reexports presence feature
2167
2176
  * @default false
2177
+ * @deprecated This option is deprecated, it's already stable. Rspack will remove this option in future version
2168
2178
  */
2169
2179
  typeReexportsPresence?: boolean;
2170
2180
  /**
2171
2181
  * Enable lazy make side effects free barrel file
2172
2182
  * @default false
2183
+ * @deprecated This option is deprecated, it's already stable and enabled by default, Rspack will remove this option in future version
2173
2184
  */
2174
2185
  lazyBarrel?: boolean;
2175
2186
  /**
@@ -2333,7 +2344,18 @@ export type RspackOptions = {
2333
2344
  */
2334
2345
  loader?: Loader;
2335
2346
  /**
2336
- * Warnings to ignore during compilation.
2347
+ * Tells Rspack to suppress specific compilation warnings by matching their
2348
+ * message, module, or file, or by using a custom function.
2349
+ *
2350
+ * @example
2351
+ * ```js
2352
+ * export default {
2353
+ * ignoreWarnings: [
2354
+ * /warning from compiler/,
2355
+ * { file: /node_modules/ },
2356
+ * ],
2357
+ * };
2358
+ * ```
2337
2359
  */
2338
2360
  ignoreWarnings?: IgnoreWarnings;
2339
2361
  /**
package/dist/exports.d.ts CHANGED
@@ -56,6 +56,7 @@ export { LoaderOptionsPlugin } from "./lib/LoaderOptionsPlugin";
56
56
  export { LoaderTargetPlugin } from "./lib/LoaderTargetPlugin";
57
57
  export type { OutputFileSystem, WatchFileSystem } from "./util/fs";
58
58
  import { EsmLibraryPlugin, FetchCompileAsyncWasmPlugin, lazyCompilationMiddleware, SubresourceIntegrityPlugin } from "./builtin-plugin";
59
+ export { SubresourceIntegrityPlugin };
59
60
  interface Web {
60
61
  FetchCompileAsyncWasmPlugin: typeof FetchCompileAsyncWasmPlugin;
61
62
  }
@@ -68,6 +69,7 @@ interface Node {
68
69
  NodeTemplatePlugin: typeof NodeTemplatePlugin;
69
70
  NodeEnvironmentPlugin: typeof NodeEnvironmentPlugin;
70
71
  }
72
+ export { lazyCompilationMiddleware };
71
73
  export declare const node: Node;
72
74
  import { ElectronTargetPlugin } from "./builtin-plugin";
73
75
  interface Electron {
@@ -141,11 +143,17 @@ interface Experiments {
141
143
  cleanup: () => Promise<void>;
142
144
  };
143
145
  RemoveDuplicateModulesPlugin: typeof RemoveDuplicateModulesPlugin;
146
+ /**
147
+ * @deprecated Use `rspack.SubresourceIntegrityPlugin` instead
148
+ */
149
+ SubresourceIntegrityPlugin: typeof SubresourceIntegrityPlugin;
144
150
  EsmLibraryPlugin: typeof EsmLibraryPlugin;
145
151
  RsdoctorPlugin: typeof RsdoctorPlugin;
146
152
  RstestPlugin: typeof RstestPlugin;
147
153
  RslibPlugin: typeof RslibPlugin;
148
- SubresourceIntegrityPlugin: typeof SubresourceIntegrityPlugin;
154
+ /**
155
+ * @deprecated Use `rspack.lazyCompilationMiddleware` instead
156
+ */
149
157
  lazyCompilationMiddleware: typeof lazyCompilationMiddleware;
150
158
  swc: {
151
159
  transform: typeof transform;