@rspack/browser 2.0.0-beta.6 → 2.0.0-beta.7
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/builtin-loader/swc/types.d.ts +8 -0
- package/dist/builtin-plugin/RsdoctorPlugin.d.ts +2 -2
- package/dist/builtin-plugin/WorkerPlugin.d.ts +1 -0
- package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +25 -0
- package/dist/config/devServer.d.ts +15 -22
- package/dist/config/types.d.ts +1 -4
- package/dist/index.js +418 -537
- package/dist/napi-binding.d.ts +14 -1
- package/dist/rslib-runtime.js +5 -8
- package/dist/rspack.wasm32-wasi.wasm +0 -0
- package/dist/wasi-worker-browser.mjs +22 -23
- package/package.json +1 -1
|
@@ -15,11 +15,19 @@ export type SwcLoaderOptions = Config & {
|
|
|
15
15
|
* providing better TypeScript development experience and smaller output bundle size.
|
|
16
16
|
*/
|
|
17
17
|
collectTypeScriptInfo?: CollectTypeScriptInfoOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Ported from [babel-plugin-import](https://github.com/umijs/babel-plugin-import),
|
|
20
|
+
* used to transform imports for modular component libraries.
|
|
21
|
+
*/
|
|
22
|
+
transformImport?: PluginImportOptions;
|
|
18
23
|
/**
|
|
19
24
|
* Experimental features provided by Rspack.
|
|
20
25
|
* @experimental
|
|
21
26
|
*/
|
|
22
27
|
rspackExperiments?: {
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use top-level `transformImport` instead.
|
|
30
|
+
*/
|
|
23
31
|
import?: PluginImportOptions;
|
|
24
32
|
/**
|
|
25
33
|
* Enable React Server Components support.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type JsRsdoctorAsset, type JsRsdoctorAssetPatch, type JsRsdoctorChunk, type JsRsdoctorChunkAssets, type JsRsdoctorChunkGraph, type JsRsdoctorChunkModules, type JsRsdoctorDependency, type JsRsdoctorEntrypoint, type JsRsdoctorEntrypointAssets, type JsRsdoctorExportInfo, type JsRsdoctorModule, type JsRsdoctorModuleGraph, type JsRsdoctorModuleGraphModule, type JsRsdoctorModuleIdsPatch, type JsRsdoctorModuleOriginalSource, type JsRsdoctorModuleSourcesPatch, type JsRsdoctorSideEffect, type JsRsdoctorSourcePosition, type JsRsdoctorSourceRange, type JsRsdoctorStatement, type JsRsdoctorVariable } from '../binding';
|
|
1
|
+
import { type JsRsdoctorAsset, type JsRsdoctorAssetPatch, type JsRsdoctorChunk, type JsRsdoctorChunkAssets, type JsRsdoctorChunkGraph, type JsRsdoctorChunkModules, type JsRsdoctorConnectionsOnlyImport, type JsRsdoctorConnectionsOnlyImportConnection, type JsRsdoctorDependency, type JsRsdoctorEntrypoint, type JsRsdoctorEntrypointAssets, type JsRsdoctorExportInfo, type JsRsdoctorModule, type JsRsdoctorModuleGraph, type JsRsdoctorModuleGraphModule, type JsRsdoctorModuleIdsPatch, type JsRsdoctorModuleOriginalSource, type JsRsdoctorModuleSourcesPatch, type JsRsdoctorSideEffect, type JsRsdoctorSourcePosition, type JsRsdoctorSourceRange, type JsRsdoctorStatement, type JsRsdoctorVariable } from '../binding';
|
|
2
2
|
import * as liteTapable from '@rspack/lite-tapable';
|
|
3
3
|
import { type Compilation } from '../Compilation';
|
|
4
4
|
import type { Compiler } from '../Compiler';
|
|
5
5
|
import type { CreatePartialRegisters } from '../taps/types';
|
|
6
6
|
export declare namespace RsdoctorPluginData {
|
|
7
|
-
export type { JsRsdoctorAsset as RsdoctorAsset, JsRsdoctorChunkGraph as RsdoctorChunkGraph, JsRsdoctorModuleGraph as RsdoctorModuleGraph, JsRsdoctorChunk as RsdoctorChunk, JsRsdoctorModule as RsdoctorModule, JsRsdoctorSideEffect as RsdoctorSideEffect, JsRsdoctorExportInfo as RsdoctorExportInfo, JsRsdoctorVariable as RsdoctorVariable, JsRsdoctorDependency as RsdoctorDependency, JsRsdoctorEntrypoint as RsdoctorEntrypoint, JsRsdoctorStatement as RsdoctorStatement, JsRsdoctorSourceRange as RsdoctorSourceRange, JsRsdoctorSourcePosition as RsdoctorSourcePosition, JsRsdoctorModuleGraphModule as RsdoctorModuleGraphModule, JsRsdoctorModuleIdsPatch as RsdoctorModuleIdsPatch, JsRsdoctorModuleOriginalSource as RsdoctorModuleOriginalSource, JsRsdoctorAssetPatch as RsdoctorAssetPatch, JsRsdoctorChunkAssets as RsdoctorChunkAssets, JsRsdoctorEntrypointAssets as RsdoctorEntrypointAssets, JsRsdoctorChunkModules as RsdoctorChunkModules, JsRsdoctorModuleSourcesPatch as RsdoctorModuleSourcesPatch, };
|
|
7
|
+
export type { JsRsdoctorAsset as RsdoctorAsset, JsRsdoctorChunkGraph as RsdoctorChunkGraph, JsRsdoctorModuleGraph as RsdoctorModuleGraph, JsRsdoctorChunk as RsdoctorChunk, JsRsdoctorModule as RsdoctorModule, JsRsdoctorSideEffect as RsdoctorSideEffect, JsRsdoctorExportInfo as RsdoctorExportInfo, JsRsdoctorVariable as RsdoctorVariable, JsRsdoctorConnectionsOnlyImport as RsdoctorConnectionsOnlyImport, JsRsdoctorConnectionsOnlyImportConnection as RsdoctorConnectionsOnlyImportConnection, JsRsdoctorDependency as RsdoctorDependency, JsRsdoctorEntrypoint as RsdoctorEntrypoint, JsRsdoctorStatement as RsdoctorStatement, JsRsdoctorSourceRange as RsdoctorSourceRange, JsRsdoctorSourcePosition as RsdoctorSourcePosition, JsRsdoctorModuleGraphModule as RsdoctorModuleGraphModule, JsRsdoctorModuleIdsPatch as RsdoctorModuleIdsPatch, JsRsdoctorModuleOriginalSource as RsdoctorModuleOriginalSource, JsRsdoctorAssetPatch as RsdoctorAssetPatch, JsRsdoctorChunkAssets as RsdoctorChunkAssets, JsRsdoctorEntrypointAssets as RsdoctorEntrypointAssets, JsRsdoctorChunkModules as RsdoctorChunkModules, JsRsdoctorModuleSourcesPatch as RsdoctorModuleSourcesPatch, };
|
|
8
8
|
}
|
|
9
9
|
export type RsdoctorPluginOptions = {
|
|
10
10
|
moduleGraphFeatures?: boolean | ('graph' | 'ids' | 'sources')[];
|
|
@@ -8,6 +8,7 @@ export declare class WorkerPlugin extends RspackBuiltinPlugin {
|
|
|
8
8
|
private module;
|
|
9
9
|
private workerPublicPath;
|
|
10
10
|
name: BuiltinPluginName;
|
|
11
|
+
affectedHooks: "compilation";
|
|
11
12
|
constructor(chunkLoading: ChunkLoading, wasmLoading: WasmLoading, module: OutputModule, workerPublicPath: WorkerPublicPath);
|
|
12
13
|
raw(compiler: Compiler): BuiltinPlugin;
|
|
13
14
|
}
|
|
@@ -2,9 +2,34 @@ import type binding from '../../binding';
|
|
|
2
2
|
import type { Compiler } from '../..';
|
|
3
3
|
import { RspackBuiltinPlugin } from '../base';
|
|
4
4
|
import { type Coordinator } from './Coordinator';
|
|
5
|
+
/** Manifest export entry (server/client actions, module refs). */
|
|
6
|
+
export interface RscManifestExport {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
chunks: string[];
|
|
10
|
+
async?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Map of export name to manifest export. */
|
|
13
|
+
export type RscManifestNode = Record<string, RscManifestExport>;
|
|
14
|
+
/** Module loading config (prefix, crossOrigin). */
|
|
15
|
+
export interface RscModuleLoading {
|
|
16
|
+
prefix: string;
|
|
17
|
+
crossOrigin?: 'use-credentials' | '';
|
|
18
|
+
}
|
|
19
|
+
export interface RscManifestPerEntry {
|
|
20
|
+
serverManifest: Record<string, RscManifestExport>;
|
|
21
|
+
clientManifest: Record<string, RscManifestExport>;
|
|
22
|
+
serverConsumerModuleMap: Record<string, RscManifestNode>;
|
|
23
|
+
moduleLoading: RscModuleLoading;
|
|
24
|
+
entryCssFiles: Record<string, string[]>;
|
|
25
|
+
entryJsFiles: string[];
|
|
26
|
+
}
|
|
27
|
+
/** Full RSC manifest (all entries) passed to onManifest. Map from entry name to per-entry manifest. */
|
|
28
|
+
export type RscManifest = Record<string, RscManifestPerEntry>;
|
|
5
29
|
export type RscServerPluginOptions = {
|
|
6
30
|
coordinator: Coordinator;
|
|
7
31
|
onServerComponentChanges?: () => Promise<void>;
|
|
32
|
+
onManifest?: (manifest: RscManifest) => void | Promise<void>;
|
|
8
33
|
};
|
|
9
34
|
export declare class RscServerPlugin extends RspackBuiltinPlugin {
|
|
10
35
|
#private;
|
|
@@ -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 } from 'connect-next';
|
|
13
|
+
import type { Server as ConnectApplication, 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 '..';
|
|
@@ -18,12 +18,14 @@ type Logger = ReturnType<Compiler['getInfrastructureLogger']>;
|
|
|
18
18
|
type MultiWatching = MultiCompiler['watch'];
|
|
19
19
|
export type DevServerHost = LiteralUnion<'local-ip' | 'local-ipv4' | 'local-ipv6', string>;
|
|
20
20
|
type BasicServer = import('node:net').Server | import('node:tls').Server;
|
|
21
|
-
export type DevServerOpenOptions = OpenOptions
|
|
21
|
+
export type DevServerOpenOptions = OpenOptions & {
|
|
22
|
+
target?: string | string[];
|
|
23
|
+
};
|
|
22
24
|
type ResponseData = {
|
|
23
25
|
data: Buffer | ReadStream;
|
|
24
26
|
byteLength: number;
|
|
25
27
|
};
|
|
26
|
-
type ModifyResponseData<
|
|
28
|
+
type ModifyResponseData<Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse> = (req: Req, res: Res, data: Buffer | ReadStream, byteLength: number) => ResponseData;
|
|
27
29
|
export type DevServerHeaders = {
|
|
28
30
|
key: string;
|
|
29
31
|
value: string;
|
|
@@ -51,7 +53,7 @@ type HistoryApiFallbackOptions = {
|
|
|
51
53
|
readonly rewrites?: readonly Rewrite[];
|
|
52
54
|
readonly verbose?: boolean;
|
|
53
55
|
};
|
|
54
|
-
type DevMiddlewareOptions<
|
|
56
|
+
type DevMiddlewareOptions<Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse> = {
|
|
55
57
|
mimeTypes?: {
|
|
56
58
|
[key: string]: string;
|
|
57
59
|
};
|
|
@@ -64,7 +66,7 @@ type DevMiddlewareOptions<RequestInternal extends IncomingMessage = IncomingMess
|
|
|
64
66
|
serverSideRender?: boolean;
|
|
65
67
|
outputFileSystem?: OutputFileSystem;
|
|
66
68
|
index?: string | boolean;
|
|
67
|
-
modifyResponseData?: ModifyResponseData<
|
|
69
|
+
modifyResponseData?: ModifyResponseData<Req, Res>;
|
|
68
70
|
etag?: 'strong' | 'weak';
|
|
69
71
|
lastModified?: boolean;
|
|
70
72
|
cacheControl?: string | number | boolean | {
|
|
@@ -77,9 +79,6 @@ type BasicApplication = any;
|
|
|
77
79
|
type ChokidarWatchOptions = {
|
|
78
80
|
[key: string]: any;
|
|
79
81
|
};
|
|
80
|
-
type ServeIndexOptions = {
|
|
81
|
-
[key: string]: any;
|
|
82
|
-
};
|
|
83
82
|
type ServeStaticOptions = {
|
|
84
83
|
[key: string]: any;
|
|
85
84
|
};
|
|
@@ -87,20 +86,14 @@ type WatchFiles = {
|
|
|
87
86
|
paths: string | string[];
|
|
88
87
|
options?: ChokidarWatchOptions & {
|
|
89
88
|
aggregateTimeout?: number;
|
|
90
|
-
ignored?: ChokidarWatchOptions['ignored'];
|
|
91
89
|
poll?: number | boolean;
|
|
92
90
|
};
|
|
93
91
|
};
|
|
94
92
|
export type DevServerStaticItem = {
|
|
95
93
|
directory?: string;
|
|
96
94
|
publicPath?: string | string[];
|
|
97
|
-
serveIndex?: boolean | ServeIndexOptions;
|
|
98
95
|
staticOptions?: ServeStaticOptions;
|
|
99
|
-
watch?: boolean |
|
|
100
|
-
aggregateTimeout?: number;
|
|
101
|
-
ignored?: ChokidarWatchOptions['ignored'];
|
|
102
|
-
poll?: number | boolean;
|
|
103
|
-
});
|
|
96
|
+
watch?: boolean | NonNullable<WatchFiles['options']>;
|
|
104
97
|
};
|
|
105
98
|
export type DevServerStatic = string | boolean | DevServerStaticItem | (string | DevServerStaticItem)[];
|
|
106
99
|
type ServerType<A extends BasicApplication, S extends BasicServer> = LiteralUnion<'http' | 'https' | 'http2', string> | ((arg0: ServerOptions, arg1: A) => S);
|
|
@@ -112,7 +105,6 @@ type WebSocketServerConfiguration = {
|
|
|
112
105
|
type?: string | Function;
|
|
113
106
|
options?: Record<string, any>;
|
|
114
107
|
};
|
|
115
|
-
type NextFunction = (err?: any) => void;
|
|
116
108
|
export type DevServerProxyConfigArrayItem = {
|
|
117
109
|
/**
|
|
118
110
|
* Alias for `pathFilter` in `http-proxy-middleware` options.
|
|
@@ -122,7 +114,7 @@ export type DevServerProxyConfigArrayItem = {
|
|
|
122
114
|
} & ProxyOptions;
|
|
123
115
|
export type DevServerProxyConfigArray = (DevServerProxyConfigArrayItem | ((req?: IncomingMessage, res?: ServerResponse, next?: NextFunction) => DevServerProxyConfigArrayItem))[];
|
|
124
116
|
type Callback = (stats?: Stats | MultiStats) => any;
|
|
125
|
-
type DevMiddlewareContext
|
|
117
|
+
type DevMiddlewareContext = {
|
|
126
118
|
state: boolean;
|
|
127
119
|
stats: Stats | MultiStats | undefined;
|
|
128
120
|
callbacks: Callback[];
|
|
@@ -132,13 +124,14 @@ type DevMiddlewareContext<_RequestInternal extends IncomingMessage = IncomingMes
|
|
|
132
124
|
logger: Logger;
|
|
133
125
|
outputFileSystem: OutputFileSystem;
|
|
134
126
|
};
|
|
135
|
-
export type DevServerMiddlewareHandler<
|
|
136
|
-
type
|
|
127
|
+
export type DevServerMiddlewareHandler<Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse> = (req: Req, res: Res, next: NextFunction) => void | Promise<void>;
|
|
128
|
+
export type DevServerMiddlewareErrorHandler<Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse> = (error: any, req: Req, res: Res, next: NextFunction) => void | Promise<void>;
|
|
129
|
+
export type DevServerMiddlewareObject<Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse> = {
|
|
137
130
|
name?: string;
|
|
138
131
|
path?: string;
|
|
139
|
-
middleware: DevServerMiddlewareHandler<
|
|
132
|
+
middleware: DevServerMiddlewareHandler<Req, Res> | DevServerMiddlewareErrorHandler<Req, Res>;
|
|
140
133
|
};
|
|
141
|
-
export type DevServerMiddleware = DevServerMiddlewareObject | DevServerMiddlewareHandler;
|
|
134
|
+
export type DevServerMiddleware = DevServerMiddlewareObject | DevServerMiddlewareHandler | DevServerMiddlewareErrorHandler;
|
|
142
135
|
type OverlayMessageOptions = boolean | ((error: Error) => void);
|
|
143
136
|
export type DevServerWebSocketURL = {
|
|
144
137
|
hostname?: string;
|
|
@@ -176,7 +169,7 @@ export type DevServerOptions<A extends BasicApplication = ConnectApplication, S
|
|
|
176
169
|
app?: () => Promise<A>;
|
|
177
170
|
webSocketServer?: boolean | LiteralUnion<'ws', string> | WebSocketServerConfiguration;
|
|
178
171
|
proxy?: DevServerProxyConfigArray;
|
|
179
|
-
open?: string | boolean |
|
|
172
|
+
open?: string | boolean | DevServerOpenOptions | (string | DevServerOpenOptions)[];
|
|
180
173
|
setupExitSignals?: boolean;
|
|
181
174
|
client?: boolean | DevServerClient;
|
|
182
175
|
headers?: DevServerHeaders | ((req: IncomingMessage, res: ServerResponse, context: DevMiddlewareContext | undefined) => DevServerHeaders);
|
package/dist/config/types.d.ts
CHANGED
|
@@ -592,7 +592,6 @@ export type ResolveOptions = {
|
|
|
592
592
|
restrictions?: string[];
|
|
593
593
|
/**
|
|
594
594
|
* A list of directories where server-relative URLs (beginning with '/') are resolved.
|
|
595
|
-
* It defaults to the context configuration option.
|
|
596
595
|
* On systems other than Windows, these requests are initially resolved as an absolute path.
|
|
597
596
|
* @default []
|
|
598
597
|
*/
|
|
@@ -1934,8 +1933,6 @@ export type Optimization = {
|
|
|
1934
1933
|
* @default false
|
|
1935
1934
|
*/
|
|
1936
1935
|
runtimeChunk?: OptimizationRuntimeChunk;
|
|
1937
|
-
/** Detect and remove modules from chunks these modules are already included in all parents. */
|
|
1938
|
-
removeAvailableModules?: boolean;
|
|
1939
1936
|
/**
|
|
1940
1937
|
* Remove empty chunks generated in the compilation.
|
|
1941
1938
|
* @default true
|
|
@@ -2232,7 +2229,7 @@ export type WatchOptions = {
|
|
|
2232
2229
|
* Options for dev server
|
|
2233
2230
|
* */
|
|
2234
2231
|
export type DevServer = DevServerOptions;
|
|
2235
|
-
export type { DevServerClient, DevServerHeaders, DevServerHost, DevServerMiddleware, DevServerMiddlewareHandler, DevServerOpenOptions, DevServerProxyConfigArray, DevServerProxyConfigArrayItem, DevServerStatic, DevServerStaticItem, DevServerWebSocketURL, } from './devServer';
|
|
2232
|
+
export type { DevServerClient, DevServerHeaders, DevServerHost, DevServerMiddleware, DevServerMiddlewareHandler, DevServerMiddlewareObject, DevServerOpenOptions, DevServerProxyConfigArray, DevServerProxyConfigArrayItem, DevServerStatic, DevServerStaticItem, DevServerWebSocketURL, } from './devServer';
|
|
2236
2233
|
/**
|
|
2237
2234
|
* Ignore specific warnings.
|
|
2238
2235
|
*/
|