@rspack/core 2.0.0-beta.5 → 2.0.0-beta.6
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/README.md +1 -1
- package/compiled/connect-next/index.d.ts +56 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +544 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/open/index.d.ts +161 -0
- package/compiled/open/package.json +1 -0
- package/dist/builtin-loader/swc/types.d.ts +9 -1
- package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +2 -2
- package/dist/checkNodeVersion.d.ts +1 -0
- package/dist/config/devServer.d.ts +96 -224
- package/dist/config/types.d.ts +2 -2
- package/dist/container/ContainerPlugin.d.ts +3 -2
- package/dist/container/ContainerReferencePlugin.d.ts +4 -3
- package/dist/container/ModuleFederationPlugin.d.ts +2 -1
- package/dist/container/ModuleFederationPluginV1.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +66 -37
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +2 -2
- package/dist/sharing/ConsumeSharedPlugin.d.ts +5 -5
- package/dist/sharing/ProvideSharedPlugin.d.ts +6 -5
- package/dist/sharing/SharePlugin.d.ts +9 -7
- package/hot/dev-server.js +1 -1
- package/hot/emitter.js +0 -2
- package/hot/log.js +0 -2
- package/hot/only-dev-server.js +1 -1
- package/package.json +11 -10
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { ChildProcess } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
type Options = {
|
|
4
|
+
/**
|
|
5
|
+
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
|
|
6
|
+
|
|
7
|
+
Note that it waits for the app to exit, not just for the window to close.
|
|
8
|
+
|
|
9
|
+
On Windows, you have to explicitly specify an app for it to be able to wait.
|
|
10
|
+
|
|
11
|
+
**Warning:** When opening URLs in browsers while the browser is already running, the `wait` option will not work as expected. Browsers use a single-instance architecture where new URLs are passed to the existing process, causing the command to exit immediately. Use the `newInstance` option on macOS to force a new browser instance, or avoid using `wait` with browsers.
|
|
12
|
+
|
|
13
|
+
@default false
|
|
14
|
+
*/
|
|
15
|
+
readonly wait?: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
__macOS only__
|
|
19
|
+
|
|
20
|
+
Do not bring the app to the foreground.
|
|
21
|
+
|
|
22
|
+
@default false
|
|
23
|
+
*/
|
|
24
|
+
readonly background?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
__macOS only__
|
|
28
|
+
|
|
29
|
+
Open a new instance of the app even it's already running.
|
|
30
|
+
|
|
31
|
+
A new instance is always opened on other platforms.
|
|
32
|
+
|
|
33
|
+
@default false
|
|
34
|
+
*/
|
|
35
|
+
readonly newInstance?: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
Specify the `name` of the app to open the `target` with, and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
|
|
39
|
+
|
|
40
|
+
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use `apps` which auto-detects the correct binary to use.
|
|
41
|
+
|
|
42
|
+
You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
|
|
43
|
+
|
|
44
|
+
The app `arguments` are app dependent. Check the app's documentation for what arguments it accepts.
|
|
45
|
+
*/
|
|
46
|
+
readonly app?: App | readonly App[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
|
|
50
|
+
|
|
51
|
+
We do not recommend setting this option. The convention for success is exit code zero.
|
|
52
|
+
|
|
53
|
+
@default false
|
|
54
|
+
*/
|
|
55
|
+
readonly allowNonzeroExitCode?: boolean;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type OpenAppOptions = {
|
|
59
|
+
/**
|
|
60
|
+
Arguments passed to the app.
|
|
61
|
+
|
|
62
|
+
These arguments are app dependent. Check the app's documentation for what arguments it accepts.
|
|
63
|
+
*/
|
|
64
|
+
readonly arguments?: readonly string[];
|
|
65
|
+
} & Omit<Options, 'app'>;
|
|
66
|
+
|
|
67
|
+
type AppName =
|
|
68
|
+
| 'chrome'
|
|
69
|
+
| 'brave'
|
|
70
|
+
| 'firefox'
|
|
71
|
+
| 'edge'
|
|
72
|
+
| 'browser'
|
|
73
|
+
| 'browserPrivate';
|
|
74
|
+
|
|
75
|
+
type App = {
|
|
76
|
+
name: string | readonly string[];
|
|
77
|
+
arguments?: readonly string[];
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
An object containing auto-detected binary names for common apps. Useful to work around cross-platform differences.
|
|
82
|
+
|
|
83
|
+
@example
|
|
84
|
+
```
|
|
85
|
+
import open, {apps} from 'open';
|
|
86
|
+
|
|
87
|
+
await open('https://google.com', {
|
|
88
|
+
app: {
|
|
89
|
+
name: apps.chrome
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
*/
|
|
94
|
+
declare const apps: Record<AppName, string | readonly string[]>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
Open stuff like URLs, files, executables. Cross-platform.
|
|
98
|
+
|
|
99
|
+
Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
|
100
|
+
|
|
101
|
+
@param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
|
|
102
|
+
@returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
|
103
|
+
|
|
104
|
+
@example
|
|
105
|
+
```
|
|
106
|
+
import open, {apps} from 'open';
|
|
107
|
+
|
|
108
|
+
// Opens the image in the default image viewer.
|
|
109
|
+
await open('unicorn.png', {wait: true});
|
|
110
|
+
console.log('The image viewer app quit');
|
|
111
|
+
|
|
112
|
+
// Opens the URL in the default browser.
|
|
113
|
+
await open('https://sindresorhus.com');
|
|
114
|
+
|
|
115
|
+
// Opens the URL in a specified browser.
|
|
116
|
+
await open('https://sindresorhus.com', {app: {name: 'firefox'}});
|
|
117
|
+
|
|
118
|
+
// Specify app arguments.
|
|
119
|
+
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
|
|
120
|
+
|
|
121
|
+
// Opens the URL in the default browser in incognito mode.
|
|
122
|
+
await open('https://sindresorhus.com', {app: {name: apps.browserPrivate}});
|
|
123
|
+
```
|
|
124
|
+
*/
|
|
125
|
+
declare function open(
|
|
126
|
+
target: string,
|
|
127
|
+
options?: Options
|
|
128
|
+
): Promise<ChildProcess>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
Open an app. Cross-platform.
|
|
132
|
+
|
|
133
|
+
Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
|
134
|
+
|
|
135
|
+
@param name - The app you want to open. Can be either builtin supported `apps` names or other name supported in platform.
|
|
136
|
+
@returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
|
137
|
+
|
|
138
|
+
@example
|
|
139
|
+
```
|
|
140
|
+
import open, {openApp, apps} from 'open';
|
|
141
|
+
|
|
142
|
+
// Open Firefox.
|
|
143
|
+
await openApp(apps.firefox);
|
|
144
|
+
|
|
145
|
+
// Open Chrome in incognito mode.
|
|
146
|
+
await openApp(apps.chrome, {arguments: ['--incognito']});
|
|
147
|
+
|
|
148
|
+
// Open default browser.
|
|
149
|
+
await openApp(apps.browser);
|
|
150
|
+
|
|
151
|
+
// Open default browser in incognito mode.
|
|
152
|
+
await openApp(apps.browserPrivate);
|
|
153
|
+
|
|
154
|
+
// Open Xcode.
|
|
155
|
+
await openApp('xcode');
|
|
156
|
+
```
|
|
157
|
+
*/
|
|
158
|
+
declare function openApp(name: App['name'], options?: OpenAppOptions): Promise<ChildProcess>;
|
|
159
|
+
|
|
160
|
+
export { apps, open as default, openApp };
|
|
161
|
+
export type { App, AppName, OpenAppOptions, Options };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"open","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"version":"11.0.0","funding":"https://github.com/sponsors/sindresorhus","license":"MIT","types":"index.d.ts","type":"module"}
|
|
@@ -24,9 +24,17 @@ export type SwcLoaderOptions = Config & {
|
|
|
24
24
|
/**
|
|
25
25
|
* Enable React Server Components support.
|
|
26
26
|
*/
|
|
27
|
-
reactServerComponents?: boolean;
|
|
27
|
+
reactServerComponents?: boolean | ReactServerComponentsOptions;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
+
export interface ReactServerComponentsOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Whether to disable the compile-time check that reports errors when React
|
|
33
|
+
* client-only APIs (e.g. `useState`, `useEffect`) are imported in server
|
|
34
|
+
* components. Defaults to `false`.
|
|
35
|
+
*/
|
|
36
|
+
disableClientApiChecks?: boolean;
|
|
37
|
+
}
|
|
30
38
|
export interface TerserCompressOptions {
|
|
31
39
|
arguments?: boolean;
|
|
32
40
|
arrows?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Compiler, MultiCompiler } from '../../index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DevServerMiddlewareHandler } from '../../config/devServer.js';
|
|
3
3
|
export declare const LAZY_COMPILATION_PREFIX = "/_rspack/lazy/trigger";
|
|
4
4
|
/**
|
|
5
5
|
* Create a middleware that handles lazy compilation requests from the client.
|
|
@@ -9,4 +9,4 @@ export declare const LAZY_COMPILATION_PREFIX = "/_rspack/lazy/trigger";
|
|
|
9
9
|
* Use this middleware when integrating lazy compilation into a
|
|
10
10
|
* custom development server instead of relying on the built-in server.
|
|
11
11
|
*/
|
|
12
|
-
export declare const lazyCompilationMiddleware: (compiler: Compiler | MultiCompiler) =>
|
|
12
|
+
export declare const lazyCompilationMiddleware: (compiler: Compiler | MultiCompiler) => DevServerMiddlewareHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function checkNodeVersion(): void;
|
|
@@ -7,32 +7,24 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
import type
|
|
11
|
-
import type
|
|
12
|
-
import type
|
|
13
|
-
import type
|
|
14
|
-
import type {
|
|
10
|
+
import type { ReadStream } from 'node:fs';
|
|
11
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
12
|
+
import type { ServerOptions } from 'node:https';
|
|
13
|
+
import type { Server as ConnectApplication } from '../../compiled/connect-next';
|
|
14
|
+
import type { Filter as ProxyFilter, Options as ProxyOptions } from '../../compiled/http-proxy-middleware';
|
|
15
|
+
import type { Options as OpenOptions } from '../../compiled/open';
|
|
16
|
+
import type { Compiler, Configuration, LiteralUnion, MultiCompiler, MultiStats, Stats, Watching } from '../index.js';
|
|
15
17
|
type Logger = ReturnType<Compiler['getInfrastructureLogger']>;
|
|
16
18
|
type MultiWatching = MultiCompiler['watch'];
|
|
17
|
-
type
|
|
18
|
-
type
|
|
19
|
-
type
|
|
20
|
-
type ServerResponse = import('http').ServerResponse;
|
|
21
|
-
type ServerOptions = import('https').ServerOptions & {
|
|
22
|
-
spdy?: {
|
|
23
|
-
plain?: boolean | undefined;
|
|
24
|
-
ssl?: boolean | undefined;
|
|
25
|
-
'x-forwarded-for'?: string | undefined;
|
|
26
|
-
protocol?: string | undefined;
|
|
27
|
-
protocols?: string[] | undefined;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
19
|
+
export type DevServerHost = LiteralUnion<'local-ip' | 'local-ipv4' | 'local-ipv6', string>;
|
|
20
|
+
type BasicServer = import('node:net').Server | import('node:tls').Server;
|
|
21
|
+
export type DevServerOpenOptions = OpenOptions;
|
|
30
22
|
type ResponseData = {
|
|
31
23
|
data: Buffer | ReadStream;
|
|
32
24
|
byteLength: number;
|
|
33
25
|
};
|
|
34
26
|
type ModifyResponseData<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = (req: RequestInternal, res: ResponseInternal, data: Buffer | ReadStream, byteLength: number) => ResponseData;
|
|
35
|
-
type
|
|
27
|
+
export type DevServerHeaders = {
|
|
36
28
|
key: string;
|
|
37
29
|
value: string;
|
|
38
30
|
}[] | Record<string, string | string[]>;
|
|
@@ -40,7 +32,6 @@ type OutputFileSystem = import('../index.js').OutputFileSystem & {
|
|
|
40
32
|
statSync: import('fs').StatSyncFn;
|
|
41
33
|
readFileSync: typeof import('fs').readFileSync;
|
|
42
34
|
};
|
|
43
|
-
type RspackConfiguration = import('../index.js').Configuration;
|
|
44
35
|
type Port = number | LiteralUnion<'auto', string>;
|
|
45
36
|
type HistoryContext = {
|
|
46
37
|
readonly match: RegExpMatchArray;
|
|
@@ -53,37 +44,36 @@ type Rewrite = {
|
|
|
53
44
|
readonly to: string | RegExp | RewriteTo;
|
|
54
45
|
};
|
|
55
46
|
type HistoryApiFallbackOptions = {
|
|
56
|
-
readonly disableDotRule?: true
|
|
57
|
-
readonly htmlAcceptHeaders?: readonly string[]
|
|
58
|
-
readonly index?: string
|
|
59
|
-
readonly logger?: typeof console.log
|
|
60
|
-
readonly rewrites?: readonly Rewrite[]
|
|
61
|
-
readonly verbose?: boolean
|
|
47
|
+
readonly disableDotRule?: true;
|
|
48
|
+
readonly htmlAcceptHeaders?: readonly string[];
|
|
49
|
+
readonly index?: string;
|
|
50
|
+
readonly logger?: typeof console.log;
|
|
51
|
+
readonly rewrites?: readonly Rewrite[];
|
|
52
|
+
readonly verbose?: boolean;
|
|
62
53
|
};
|
|
63
54
|
type DevMiddlewareOptions<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = {
|
|
64
55
|
mimeTypes?: {
|
|
65
56
|
[key: string]: string;
|
|
66
|
-
}
|
|
67
|
-
mimeTypeDefault?: string
|
|
68
|
-
writeToDisk?: boolean | ((targetPath: string) => boolean)
|
|
69
|
-
methods?: string[]
|
|
57
|
+
};
|
|
58
|
+
mimeTypeDefault?: string;
|
|
59
|
+
writeToDisk?: boolean | ((targetPath: string) => boolean);
|
|
60
|
+
methods?: string[];
|
|
70
61
|
headers?: any;
|
|
71
|
-
publicPath?: NonNullable<
|
|
72
|
-
stats?:
|
|
73
|
-
serverSideRender?: boolean
|
|
74
|
-
outputFileSystem?: OutputFileSystem
|
|
75
|
-
index?: string | boolean
|
|
76
|
-
modifyResponseData?: ModifyResponseData<RequestInternal, ResponseInternal
|
|
77
|
-
etag?: 'strong' | 'weak'
|
|
78
|
-
lastModified?: boolean
|
|
62
|
+
publicPath?: NonNullable<Configuration['output']>['publicPath'];
|
|
63
|
+
stats?: Configuration['stats'];
|
|
64
|
+
serverSideRender?: boolean;
|
|
65
|
+
outputFileSystem?: OutputFileSystem;
|
|
66
|
+
index?: string | boolean;
|
|
67
|
+
modifyResponseData?: ModifyResponseData<RequestInternal, ResponseInternal>;
|
|
68
|
+
etag?: 'strong' | 'weak';
|
|
69
|
+
lastModified?: boolean;
|
|
79
70
|
cacheControl?: string | number | boolean | {
|
|
80
71
|
maxAge?: number;
|
|
81
72
|
immutable?: boolean;
|
|
82
|
-
}
|
|
83
|
-
cacheImmutable?: boolean
|
|
73
|
+
};
|
|
74
|
+
cacheImmutable?: boolean;
|
|
84
75
|
};
|
|
85
76
|
type BasicApplication = any;
|
|
86
|
-
type BonjourServer = Record<string, any>;
|
|
87
77
|
type ChokidarWatchOptions = {
|
|
88
78
|
[key: string]: any;
|
|
89
79
|
};
|
|
@@ -93,46 +83,44 @@ type ServeIndexOptions = {
|
|
|
93
83
|
type ServeStaticOptions = {
|
|
94
84
|
[key: string]: any;
|
|
95
85
|
};
|
|
96
|
-
type HttpProxyMiddlewareOptionsFilter = any;
|
|
97
|
-
type Request = IncomingMessage;
|
|
98
|
-
type Response = ServerResponse;
|
|
99
86
|
type WatchFiles = {
|
|
100
87
|
paths: string | string[];
|
|
101
|
-
options?:
|
|
88
|
+
options?: ChokidarWatchOptions & {
|
|
102
89
|
aggregateTimeout?: number;
|
|
103
90
|
ignored?: ChokidarWatchOptions['ignored'];
|
|
104
91
|
poll?: number | boolean;
|
|
105
|
-
}
|
|
92
|
+
};
|
|
106
93
|
};
|
|
107
|
-
type
|
|
108
|
-
directory?: string
|
|
109
|
-
publicPath?: string | string[]
|
|
110
|
-
serveIndex?: boolean | ServeIndexOptions
|
|
111
|
-
staticOptions?: ServeStaticOptions
|
|
94
|
+
export type DevServerStaticItem = {
|
|
95
|
+
directory?: string;
|
|
96
|
+
publicPath?: string | string[];
|
|
97
|
+
serveIndex?: boolean | ServeIndexOptions;
|
|
98
|
+
staticOptions?: ServeStaticOptions;
|
|
112
99
|
watch?: boolean | (ChokidarWatchOptions & {
|
|
113
100
|
aggregateTimeout?: number;
|
|
114
101
|
ignored?: ChokidarWatchOptions['ignored'];
|
|
115
102
|
poll?: number | boolean;
|
|
116
|
-
})
|
|
103
|
+
});
|
|
117
104
|
};
|
|
118
|
-
type
|
|
119
|
-
type
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
export type DevServerStatic = string | boolean | DevServerStaticItem | (string | DevServerStaticItem)[];
|
|
106
|
+
type ServerType<A extends BasicApplication, S extends BasicServer> = LiteralUnion<'http' | 'https' | 'http2', string> | ((arg0: ServerOptions, arg1: A) => S);
|
|
107
|
+
type ServerConfiguration<A extends BasicApplication, S extends BasicServer> = {
|
|
108
|
+
type?: ServerType<A, S>;
|
|
109
|
+
options?: ServerOptions;
|
|
122
110
|
};
|
|
123
111
|
type WebSocketServerConfiguration = {
|
|
124
|
-
type?: string | Function
|
|
125
|
-
options?: Record<string, any
|
|
112
|
+
type?: string | Function;
|
|
113
|
+
options?: Record<string, any>;
|
|
126
114
|
};
|
|
127
115
|
type NextFunction = (err?: any) => void;
|
|
128
|
-
type
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
type
|
|
116
|
+
export type DevServerProxyConfigArrayItem = {
|
|
117
|
+
/**
|
|
118
|
+
* Alias for `pathFilter` in `http-proxy-middleware` options.
|
|
119
|
+
* When both `context` and `pathFilter` are provided, `pathFilter` takes precedence.
|
|
120
|
+
*/
|
|
121
|
+
context?: ProxyFilter;
|
|
122
|
+
} & ProxyOptions;
|
|
123
|
+
export type DevServerProxyConfigArray = (DevServerProxyConfigArrayItem | ((req?: IncomingMessage, res?: ServerResponse, next?: NextFunction) => DevServerProxyConfigArrayItem))[];
|
|
136
124
|
type Callback = (stats?: Stats | MultiStats) => any;
|
|
137
125
|
type DevMiddlewareContext<_RequestInternal extends IncomingMessage = IncomingMessage, _ResponseInternal extends ServerResponse = ServerResponse> = {
|
|
138
126
|
state: boolean;
|
|
@@ -144,171 +132,55 @@ type DevMiddlewareContext<_RequestInternal extends IncomingMessage = IncomingMes
|
|
|
144
132
|
logger: Logger;
|
|
145
133
|
outputFileSystem: OutputFileSystem;
|
|
146
134
|
};
|
|
147
|
-
type
|
|
148
|
-
|
|
149
|
-
type MiddlewareObject<RequestInternal extends Request = Request, ResponseInternal extends Response = Response> = {
|
|
135
|
+
export type DevServerMiddlewareHandler<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = (req: RequestInternal, res: ResponseInternal, next: NextFunction) => void | Promise<void>;
|
|
136
|
+
type DevServerMiddlewareObject<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = {
|
|
150
137
|
name?: string;
|
|
151
138
|
path?: string;
|
|
152
|
-
middleware:
|
|
153
|
-
};
|
|
154
|
-
export type Middleware<RequestInternal extends Request = Request, ResponseInternal extends Response = Response> = MiddlewareObject<RequestInternal, ResponseInternal> | MiddlewareHandler<RequestInternal, ResponseInternal>;
|
|
155
|
-
type OpenApp = {
|
|
156
|
-
name?: string | undefined;
|
|
157
|
-
arguments?: string[] | undefined;
|
|
158
|
-
};
|
|
159
|
-
type Open = {
|
|
160
|
-
app?: string | string[] | OpenApp | undefined;
|
|
161
|
-
target?: string | string[] | undefined;
|
|
139
|
+
middleware: DevServerMiddlewareHandler<RequestInternal, ResponseInternal>;
|
|
162
140
|
};
|
|
141
|
+
export type DevServerMiddleware = DevServerMiddlewareObject | DevServerMiddlewareHandler;
|
|
163
142
|
type OverlayMessageOptions = boolean | ((error: Error) => void);
|
|
164
|
-
type
|
|
165
|
-
hostname?: string
|
|
166
|
-
password?: string
|
|
167
|
-
pathname?: string
|
|
168
|
-
port?: string | number
|
|
169
|
-
protocol?: string
|
|
170
|
-
username?: string
|
|
171
|
-
};
|
|
172
|
-
type
|
|
173
|
-
logging?: 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'
|
|
143
|
+
export type DevServerWebSocketURL = {
|
|
144
|
+
hostname?: string;
|
|
145
|
+
password?: string;
|
|
146
|
+
pathname?: string;
|
|
147
|
+
port?: string | number;
|
|
148
|
+
protocol?: string;
|
|
149
|
+
username?: string;
|
|
150
|
+
};
|
|
151
|
+
export type DevServerClient = {
|
|
152
|
+
logging?: 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose';
|
|
174
153
|
overlay?: boolean | {
|
|
175
154
|
warnings?: OverlayMessageOptions;
|
|
176
155
|
errors?: OverlayMessageOptions;
|
|
177
156
|
runtimeErrors?: OverlayMessageOptions;
|
|
178
|
-
}
|
|
179
|
-
progress?: boolean
|
|
180
|
-
reconnect?: number | boolean
|
|
181
|
-
webSocketTransport?: string
|
|
182
|
-
webSocketURL?: string |
|
|
183
|
-
};
|
|
184
|
-
export type DevServerOptions<A extends BasicApplication =
|
|
185
|
-
ipc?: string | boolean
|
|
186
|
-
host?:
|
|
187
|
-
port?: Port
|
|
188
|
-
hot?: boolean | 'only'
|
|
189
|
-
liveReload?: boolean
|
|
190
|
-
devMiddleware?: DevMiddlewareOptions
|
|
191
|
-
compress?: boolean
|
|
192
|
-
allowedHosts?: string | string[]
|
|
193
|
-
historyApiFallback?: boolean | HistoryApiFallbackOptions
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
setupMiddlewares?: ((middlewares: Middleware[], devServer: Server) => Middleware[]) | undefined;
|
|
157
|
+
};
|
|
158
|
+
progress?: boolean;
|
|
159
|
+
reconnect?: number | boolean;
|
|
160
|
+
webSocketTransport?: LiteralUnion<'ws', string>;
|
|
161
|
+
webSocketURL?: string | DevServerWebSocketURL;
|
|
162
|
+
};
|
|
163
|
+
export type DevServerOptions<A extends BasicApplication = ConnectApplication, S extends BasicServer = BasicServer> = {
|
|
164
|
+
ipc?: string | boolean;
|
|
165
|
+
host?: DevServerHost;
|
|
166
|
+
port?: Port;
|
|
167
|
+
hot?: boolean | 'only';
|
|
168
|
+
liveReload?: boolean;
|
|
169
|
+
devMiddleware?: DevMiddlewareOptions;
|
|
170
|
+
compress?: boolean;
|
|
171
|
+
allowedHosts?: LiteralUnion<'auto' | 'all', string> | string[];
|
|
172
|
+
historyApiFallback?: boolean | HistoryApiFallbackOptions;
|
|
173
|
+
watchFiles?: string | string[] | WatchFiles | (string | WatchFiles)[];
|
|
174
|
+
static?: DevServerStatic;
|
|
175
|
+
server?: ServerType<A, S> | ServerConfiguration<A, S>;
|
|
176
|
+
app?: () => Promise<A>;
|
|
177
|
+
webSocketServer?: boolean | LiteralUnion<'ws', string> | WebSocketServerConfiguration;
|
|
178
|
+
proxy?: DevServerProxyConfigArray;
|
|
179
|
+
open?: string | boolean | OpenOptions | (string | OpenOptions)[];
|
|
180
|
+
setupExitSignals?: boolean;
|
|
181
|
+
client?: boolean | DevServerClient;
|
|
182
|
+
headers?: DevServerHeaders | ((req: IncomingMessage, res: ServerResponse, context: DevMiddlewareContext | undefined) => DevServerHeaders);
|
|
183
|
+
onListening?: (devServer: any) => void;
|
|
184
|
+
setupMiddlewares?: (middlewares: DevServerMiddleware[], devServer: any) => DevServerMiddleware[];
|
|
207
185
|
};
|
|
208
|
-
interface HttpProxyMiddlewareOptions extends HttpProxyServerOptions {
|
|
209
|
-
pathRewrite?: {
|
|
210
|
-
[regexp: string]: string;
|
|
211
|
-
} | ((path: string, req: Request) => string) | ((path: string, req: Request) => Promise<string>);
|
|
212
|
-
router?: {
|
|
213
|
-
[hostOrPath: string]: HttpProxyServerOptions['target'];
|
|
214
|
-
} | ((req: Request) => HttpProxyServerOptions['target']) | ((req: Request) => Promise<HttpProxyServerOptions['target']>);
|
|
215
|
-
logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
216
|
-
logProvider?: LogProviderCallback;
|
|
217
|
-
onError?: OnErrorCallback;
|
|
218
|
-
onProxyRes?: OnProxyResCallback;
|
|
219
|
-
onProxyReq?: OnProxyReqCallback;
|
|
220
|
-
onProxyReqWs?: OnProxyReqWsCallback;
|
|
221
|
-
onOpen?: OnOpenCallback;
|
|
222
|
-
onClose?: OnCloseCallback;
|
|
223
|
-
}
|
|
224
|
-
interface LogProvider {
|
|
225
|
-
log: Logger;
|
|
226
|
-
debug?: Logger;
|
|
227
|
-
info?: Logger;
|
|
228
|
-
warn?: Logger;
|
|
229
|
-
error?: Logger;
|
|
230
|
-
}
|
|
231
|
-
type LogProviderCallback = (provider: LogProvider) => LogProvider;
|
|
232
|
-
type OnErrorCallback = (err: Error, req: Request, res: Response, target?: string | Partial<url.Url>) => void;
|
|
233
|
-
type OnProxyResCallback = (proxyRes: http.IncomingMessage, req: Request, res: Response) => void;
|
|
234
|
-
type OnProxyReqCallback = (proxyReq: http.ClientRequest, req: Request, res: Response, options: HttpProxyServerOptions) => void;
|
|
235
|
-
type OnProxyReqWsCallback = (proxyReq: http.ClientRequest, req: Request, socket: net.Socket, options: HttpProxyServerOptions, head: any) => void;
|
|
236
|
-
type OnCloseCallback = (proxyRes: Response, proxySocket: net.Socket, proxyHead: any) => void;
|
|
237
|
-
type OnOpenCallback = (proxySocket: net.Socket) => void;
|
|
238
|
-
interface HttpProxyServerOptions {
|
|
239
|
-
/** URL string to be parsed with the url module. */
|
|
240
|
-
target?: HttpProxyTarget | undefined;
|
|
241
|
-
/** URL string to be parsed with the url module. */
|
|
242
|
-
forward?: HttpProxyTargetUrl | undefined;
|
|
243
|
-
/** Object to be passed to http(s).request. */
|
|
244
|
-
agent?: any;
|
|
245
|
-
/** Object to be passed to https.createServer(). */
|
|
246
|
-
ssl?: any;
|
|
247
|
-
/** If you want to proxy websockets. */
|
|
248
|
-
ws?: boolean | undefined;
|
|
249
|
-
/** Adds x- forward headers. */
|
|
250
|
-
xfwd?: boolean | undefined;
|
|
251
|
-
/** Verify SSL certificate. */
|
|
252
|
-
secure?: boolean | undefined;
|
|
253
|
-
/** Explicitly specify if we are proxying to another proxy. */
|
|
254
|
-
toProxy?: boolean | undefined;
|
|
255
|
-
/** Specify whether you want to prepend the target's path to the proxy path. */
|
|
256
|
-
prependPath?: boolean | undefined;
|
|
257
|
-
/** Specify whether you want to ignore the proxy path of the incoming request. */
|
|
258
|
-
ignorePath?: boolean | undefined;
|
|
259
|
-
/** Local interface string to bind for outgoing connections. */
|
|
260
|
-
localAddress?: string | undefined;
|
|
261
|
-
/** Changes the origin of the host header to the target URL. */
|
|
262
|
-
changeOrigin?: boolean | undefined;
|
|
263
|
-
/** specify whether you want to keep letter case of response header key */
|
|
264
|
-
preserveHeaderKeyCase?: boolean | undefined;
|
|
265
|
-
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
|
|
266
|
-
auth?: string | undefined;
|
|
267
|
-
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
|
|
268
|
-
hostRewrite?: string | undefined;
|
|
269
|
-
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
|
|
270
|
-
autoRewrite?: boolean | undefined;
|
|
271
|
-
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
|
|
272
|
-
protocolRewrite?: string | undefined;
|
|
273
|
-
/** rewrites domain of set-cookie headers. */
|
|
274
|
-
cookieDomainRewrite?: false | string | {
|
|
275
|
-
[oldDomain: string]: string;
|
|
276
|
-
} | undefined;
|
|
277
|
-
/** rewrites path of set-cookie headers. Default: false */
|
|
278
|
-
cookiePathRewrite?: false | string | {
|
|
279
|
-
[oldPath: string]: string;
|
|
280
|
-
} | undefined;
|
|
281
|
-
/** object with extra headers to be added to target requests. */
|
|
282
|
-
headers?: {
|
|
283
|
-
[header: string]: string;
|
|
284
|
-
} | undefined;
|
|
285
|
-
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
|
|
286
|
-
proxyTimeout?: number | undefined;
|
|
287
|
-
/** Timeout (in milliseconds) for incoming requests */
|
|
288
|
-
timeout?: number | undefined;
|
|
289
|
-
/** Specify whether you want to follow redirects. Default: false */
|
|
290
|
-
followRedirects?: boolean | undefined;
|
|
291
|
-
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
|
|
292
|
-
selfHandleResponse?: boolean | undefined;
|
|
293
|
-
/** Buffer */
|
|
294
|
-
buffer?: stream.Stream | undefined;
|
|
295
|
-
/** Explicitly set the method type of the ProxyReq */
|
|
296
|
-
method?: string | undefined;
|
|
297
|
-
}
|
|
298
|
-
interface HttpProxyTargetDetailed {
|
|
299
|
-
host: string;
|
|
300
|
-
port: number;
|
|
301
|
-
protocol?: string | undefined;
|
|
302
|
-
hostname?: string | undefined;
|
|
303
|
-
socketPath?: string | undefined;
|
|
304
|
-
key?: string | undefined;
|
|
305
|
-
passphrase?: string | undefined;
|
|
306
|
-
pfx?: Buffer | string | undefined;
|
|
307
|
-
cert?: string | undefined;
|
|
308
|
-
ca?: string | undefined;
|
|
309
|
-
ciphers?: string | undefined;
|
|
310
|
-
secureProtocol?: string | undefined;
|
|
311
|
-
}
|
|
312
|
-
type HttpProxyTarget = HttpProxyTargetUrl | HttpProxyTargetDetailed;
|
|
313
|
-
type HttpProxyTargetUrl = string | Partial<url.Url>;
|
|
314
186
|
export {};
|
package/dist/config/types.d.ts
CHANGED
|
@@ -2229,10 +2229,10 @@ export type WatchOptions = {
|
|
|
2229
2229
|
stdin?: boolean;
|
|
2230
2230
|
};
|
|
2231
2231
|
/**
|
|
2232
|
-
* Options for
|
|
2232
|
+
* Options for dev server
|
|
2233
2233
|
* */
|
|
2234
2234
|
export type DevServer = DevServerOptions;
|
|
2235
|
-
export type {
|
|
2235
|
+
export type { DevServerClient, DevServerHeaders, DevServerHost, DevServerMiddleware, DevServerMiddlewareHandler, DevServerOpenOptions, DevServerProxyConfigArray, DevServerProxyConfigArrayItem, DevServerStatic, DevServerStaticItem, DevServerWebSocketURL, } from './devServer.js';
|
|
2236
2236
|
/**
|
|
2237
2237
|
* Ignore specific warnings.
|
|
2238
2238
|
*/
|
|
@@ -2,13 +2,14 @@ import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
|
|
|
2
2
|
import { RspackBuiltinPlugin } from '../builtin-plugin/base.js';
|
|
3
3
|
import type { Compiler } from '../Compiler.js';
|
|
4
4
|
import type { EntryRuntime, FilenameTemplate, LibraryOptions } from '../config/index.js';
|
|
5
|
+
import { type ShareScope } from '../sharing/SharePlugin.js';
|
|
5
6
|
export type ContainerPluginOptions = {
|
|
6
7
|
exposes: Exposes;
|
|
7
8
|
filename?: FilenameTemplate;
|
|
8
9
|
library?: LibraryOptions;
|
|
9
10
|
name: string;
|
|
10
11
|
runtime?: EntryRuntime;
|
|
11
|
-
shareScope?:
|
|
12
|
+
shareScope?: ShareScope;
|
|
12
13
|
enhanced?: boolean;
|
|
13
14
|
};
|
|
14
15
|
export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
|
|
@@ -25,7 +26,7 @@ export declare class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
25
26
|
name: BuiltinPluginName;
|
|
26
27
|
_options: {
|
|
27
28
|
name: string;
|
|
28
|
-
shareScope:
|
|
29
|
+
shareScope: ShareScope;
|
|
29
30
|
library: LibraryOptions;
|
|
30
31
|
runtime: EntryRuntime | undefined;
|
|
31
32
|
filename: string | undefined;
|