@rsbuild/core 2.0.7 → 2.0.9
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/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/dist/1~rslib-runtime.js +8 -5
- package/dist/{753.js → 756.js} +157 -128
- package/dist/client/hmr.js +1 -1
- package/dist/client/overlay.js +1 -1
- package/dist/http-proxy-middleware.js +2 -5
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +1 -1
- package/dist/manifest-plugin.js +7 -7
- package/dist/memfs.js +5 -5
- package/dist/ws.js +45 -31
- package/dist-types/build.d.ts +1 -1
- package/dist-types/cli/init.d.ts +1 -1
- package/dist-types/configChain.d.ts +59 -118
- package/dist-types/constants.d.ts +35 -31
- package/dist-types/createContext.d.ts +1 -2
- package/dist-types/createRsbuild.d.ts +1 -2
- package/dist-types/defaultConfig.d.ts +2 -4
- package/dist-types/helpers/exitHook.d.ts +1 -1
- package/dist-types/helpers/format.d.ts +2 -1
- package/dist-types/helpers/fs.d.ts +2 -4
- package/dist-types/helpers/index.d.ts +1 -2
- package/dist-types/helpers/packageJson.d.ts +1 -1
- package/dist-types/helpers/path.d.ts +4 -8
- package/dist-types/helpers/stats.d.ts +3 -5
- package/dist-types/helpers/url.d.ts +1 -0
- package/dist-types/helpers/vendors.d.ts +2 -3
- package/dist-types/helpers/version.d.ts +2 -3
- package/dist-types/hooks.d.ts +6 -8
- package/dist-types/index.d.ts +10 -5
- package/dist-types/initConfigs.d.ts +2 -3
- package/dist-types/initPlugins.d.ts +1 -1
- package/dist-types/inspectConfig.d.ts +1 -1
- package/dist-types/loadConfig.d.ts +24 -32
- package/dist-types/loadEnv.d.ts +48 -57
- package/dist-types/loader/transformRawLoader.d.ts +1 -0
- package/dist-types/logger.d.ts +1 -2
- package/dist-types/mergeConfig.d.ts +1 -2
- package/dist-types/pluginHelper.d.ts +1 -2
- package/dist-types/pluginManager.d.ts +4 -7
- package/dist-types/plugins/basic.d.ts +1 -2
- package/dist-types/plugins/css.d.ts +5 -1
- package/dist-types/plugins/externals.d.ts +1 -1
- package/dist-types/plugins/fileSize.d.ts +6 -5
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +1 -0
- package/dist-types/plugins/swc.d.ts +1 -2
- package/dist-types/restart.d.ts +4 -5
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +2 -3
- package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +2 -3
- package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +3 -4
- package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +1 -2
- package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +2 -3
- package/dist-types/rspackConfig.d.ts +1 -1
- package/dist-types/server/ansiHTML.d.ts +1 -2
- package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +1 -2
- package/dist-types/server/assets-middleware/index.d.ts +3 -5
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +1 -2
- package/dist-types/server/browserLogs.d.ts +1 -2
- package/dist-types/server/buildManager.d.ts +4 -6
- package/dist-types/server/cliShortcuts.d.ts +3 -1
- package/dist-types/server/devMiddlewares.d.ts +2 -3
- package/dist-types/server/devServer.d.ts +18 -23
- package/dist-types/server/gracefulShutdown.d.ts +2 -4
- package/dist-types/server/gzipMiddleware.d.ts +1 -1
- package/dist-types/server/helper.d.ts +39 -47
- package/dist-types/server/historyApiFallback.d.ts +8 -1
- package/dist-types/server/httpServer.d.ts +1 -1
- package/dist-types/server/middlewares.d.ts +4 -8
- package/dist-types/server/open.d.ts +1 -1
- package/dist-types/server/runner/basic.d.ts +4 -5
- package/dist-types/server/runner/index.d.ts +3 -1
- package/dist-types/server/socketServer.d.ts +24 -18
- package/dist-types/server/watchFiles.d.ts +1 -1
- package/dist-types/types/config.d.ts +1197 -1457
- package/dist-types/types/context.d.ts +63 -92
- package/dist-types/types/hooks.d.ts +106 -150
- package/dist-types/types/plugin.d.ts +359 -444
- package/dist-types/types/rsbuild.d.ts +156 -191
- package/dist-types/types/thirdParty.d.ts +101 -132
- package/dist-types/types/utils.d.ts +2 -5
- package/package.json +10 -10
- package/dist-types/client/hmr.d.ts +0 -3
- package/dist-types/client/log.d.ts +0 -13
- package/dist-types/client/overlay.d.ts +0 -1
- /package/dist/{753.js.LICENSE.txt → 756.js.LICENSE.txt} +0 -0
- /package/dist/client/{797.js → 60.js} +0 -0
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { CSSLoaderOptions, NormalizedEnvironmentConfig, RsbuildPlugin, Rspack } from '../types';
|
|
2
|
-
export declare function getLightningCSSLoaderOptions(config: NormalizedEnvironmentConfig, targets: string[], minify: boolean): Rspack.LightningcssLoaderOptions
|
|
2
|
+
export declare function getLightningCSSLoaderOptions(config: NormalizedEnvironmentConfig, targets: string[], minify: boolean): Promise<Rspack.LightningcssLoaderOptions>;
|
|
3
|
+
// If the target is not `web` and the modules option of css-loader is enabled,
|
|
4
|
+
// we must enable exportOnlyLocals to only exports the modules identifier mappings.
|
|
5
|
+
// Otherwise, the compiled CSS code may contain invalid code, such as `new URL`.
|
|
6
|
+
// https://github.com/webpack/css-loader#exportonlylocals
|
|
3
7
|
export declare const normalizeCssLoaderOptions: (options: CSSLoaderOptions, exportOnlyLocals: boolean) => CSSLoaderOptions;
|
|
4
8
|
export declare const pluginCss: () => RsbuildPlugin;
|
|
@@ -5,5 +5,5 @@ export declare const composeAutoExternalRules: (options: {
|
|
|
5
5
|
autoExternal?: AutoExternal;
|
|
6
6
|
pkgJson?: PackageJson;
|
|
7
7
|
userExternals?: Externals;
|
|
8
|
-
}) =>
|
|
8
|
+
}) => RegExp[] | undefined;
|
|
9
9
|
export declare function pluginExternals(): RsbuildPlugin;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare
|
|
1
|
+
/**
|
|
2
|
+
* modified from https://github.com/facebook/create-react-app
|
|
3
|
+
* license at https://github.com/facebook/create-react-app/blob/master/LICENSE
|
|
4
|
+
*/ import type { InternalContext, PrintFileSizeAsset, RsbuildPlugin } from '../types';
|
|
5
|
+
/** Normalize file path by removing hash for comparison across builds */ export declare function normalizeFilePath(filePath: string): string;
|
|
6
|
+
/** Exclude source map and license files by default */ export declare const excludeAsset: (asset: PrintFileSizeAsset) => boolean;
|
|
6
7
|
export declare const pluginFileSize: (context: InternalContext) => RsbuildPlugin;
|
package/dist-types/restart.d.ts
CHANGED
|
@@ -4,17 +4,16 @@ import type { RsbuildInstance } from './types';
|
|
|
4
4
|
type Cleaner = () => unknown;
|
|
5
5
|
/**
|
|
6
6
|
* Add a cleaner to handle side effects
|
|
7
|
-
*/
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const restartDevServer: ({ filePath, clear, logger, }: {
|
|
7
|
+
*/ export declare const onBeforeRestartServer: (cleaner: Cleaner) => void;
|
|
8
|
+
export declare const restartDevServer: ({ filePath, clear, logger }: {
|
|
10
9
|
filePath?: string;
|
|
11
10
|
clear?: boolean;
|
|
12
11
|
logger: Logger;
|
|
13
12
|
}) => Promise<boolean>;
|
|
14
|
-
export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions
|
|
13
|
+
export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions }: {
|
|
15
14
|
files: string[];
|
|
16
15
|
rsbuild: RsbuildInstance;
|
|
17
16
|
isBuildWatch: boolean;
|
|
18
17
|
watchOptions?: ChokidarOptions;
|
|
19
18
|
}): Promise<void>;
|
|
20
|
-
export {};
|
|
19
|
+
export { };
|
|
@@ -9,8 +9,7 @@ export type TagConfig = {
|
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
11
|
* A unique identifier for providing extra data to RsbuildHtmlPlugin
|
|
12
|
-
*/
|
|
13
|
-
export declare const entryNameSymbol: unique symbol;
|
|
12
|
+
*/ export declare const entryNameSymbol: unique symbol;
|
|
14
13
|
export type HtmlExtraData = {
|
|
15
14
|
entryName: string;
|
|
16
15
|
context: InternalContext;
|
|
@@ -35,4 +34,4 @@ export declare class RsbuildHtmlPlugin {
|
|
|
35
34
|
constructor(getExtraData: (entryName: string) => HtmlExtraData | undefined, getHTMLPlugin: () => typeof HtmlRspackPlugin);
|
|
36
35
|
apply(compiler: Compiler): void;
|
|
37
36
|
}
|
|
38
|
-
export {};
|
|
37
|
+
export { };
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
17
|
+
*/ import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
19
18
|
import type { HtmlRspackPlugin, ResourceHintsOptions } from '../../types';
|
|
20
19
|
type LinkType = 'preload' | 'prefetch';
|
|
21
20
|
export declare class HtmlResourceHintsPlugin implements RspackPluginInstance {
|
|
@@ -29,4 +28,4 @@ export declare class HtmlResourceHintsPlugin implements RspackPluginInstance {
|
|
|
29
28
|
constructor(options: ResourceHintsOptions, type: LinkType, HTMLCount: number, isDev: boolean, getHTMLPlugin: () => typeof HtmlRspackPlugin);
|
|
30
29
|
apply(compiler: Compiler): void;
|
|
31
30
|
}
|
|
32
|
-
export {};
|
|
31
|
+
export { };
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
import type { Chunk, Compilation } from '@rspack/core';
|
|
17
|
+
*/ import type { Chunk, Compilation } from '@rspack/core';
|
|
19
18
|
import type { HtmlRspackPlugin, ResourceHintsOptions } from '../../types';
|
|
20
19
|
interface DoesChunkBelongToHtmlOptions {
|
|
21
20
|
chunk: Chunk;
|
|
@@ -24,5 +23,5 @@ interface DoesChunkBelongToHtmlOptions {
|
|
|
24
23
|
pluginOptions?: ResourceHintsOptions;
|
|
25
24
|
}
|
|
26
25
|
export declare function recursiveChunkEntryNames(chunk: Chunk): string[];
|
|
27
|
-
export declare function doesChunkBelongToHtml({ chunk, htmlPluginData
|
|
28
|
-
export {};
|
|
26
|
+
export declare function doesChunkBelongToHtml({ chunk, htmlPluginData }: DoesChunkBelongToHtmlOptions): boolean;
|
|
27
|
+
export { };
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
import type { Chunk, Compilation } from '@rspack/core';
|
|
17
|
+
*/ import type { Chunk, Compilation } from '@rspack/core';
|
|
19
18
|
import type { ResourceHintsIncludeType } from '../../types';
|
|
20
19
|
export declare function extractChunks(compilation: Compilation, includeType?: ResourceHintsIncludeType): Chunk[] | {
|
|
21
20
|
files: string[];
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
export
|
|
19
|
-
export declare function getResourceType({ href, file, }: {
|
|
17
|
+
*/ export type ResourceType = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
|
|
18
|
+
export declare function getResourceType({ href, file }: {
|
|
20
19
|
href: string;
|
|
21
20
|
file: string;
|
|
22
21
|
}): ResourceType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EnvironmentContext, InternalContext, ModifyChainUtils, ModifyRspackConfigUtils, RsbuildTarget, Rspack } from './types';
|
|
2
2
|
export declare function getConfigUtils(getCurrentConfig: () => Rspack.Configuration, chainUtils: ModifyChainUtils): ModifyRspackConfigUtils;
|
|
3
3
|
export declare function getChainUtils(target: RsbuildTarget, environment: EnvironmentContext, environments: Record<string, EnvironmentContext>): ModifyChainUtils;
|
|
4
|
-
export declare function generateRspackConfig({ target, context, environmentName
|
|
4
|
+
export declare function generateRspackConfig({ target, context, environmentName }: {
|
|
5
5
|
target: RsbuildTarget;
|
|
6
6
|
context: InternalContext;
|
|
7
7
|
environmentName: string;
|
|
@@ -3,8 +3,7 @@ import type { InternalContext, Rspack } from '../../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Resolves URL to file path with security checks and retrieves file from
|
|
5
5
|
* the build output directories.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.OutputFileSystem, context: InternalContext): Promise<{
|
|
6
|
+
*/ export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.OutputFileSystem, context: InternalContext): Promise<{
|
|
8
7
|
filename: string;
|
|
9
8
|
fsStats: FSStats;
|
|
10
9
|
} | {
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* MIT Licensed
|
|
6
6
|
* Copyright JS Foundation and other contributors
|
|
7
7
|
* https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
|
|
8
|
-
*/
|
|
9
|
-
import { type Compiler, type MultiCompiler } from '@rspack/core';
|
|
8
|
+
*/ import { type Compiler, type MultiCompiler } from '@rspack/core';
|
|
10
9
|
import type { InternalContext, LiveReload, NormalizedConfig, RequestHandler } from '../../types';
|
|
11
10
|
import type { SocketServer } from '../socketServer';
|
|
12
11
|
export type MultiWatching = ReturnType<MultiCompiler['watch']>;
|
|
@@ -16,7 +15,7 @@ export type AssetsMiddleware = RequestHandler & {
|
|
|
16
15
|
close: AssetsMiddlewareClose;
|
|
17
16
|
};
|
|
18
17
|
export declare const isClientCompiler: (compiler: Compiler) => boolean;
|
|
19
|
-
export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload
|
|
18
|
+
export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload }: {
|
|
20
19
|
context: InternalContext;
|
|
21
20
|
compiler: Compiler;
|
|
22
21
|
token: string;
|
|
@@ -28,8 +27,7 @@ export declare const setupServerHooks: ({ context, compiler, token, socketServer
|
|
|
28
27
|
* - Call `compiler.watch`
|
|
29
28
|
* - Inject the HMR client path into page
|
|
30
29
|
* - Notify server when compiler hooks are triggered
|
|
31
|
-
*/
|
|
32
|
-
export declare const assetsMiddleware: ({ config, compiler, context, socketServer, resolvedPort, }: {
|
|
30
|
+
*/ export declare const assetsMiddleware: ({ config, compiler, context, socketServer, resolvedPort }: {
|
|
33
31
|
config: NormalizedConfig;
|
|
34
32
|
compiler: Compiler | MultiCompiler;
|
|
35
33
|
context: InternalContext;
|
|
@@ -11,6 +11,5 @@ export type ResolvedWriteToDisk = boolean | ((filePath: string, name?: string) =
|
|
|
11
11
|
* Resolve writeToDisk config across multiple environments.
|
|
12
12
|
* Returns the unified config if all environments have the same value,
|
|
13
13
|
* otherwise returns a function that resolves config based on compilation.
|
|
14
|
-
*/
|
|
15
|
-
export declare const resolveWriteToDiskConfig: (config: NormalizedDevConfig, environments: Record<string, EnvironmentContext>, environmentList: EnvironmentContext[]) => ResolvedWriteToDisk;
|
|
14
|
+
*/ export declare const resolveWriteToDiskConfig: (config: NormalizedDevConfig, environments: Record<string, EnvironmentContext>, environmentList: EnvironmentContext[]) => ResolvedWriteToDisk;
|
|
16
15
|
export declare function setupWriteToDisk(compilers: Compiler[], writeToDisk: ResolvedWriteToDisk, logger: Logger): void;
|
|
@@ -5,5 +5,4 @@ export type CachedTraceMap = Map<string, TraceMap>;
|
|
|
5
5
|
/**
|
|
6
6
|
* Formats error messages received from the browser into a log string with
|
|
7
7
|
* source location information.
|
|
8
|
-
*/
|
|
9
|
-
export declare const formatBrowserErrorLog: (message: string, context: InternalContext, fs: Rspack.OutputFileSystem, stackTrace: BrowserLogsStackTrace, stackFrames: StackFrame[] | null, cachedTraceMap: CachedTraceMap) => Promise<string>;
|
|
8
|
+
*/ export declare const formatBrowserErrorLog: (message: string, context: InternalContext, fs: Rspack.OutputFileSystem, stackTrace: BrowserLogsStackTrace, stackFrames: StackFrame[] | null, cachedTraceMap: CachedTraceMap) => Promise<string>;
|
|
@@ -11,8 +11,7 @@ type Options = {
|
|
|
11
11
|
* Setup compiler related logic:
|
|
12
12
|
* 1. setup assets middleware
|
|
13
13
|
* 2. establish webSocket connect
|
|
14
|
-
*/
|
|
15
|
-
export declare class BuildManager {
|
|
14
|
+
*/ export declare class BuildManager {
|
|
16
15
|
assetsMiddleware: AssetsMiddleware;
|
|
17
16
|
outputFileSystem: Rspack.OutputFileSystem;
|
|
18
17
|
socketServer: SocketServer;
|
|
@@ -23,11 +22,10 @@ export declare class BuildManager {
|
|
|
23
22
|
constructor({ config, context, compiler, resolvedPort }: Options);
|
|
24
23
|
init(): Promise<void>;
|
|
25
24
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
watch(): void;
|
|
25
|
+
* Call `compiler.watch()` to start compiling.
|
|
26
|
+
*/ watch(): void;
|
|
29
27
|
close(): Promise<void>;
|
|
30
28
|
readFileSync: (fileName: string) => string;
|
|
31
29
|
private setupCompilationMiddleware;
|
|
32
30
|
}
|
|
33
|
-
export {};
|
|
31
|
+
export { };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Logger } from '../logger';
|
|
2
2
|
import type { CliShortcut, NormalizedConfig } from '../types/config';
|
|
3
3
|
export declare const isCliShortcutsEnabled: (config: NormalizedConfig) => boolean;
|
|
4
|
+
// Normalize user input so shortcuts are case-insensitive
|
|
5
|
+
// and still work with accidental surrounding whitespace.
|
|
4
6
|
export declare const normalizeShortcutInput: (input: string) => string;
|
|
5
|
-
export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger
|
|
7
|
+
export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger }: {
|
|
6
8
|
help?: boolean | string;
|
|
7
9
|
openPage: () => Promise<void>;
|
|
8
10
|
closeServer: () => Promise<void>;
|
|
@@ -8,9 +8,8 @@ export type RsbuildDevMiddlewareOptions = {
|
|
|
8
8
|
buildManager?: BuildManager;
|
|
9
9
|
devServer: RsbuildDevServer;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
postCallbacks: (() => Promise<void> | void)[];
|
|
11
|
+
* Callbacks returned by `onBeforeStartDevServer` hook and `server.setup` config
|
|
12
|
+
*/ postCallbacks: (() => Promise<void> | void)[];
|
|
14
13
|
};
|
|
15
14
|
export type GetDevMiddlewaresResult = {
|
|
16
15
|
close: () => Promise<void>;
|
|
@@ -12,36 +12,31 @@ type ExtractSocketMessageData<T extends ServerMessage['type']> = 'data' extends
|
|
|
12
12
|
export type HotSend = <T extends ServerMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
|
|
13
13
|
export type RsbuildDevServer = RsbuildServerBase & {
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
afterListen: () => Promise<void>;
|
|
15
|
+
* Notifies Rsbuild that the custom server has successfully started.
|
|
16
|
+
* Rsbuild will trigger the `onAfterStartDevServer` hook at this stage.
|
|
17
|
+
*/ afterListen: () => Promise<void>;
|
|
19
18
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
connectWebSocket: (options: {
|
|
19
|
+
* Activate socket connection.
|
|
20
|
+
* This ensures that HMR works properly.
|
|
21
|
+
*/ connectWebSocket: (options: {
|
|
24
22
|
server: HTTPServer;
|
|
25
23
|
}) => void;
|
|
26
24
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
environments: EnvironmentAPI;
|
|
25
|
+
* Environment API of Rsbuild server.
|
|
26
|
+
*/ environments: EnvironmentAPI;
|
|
30
27
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
listen: () => Promise<StartDevServerResult>;
|
|
28
|
+
* Start listening on the Rsbuild dev server.
|
|
29
|
+
* Do not call this method if you are using a custom server.
|
|
30
|
+
*/ listen: () => Promise<StartDevServerResult>;
|
|
35
31
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
sockWrite: HotSend;
|
|
32
|
+
* Allows middleware to send some message to HMR client, and then the HMR
|
|
33
|
+
* client will take different actions depending on the message type.
|
|
34
|
+
* - `full-reload`: The page will reload.
|
|
35
|
+
* - `static-changed`: Alias of `full-reload` for backward compatibility.
|
|
36
|
+
* - `custom`: Send custom messages via `custom` type with optional data to the browser and handle them via HMR events.
|
|
37
|
+
*/ sockWrite: HotSend;
|
|
43
38
|
};
|
|
44
39
|
export declare function createDevServer<Options extends {
|
|
45
40
|
context: InternalContext;
|
|
46
41
|
}>(options: Options, createCompiler: CreateCompiler, config: NormalizedConfig, { getPortSilently, runCompile }?: CreateDevServerOptions): Promise<RsbuildDevServer>;
|
|
47
|
-
export {};
|
|
42
|
+
export { };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Registers a cleanup callback to be executed before process termination
|
|
3
|
-
*/
|
|
4
|
-
export declare const registerCleanup: (callback: () => Promise<void>) => void;
|
|
3
|
+
*/ export declare const registerCleanup: (callback: () => Promise<void>) => void;
|
|
5
4
|
export declare const removeCleanup: (callback: () => Promise<void>) => void;
|
|
6
5
|
/**
|
|
7
6
|
* Sets up listeners for termination signals and stdin end event
|
|
8
7
|
* This should be called once during application initialization
|
|
9
|
-
*/
|
|
10
|
-
export declare const setupGracefulShutdown: () => (() => void);
|
|
8
|
+
*/ export declare const setupGracefulShutdown: () => (() => void);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CompressOptions, RequestHandler } from '../types';
|
|
2
|
-
export declare function gzipMiddleware({ filter, level
|
|
2
|
+
export declare function gzipMiddleware({ filter, level }?: CompressOptions): RequestHandler;
|
|
@@ -7,30 +7,31 @@ import type { RsbuildDevServer } from './devServer';
|
|
|
7
7
|
import type { RsbuildPreviewServer } from './previewServer';
|
|
8
8
|
/**
|
|
9
9
|
* It used to subscribe http upgrade event
|
|
10
|
-
*/
|
|
11
|
-
export type UpgradeEvent = (req: IncomingMessage, socket: Socket, head: any) => void;
|
|
10
|
+
*/ export type UpgradeEvent = (req: IncomingMessage, socket: Socket, head: any) => void;
|
|
12
11
|
export type ServerStartResult<T> = {
|
|
13
12
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
urls: string[];
|
|
13
|
+
* The URLs that server is listening on.
|
|
14
|
+
*/ urls: string[];
|
|
17
15
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
port: number;
|
|
16
|
+
* The actual port used by the server.
|
|
17
|
+
*/ port: number;
|
|
21
18
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
server: T;
|
|
19
|
+
* The dev server or preview server instance.
|
|
20
|
+
*/ server: T;
|
|
25
21
|
};
|
|
26
22
|
export type StartDevServerResult = ServerStartResult<RsbuildDevServer>;
|
|
27
23
|
export type StartPreviewServerResult = ServerStartResult<RsbuildPreviewServer>;
|
|
24
|
+
// remove repeat '/'
|
|
28
25
|
export declare const normalizeUrl: (url: string) => string;
|
|
29
|
-
|
|
30
|
-
export declare const
|
|
26
|
+
// /a + /b => /a/b
|
|
27
|
+
export declare const joinUrlPath: (basePath: string, pathname: string) => string;
|
|
28
|
+
export declare const isUrlPathUnderBase: (pathname: string, base: string) => boolean;
|
|
29
|
+
export declare const removeBasePath: (url: string, base: string) => string;
|
|
31
30
|
export declare const getRoutes: (context: InternalContext) => Routes;
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
/*
|
|
32
|
+
* format route by entry and adjust the index route to be the first
|
|
33
|
+
*/ export declare const formatRoutes: (entry: RsbuildEntry, base: string, distPathPrefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
|
|
34
|
+
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, fallbackPathname, trailingLineBreak, originalConfig, logger }: {
|
|
34
35
|
urls: {
|
|
35
36
|
url: string;
|
|
36
37
|
label: string;
|
|
@@ -50,8 +51,7 @@ export declare function printServerURLs({ urls: originalUrls, port, routes, prot
|
|
|
50
51
|
* @param tryLimits - Maximum number of retries.
|
|
51
52
|
* @param strictPort - Whether to throw an error when the port is occupied.
|
|
52
53
|
* @returns Available port number.
|
|
53
|
-
*/
|
|
54
|
-
export declare const getPort: ({ host, port, strictPort, tryLimits, }: {
|
|
54
|
+
*/ export declare const getPort: ({ host, port, strictPort, tryLimits }: {
|
|
55
55
|
host: string;
|
|
56
56
|
port: string | number;
|
|
57
57
|
strictPort: boolean;
|
|
@@ -67,7 +67,7 @@ type AddressUrl = {
|
|
|
67
67
|
label: string;
|
|
68
68
|
url: string;
|
|
69
69
|
};
|
|
70
|
-
export declare const getAddressUrls: ({ protocol, port, host
|
|
70
|
+
export declare const getAddressUrls: ({ protocol, port, host }: {
|
|
71
71
|
protocol: string;
|
|
72
72
|
port: number;
|
|
73
73
|
host?: string;
|
|
@@ -77,8 +77,7 @@ export declare function getServerTerminator(server: Server | Http2SecureServer):
|
|
|
77
77
|
* Escape HTML characters
|
|
78
78
|
* @example
|
|
79
79
|
* escapeHtml('<div>Hello</div>') // '<div>Hello</div>'
|
|
80
|
-
*/
|
|
81
|
-
export declare function escapeHtml(text: string | null | undefined): string;
|
|
80
|
+
*/ export declare function escapeHtml(text: string | null | undefined): string;
|
|
82
81
|
export declare const HttpCode: {
|
|
83
82
|
readonly Ok: 200;
|
|
84
83
|
readonly NotModified: 304;
|
|
@@ -91,37 +90,30 @@ export declare const HttpCode: {
|
|
|
91
90
|
};
|
|
92
91
|
/**
|
|
93
92
|
* The public server API shared by both the dev and preview servers.
|
|
94
|
-
*/
|
|
95
|
-
export type RsbuildServerBase = {
|
|
93
|
+
*/ export type RsbuildServerBase = {
|
|
96
94
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
close: () => Promise<void>;
|
|
95
|
+
* Close the server.
|
|
96
|
+
* In the dev server, this will call the `onCloseDevServer` hook.
|
|
97
|
+
*/ close: () => Promise<void>;
|
|
101
98
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
httpServer: import('node:http').Server | import('node:http2').Http2SecureServer | null;
|
|
99
|
+
* The Node.js HTTP server instance.
|
|
100
|
+
* - Will be `Http2SecureServer` if `server.https` config is used.
|
|
101
|
+
* - Will be `null` if `server.middlewareMode` is enabled.
|
|
102
|
+
*/ httpServer: import('node:http').Server | import('node:http2').Http2SecureServer | null;
|
|
107
103
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
middlewares: Connect.Server;
|
|
104
|
+
* The `connect` app instance.
|
|
105
|
+
* Can be used to attach custom middlewares to the server.
|
|
106
|
+
*/ middlewares: Connect.Server;
|
|
112
107
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
open: () => Promise<void>;
|
|
108
|
+
* Open URL in the browser after starting the server.
|
|
109
|
+
*/ open: () => Promise<void>;
|
|
116
110
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
port: number;
|
|
111
|
+
* The resolved port.
|
|
112
|
+
* By default, Rsbuild server listens on port `3000` and automatically increments
|
|
113
|
+
* the port number if the port is occupied.
|
|
114
|
+
*/ port: number;
|
|
122
115
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
printUrls: () => void;
|
|
116
|
+
* Print the server URLs.
|
|
117
|
+
*/ printUrls: () => void;
|
|
126
118
|
};
|
|
127
|
-
export {};
|
|
119
|
+
export { };
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This module is modified based on source found in
|
|
3
|
+
* https://github.com/bripkens/connect-history-api-fallback
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Copyright (c) 2022 Ben Blackmore and contributors
|
|
7
|
+
* https://github.com/bripkens/connect-history-api-fallback/blob/master/LICENSE
|
|
8
|
+
*/ import type { Logger } from '../logger';
|
|
2
9
|
import type { HistoryApiFallbackOptions, RequestHandler } from '../types';
|
|
3
10
|
export declare function historyApiFallbackMiddleware(logger: Logger, options?: HistoryApiFallbackOptions): RequestHandler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
3
|
import type { Connect, ServerConfig } from '../types';
|
|
4
|
-
export declare const createHttpServer: ({ serverConfig, middlewares
|
|
4
|
+
export declare const createHttpServer: ({ serverConfig, middlewares }: {
|
|
5
5
|
serverConfig: ServerConfig;
|
|
6
6
|
middlewares: Connect.Server;
|
|
7
7
|
}) => Promise<Http2SecureServer | Server>;
|
|
@@ -7,29 +7,25 @@ export declare const notFoundMiddleware: RequestHandler;
|
|
|
7
7
|
export declare const optionsFallbackMiddleware: RequestHandler;
|
|
8
8
|
/**
|
|
9
9
|
* Support access HTML without suffix
|
|
10
|
-
*/
|
|
11
|
-
export declare const getHtmlCompletionMiddleware: (params: {
|
|
10
|
+
*/ export declare const getHtmlCompletionMiddleware: (params: {
|
|
12
11
|
distPath: string;
|
|
13
12
|
buildManager: BuildManager;
|
|
14
13
|
}) => RequestHandler;
|
|
15
14
|
/**
|
|
16
15
|
* handle `server.base`
|
|
17
|
-
*/
|
|
18
|
-
export declare const getBaseUrlMiddleware: (params: {
|
|
16
|
+
*/ export declare const getBaseUrlMiddleware: (params: {
|
|
19
17
|
base: string;
|
|
20
18
|
}) => RequestHandler;
|
|
21
19
|
/**
|
|
22
20
|
* support HTML fallback in some edge cases
|
|
23
|
-
*/
|
|
24
|
-
export declare const getHtmlFallbackMiddleware: (params: {
|
|
21
|
+
*/ export declare const getHtmlFallbackMiddleware: (params: {
|
|
25
22
|
distPath: string;
|
|
26
23
|
buildManager: BuildManager;
|
|
27
24
|
logger: Logger;
|
|
28
25
|
}) => RequestHandler;
|
|
29
26
|
/**
|
|
30
27
|
* Support viewing served files via `/rsbuild-dev-server` route
|
|
31
|
-
*/
|
|
32
|
-
export declare const viewingServedFilesMiddleware: (params: {
|
|
28
|
+
*/ export declare const viewingServedFilesMiddleware: (params: {
|
|
33
29
|
environments: EnvironmentAPI;
|
|
34
30
|
logger: Logger;
|
|
35
31
|
}) => RequestHandler;
|
|
@@ -2,7 +2,7 @@ import type { Logger } from '../logger';
|
|
|
2
2
|
import type { NormalizedConfig, Routes } from '../types';
|
|
3
3
|
export declare const replacePortPlaceholder: (url: string, port: number) => string;
|
|
4
4
|
export declare function resolveUrl(str: string, base: string): string;
|
|
5
|
-
export declare function open({ port, routes, config, protocol, clearCache, logger
|
|
5
|
+
export declare function open({ port, routes, config, protocol, clearCache, logger }: {
|
|
6
6
|
port: number;
|
|
7
7
|
routes: Routes;
|
|
8
8
|
config: NormalizedConfig;
|
|
@@ -18,11 +18,10 @@ export declare abstract class BasicRunner implements Runner {
|
|
|
18
18
|
protected abstract createBaseModuleScope(): BasicModuleScope;
|
|
19
19
|
protected abstract createModuleScope(requireFn: RunnerRequirer, m: ModuleObject, file: BasicRunnerFile): BasicModuleScope;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
protected getFile(modulePath: string[] | string, currentDirectory: string): BasicRunnerFile | null;
|
|
21
|
+
* Get the file information for a given module path.
|
|
22
|
+
*
|
|
23
|
+
* @returns An object containing the file path, content, and subPath, or null if the module is not an rspack output.
|
|
24
|
+
*/ protected getFile(modulePath: string[] | string, currentDirectory: string): BasicRunnerFile | null;
|
|
26
25
|
protected preExecute(_code: string, _file: BasicRunnerFile): void;
|
|
27
26
|
protected postExecute(_m: ModuleObject, _file: BasicRunnerFile): void;
|
|
28
27
|
protected createRunner(): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The following code is modified based on @rspack/test-tools/runner
|
|
3
|
+
*/ import type { RunnerFactoryOptions } from './type';
|
|
2
4
|
export declare const run: <T>({ bundlePath, ...runnerFactoryOptions }: RunnerFactoryOptions & {
|
|
3
5
|
bundlePath: string;
|
|
4
6
|
}) => Promise<T>;
|