@rsbuild/core 2.0.0-beta.0 → 2.0.0-beta.10
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/chokidar/index.d.ts +197 -29
- package/compiled/chokidar/package.json +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/cors/index.d.ts +56 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/index.js +2 -2
- package/compiled/css-loader/package.json +1 -1
- package/compiled/html-rspack-plugin/index.d.ts +102 -1
- package/compiled/html-rspack-plugin/index.js +863 -20
- package/compiled/html-rspack-plugin/package.json +1 -1
- package/compiled/http-proxy-middleware/index.d.ts +268 -43
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/jiti/LICENSE +21 -0
- package/compiled/jiti/README.md +243 -0
- package/compiled/jiti/dist/babel.cjs +46699 -0
- package/compiled/jiti/dist/jiti.cjs +4842 -0
- package/compiled/jiti/lib/jiti-cli.mjs +19 -0
- package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
- package/compiled/jiti/lib/jiti-native.mjs +76 -0
- package/compiled/jiti/lib/jiti-register.d.mts +1 -0
- package/compiled/jiti/lib/jiti-register.mjs +2 -0
- package/compiled/jiti/lib/jiti.cjs +24 -0
- package/compiled/jiti/lib/jiti.d.cts +8 -0
- package/compiled/jiti/lib/jiti.d.mts +8 -0
- package/compiled/jiti/lib/jiti.mjs +23 -0
- package/compiled/jiti/lib/types.d.ts +363 -0
- package/compiled/jiti/package.json +133 -0
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/postcss/lib/comment.d.ts +1 -1
- package/compiled/postcss/lib/container.d.ts +1 -1
- package/compiled/postcss/lib/css-syntax-error.d.ts +1 -1
- package/compiled/postcss/lib/declaration.d.ts +1 -1
- package/compiled/postcss/lib/document.d.ts +1 -1
- package/compiled/postcss/lib/input.d.ts +1 -1
- package/compiled/postcss/lib/lazy-result.d.ts +1 -1
- package/compiled/postcss/lib/no-work-result.d.ts +1 -1
- package/compiled/postcss/lib/node.d.ts +1 -1
- package/compiled/postcss/lib/previous-map.d.ts +1 -1
- package/compiled/postcss/lib/processor.d.ts +1 -1
- package/compiled/postcss/lib/result.d.ts +1 -1
- package/compiled/postcss/lib/root.d.ts +1 -1
- package/compiled/postcss/lib/rule.d.ts +1 -1
- package/compiled/postcss/lib/stringifier.d.ts +1 -1
- package/compiled/postcss/lib/warning.d.ts +1 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +10 -9
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/rslog/index.d.ts +33 -2
- package/compiled/rslog/package.json +1 -1
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-chain/types/index.d.ts +0 -5
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/style-loader/index.js +37 -94
- package/compiled/style-loader/package.json +1 -1
- package/dist/{131.js → 958.js} +1706 -1655
- package/dist/chokidar.js +59 -57
- package/dist/client/hmr.js +3 -3
- package/dist/client/overlay.js +2 -2
- package/dist/connect-next.js +268 -0
- package/dist/{connect.js.LICENSE.txt → connect-next.js.LICENSE.txt} +3 -13
- package/dist/cors.js +2 -2
- package/dist/http-proxy-middleware.js +2985 -0
- package/dist/http-proxy-middleware.js.LICENSE.txt +69 -0
- package/dist/index.js +1 -1
- package/dist/launch-editor-middleware.js +96 -16
- package/dist/manifest-plugin.js +543 -21
- package/dist/memfs.js +241 -776
- package/dist/{710.js → mrmime.js} +2 -1
- package/dist/open.js +32 -28
- package/dist/range-parser.js +2 -2
- package/dist/remapping.js +2 -2
- package/dist/rslib-runtime.js +4 -4
- package/dist/sirv.js +14 -14
- package/dist/src.js +510 -0
- package/dist/tinyglobby.js +114 -69
- package/dist/transformLoader.mjs +38 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist/ws.js +1549 -0
- package/dist-types/createContext.d.ts +3 -2
- package/dist-types/helpers/format.d.ts +2 -1
- package/dist-types/helpers/fs.d.ts +2 -1
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/helpers/stats.d.ts +4 -3
- package/dist-types/helpers/vendors.d.ts +0 -2
- package/dist-types/hooks.d.ts +3 -3
- package/dist-types/index.d.ts +4 -3
- package/dist-types/initPlugins.d.ts +2 -1
- package/dist-types/logger.d.ts +9 -3
- package/dist-types/pluginManager.d.ts +2 -1
- package/dist-types/restart.d.ts +4 -2
- package/dist-types/server/assets-middleware/index.d.ts +3 -2
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +2 -1
- package/dist-types/server/cliShortcuts.d.ts +4 -1
- package/dist-types/server/devMiddlewares.d.ts +4 -6
- package/dist-types/server/devServer.d.ts +8 -42
- package/dist-types/server/helper.d.ts +50 -16
- package/dist-types/server/historyApiFallback.d.ts +2 -1
- package/dist-types/server/middlewares.d.ts +5 -3
- package/dist-types/server/open.d.ts +4 -2
- package/dist-types/server/previewServer.d.ts +4 -0
- package/dist-types/server/proxy.d.ts +3 -2
- package/dist-types/server/runner/asModule.d.ts +1 -1
- package/dist-types/server/serverSetup.d.ts +2 -0
- package/dist-types/server/socketServer.d.ts +4 -1
- package/dist-types/server/watchFiles.d.ts +1 -1
- package/dist-types/types/config.d.ts +123 -25
- package/dist-types/types/context.d.ts +3 -0
- package/dist-types/types/hooks.d.ts +17 -15
- package/dist-types/types/plugin.d.ts +14 -11
- package/dist-types/types/rsbuild.d.ts +11 -4
- package/dist-types/types/thirdParty.d.ts +15 -6
- package/package.json +23 -26
- package/compiled/chokidar/handler.d.ts +0 -90
- package/compiled/http-proxy-middleware/index.js +0 -5284
- package/compiled/ws/index.d.ts +0 -437
- package/compiled/ws/index.js +0 -3166
- package/compiled/ws/license +0 -20
- package/compiled/ws/package.json +0 -1
- package/dist/397.js +0 -11
- package/dist/7.js +0 -1
- package/dist/743.js +0 -7
- package/dist/88.js +0 -40
- package/dist/connect.js +0 -581
- package/dist-types/server/prodServer.d.ts +0 -24
- /package/compiled/html-rspack-plugin/{loader.js → htmlLoader.js} +0 -0
- /package/dist/{131.js.LICENSE.txt → 958.js.LICENSE.txt} +0 -0
- /package/dist/client/{59.js → 797.js} +0 -0
- /package/dist/{31.js → trace-mapping.js} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { Logger } from './logger';
|
|
1
2
|
import type { InternalContext, NormalizedEnvironmentConfig, ResolvedCreateRsbuildOptions, RsbuildConfig, RsbuildContext } from './types';
|
|
2
3
|
export declare function getBrowserslist(path: string): string[] | null;
|
|
3
4
|
export declare function getBrowserslistByEnvironment(path: string, config: NormalizedEnvironmentConfig): string[];
|
|
4
5
|
export declare function updateEnvironmentContext(context: InternalContext, configs: Record<string, NormalizedEnvironmentConfig>): Promise<void>;
|
|
5
6
|
export declare function updateContextByNormalizedConfig(context: InternalContext): void;
|
|
6
|
-
export declare function createPublicContext(context:
|
|
7
|
+
export declare function createPublicContext(context: InternalContext): Readonly<RsbuildContext>;
|
|
7
8
|
/**
|
|
8
9
|
* Generate the actual context used in the build,
|
|
9
10
|
* which can have a lot of overhead and take some side effects.
|
|
10
11
|
*/
|
|
11
|
-
export declare function createContext(options: ResolvedCreateRsbuildOptions, userConfig: RsbuildConfig): Promise<InternalContext>;
|
|
12
|
+
export declare function createContext(options: ResolvedCreateRsbuildOptions, userConfig: RsbuildConfig, logger: Logger): Promise<InternalContext>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { StatsError } from '@rspack/core';
|
|
2
|
-
|
|
2
|
+
import { type Logger } from '../logger';
|
|
3
|
+
export declare function formatStatsError(stats: StatsError, root: string, level: "error" | "warning" | undefined, logger: Logger): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Logger } from '../logger';
|
|
1
2
|
import type { Rspack } from '../types';
|
|
2
3
|
export declare const isFileSync: (filePath: string) => boolean | undefined;
|
|
3
4
|
export declare function isEmptyDir(path: string): boolean;
|
|
@@ -14,4 +15,4 @@ export declare function fileExistsByCompilation({ inputFileSystem }: Rspack.Comp
|
|
|
14
15
|
* Read file asynchronously using Rspack compiler's filesystem.
|
|
15
16
|
*/
|
|
16
17
|
export declare function readFileAsync(fs: NonNullable<Rspack.Compilation['inputFileSystem'] | Rspack.OutputFileSystem>, filename: string): Promise<Buffer | string>;
|
|
17
|
-
export declare function emptyDir(dir: string, keep?: RegExp[], checkExists?: boolean): Promise<void>;
|
|
18
|
+
export declare function emptyDir(dir: string, logger: Logger, keep?: RegExp[], checkExists?: boolean): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import color from '
|
|
1
|
+
import { color } from '../../compiled/rslog';
|
|
2
2
|
import RspackChain from '../../compiled/rspack-chain/types';
|
|
3
3
|
import type { FilenameConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildTarget, Rspack } from '../types';
|
|
4
4
|
export { require } from './vendors';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Logger } from '../logger';
|
|
1
2
|
import type { ActionType, RsbuildStats, Rspack } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* If stats has errors, return stats errors directly
|
|
@@ -6,8 +7,8 @@ import type { ActionType, RsbuildStats, Rspack } from '../types';
|
|
|
6
7
|
*/
|
|
7
8
|
export declare const getStatsErrors: ({ errors, children, }: RsbuildStats) => Rspack.StatsError[];
|
|
8
9
|
export declare const getStatsWarnings: ({ warnings, children, }: RsbuildStats) => Rspack.StatsError[];
|
|
9
|
-
export declare function getRsbuildStats(statsInstance: Rspack.Stats | Rspack.MultiStats, compiler: Rspack.Compiler | Rspack.MultiCompiler, action?: ActionType): RsbuildStats;
|
|
10
|
-
export declare function formatStats(stats: RsbuildStats, hasErrors: boolean, root: string): {
|
|
10
|
+
export declare function getRsbuildStats(statsInstance: Rspack.Stats | Rspack.MultiStats, compiler: Rspack.Compiler | Rspack.MultiCompiler, logger: Logger, action?: ActionType): RsbuildStats;
|
|
11
|
+
export declare function formatStats(stats: RsbuildStats, hasErrors: boolean, root: string, logger: Logger): {
|
|
11
12
|
message?: string;
|
|
12
13
|
level?: string;
|
|
13
14
|
};
|
|
@@ -15,4 +16,4 @@ export declare function formatStats(stats: RsbuildStats, hasErrors: boolean, roo
|
|
|
15
16
|
* Remove the loader chain delimiter from the module identifier.
|
|
16
17
|
* @example ./src/index.js!=!/node_modules/my-loader/index.js -> ./src/index.js
|
|
17
18
|
*/
|
|
18
|
-
export declare const removeLoaderChainDelimiter: (moduleId: string) => string;
|
|
19
|
+
export declare const removeLoaderChainDelimiter: (moduleId: string, logger: Logger) => string;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
type CompiledPackages = {
|
|
2
|
-
ws: typeof import('../../compiled/ws').default;
|
|
3
2
|
'webpack-merge': typeof import('../../compiled/webpack-merge');
|
|
4
3
|
'html-rspack-plugin': typeof import('../../compiled/html-rspack-plugin').default;
|
|
5
|
-
'http-proxy-middleware': typeof import('../../compiled/http-proxy-middleware');
|
|
6
4
|
};
|
|
7
5
|
export declare const require: NodeJS.Require;
|
|
8
6
|
/**
|
package/dist-types/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn,
|
|
1
|
+
import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnExitFn, Rspack } from './types';
|
|
2
2
|
export declare function createEnvironmentAsyncHook<Callback extends (...args: any[]) => any>(): EnvironmentAsyncHook<Callback>;
|
|
3
3
|
export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
|
|
4
4
|
export declare function initHooks(): {
|
|
@@ -12,8 +12,8 @@ export declare function initHooks(): {
|
|
|
12
12
|
onCloseDevServer: AsyncHook<OnCloseDevServerFn>;
|
|
13
13
|
onAfterStartDevServer: AsyncHook<OnAfterStartDevServerFn>;
|
|
14
14
|
onBeforeStartDevServer: AsyncHook<OnBeforeStartDevServerFn>;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
onAfterStartPreviewServer: AsyncHook<OnAfterStartPreviewServerFn>;
|
|
16
|
+
onBeforeStartPreviewServer: AsyncHook<OnBeforeStartPreviewServerFn>;
|
|
17
17
|
onAfterCreateCompiler: AsyncHook<OnAfterCreateCompilerFn>;
|
|
18
18
|
onBeforeCreateCompiler: AsyncHook<OnBeforeCreateCompilerFn>;
|
|
19
19
|
/** The following hooks are related to the environment */
|
package/dist-types/index.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ export type { ChainIdentifier } from './configChain';
|
|
|
15
15
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME } from './constants';
|
|
16
16
|
export { defaultAllowedOrigins } from './defaultConfig';
|
|
17
17
|
export { ensureAssetPrefix } from './helpers/url';
|
|
18
|
-
export { type Logger, logger } from './logger';
|
|
18
|
+
export { createLogger, type Logger, defaultLogger as logger } from './logger';
|
|
19
19
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
20
20
|
export type { RsbuildDevServer } from './server/devServer';
|
|
21
|
-
export type {
|
|
22
|
-
export type {
|
|
21
|
+
export type { RsbuildServerBase, ServerStartResult, StartDevServerResult, StartPreviewServerResult, } from './server/helper';
|
|
22
|
+
export type { RsbuildPreviewServer } from './server/previewServer';
|
|
23
|
+
export type { AliasStrategy, AppIcon, AppIconItem, Build, BuildOptions, BuildResult, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, Connect, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InitConfigsOptions, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedResolveConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedSplitChunksConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolveConfig, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SourceMapExtract, SourceMapExtractTarget, SplitChunks, SplitChunksConfig, SplitChunksPreset, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Logger } from './logger';
|
|
1
2
|
import type { InternalContext, NormalizedEnvironmentConfig, PluginManager, RsbuildPluginAPI } from './types';
|
|
2
|
-
export declare function getHTMLPathByEntry(entryName: string, config: NormalizedEnvironmentConfig): string;
|
|
3
|
+
export declare function getHTMLPathByEntry(entryName: string, config: NormalizedEnvironmentConfig, logger: Logger): string;
|
|
3
4
|
export declare function initPluginAPI({ context, pluginManager, }: {
|
|
4
5
|
context: InternalContext;
|
|
5
6
|
pluginManager: PluginManager;
|
package/dist-types/logger.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* The default logger exported from this module is mainly for CLI/bootstrap
|
|
3
|
+
* scenarios and backwards compatibility. When writing core runtime code,
|
|
4
|
+
* prefer `context.logger` or `api.logger` so logs stay scoped to the current
|
|
5
|
+
* Rsbuild instance.
|
|
6
|
+
*
|
|
2
7
|
* Logging message case convention:
|
|
3
8
|
*
|
|
4
9
|
* Info, ready, success and debug messages:
|
|
@@ -12,8 +17,9 @@
|
|
|
12
17
|
* This convention helps distinguish between normal operations
|
|
13
18
|
* and important alerts that require attention.
|
|
14
19
|
*/
|
|
15
|
-
import { type Logger, logger } from '../compiled/rslog';
|
|
20
|
+
import { createLogger as baseCreateLogger, type Logger, logger as defaultLogger } from '../compiled/rslog';
|
|
16
21
|
export declare const isDebug: () => boolean;
|
|
17
|
-
export declare const isVerbose: () => boolean;
|
|
18
|
-
export
|
|
22
|
+
export declare const isVerbose: (targetLogger: Pick<Logger, "level">) => boolean;
|
|
23
|
+
export declare const createLogger: (...args: Parameters<typeof baseCreateLogger>) => ReturnType<typeof baseCreateLogger>;
|
|
24
|
+
export { defaultLogger };
|
|
19
25
|
export type { Logger };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { Logger } from './logger';
|
|
1
2
|
import type { InternalContext, PluginManager, PluginMeta } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Determines whether the plugin is registered in the specified environment.
|
|
4
5
|
* If the pluginEnvironment is undefined, it means it can match any environment.
|
|
5
6
|
*/
|
|
6
7
|
export declare const isEnvironmentMatch: (pluginEnvironment?: string, specifiedEnvironment?: string) => boolean;
|
|
7
|
-
export declare function createPluginManager(): PluginManager;
|
|
8
|
+
export declare function createPluginManager(logger: Logger): PluginManager;
|
|
8
9
|
/**
|
|
9
10
|
* Sorts plugins by their `enforce` property.
|
|
10
11
|
*/
|
package/dist-types/restart.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { ChokidarOptions } from '../compiled/chokidar
|
|
1
|
+
import type { ChokidarOptions } from '../compiled/chokidar';
|
|
2
|
+
import type { Logger } from './logger';
|
|
2
3
|
import type { RsbuildInstance } from './types';
|
|
3
4
|
type Cleaner = () => unknown;
|
|
4
5
|
/**
|
|
5
6
|
* Add a cleaner to handle side effects
|
|
6
7
|
*/
|
|
7
8
|
export declare const onBeforeRestartServer: (cleaner: Cleaner) => void;
|
|
8
|
-
export declare const restartDevServer: ({ filePath, clear, }
|
|
9
|
+
export declare const restartDevServer: ({ filePath, clear, logger, }: {
|
|
9
10
|
filePath?: string;
|
|
10
11
|
clear?: boolean;
|
|
12
|
+
logger: Logger;
|
|
11
13
|
}) => Promise<boolean>;
|
|
12
14
|
export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions, }: {
|
|
13
15
|
files: string[];
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
|
|
8
8
|
*/
|
|
9
9
|
import { type Compiler, type MultiCompiler } from '@rspack/core';
|
|
10
|
-
import type { InternalContext, NormalizedConfig, RequestHandler } from '../../types';
|
|
10
|
+
import type { InternalContext, LiveReload, NormalizedConfig, RequestHandler } from '../../types';
|
|
11
11
|
import type { SocketServer } from '../socketServer';
|
|
12
12
|
export type MultiWatching = ReturnType<MultiCompiler['watch']>;
|
|
13
13
|
export type AssetsMiddlewareClose = (callback: (err?: Error | null) => void) => void;
|
|
@@ -16,11 +16,12 @@ export type AssetsMiddleware = RequestHandler & {
|
|
|
16
16
|
close: AssetsMiddlewareClose;
|
|
17
17
|
};
|
|
18
18
|
export declare const isClientCompiler: (compiler: Compiler) => boolean;
|
|
19
|
-
export declare const setupServerHooks: ({ context, compiler, token, socketServer, }: {
|
|
19
|
+
export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload, }: {
|
|
20
20
|
context: InternalContext;
|
|
21
21
|
compiler: Compiler;
|
|
22
22
|
token: string;
|
|
23
23
|
socketServer: SocketServer;
|
|
24
|
+
liveReload: LiveReload;
|
|
24
25
|
}) => void;
|
|
25
26
|
/**
|
|
26
27
|
* The assets middleware handles compiler setup for development:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
|
+
import type { Logger } from '../../logger';
|
|
2
3
|
import type { EnvironmentContext, NormalizedDevConfig } from '../../types';
|
|
3
4
|
declare module '@rspack/core' {
|
|
4
5
|
interface Compiler {
|
|
@@ -12,4 +13,4 @@ export type ResolvedWriteToDisk = boolean | ((filePath: string, name?: string) =
|
|
|
12
13
|
* otherwise returns a function that resolves config based on compilation.
|
|
13
14
|
*/
|
|
14
15
|
export declare const resolveWriteToDiskConfig: (config: NormalizedDevConfig, environments: Record<string, EnvironmentContext>, environmentList: EnvironmentContext[]) => ResolvedWriteToDisk;
|
|
15
|
-
export declare function setupWriteToDisk(compilers: Compiler[], writeToDisk: ResolvedWriteToDisk): void;
|
|
16
|
+
export declare function setupWriteToDisk(compilers: Compiler[], writeToDisk: ResolvedWriteToDisk, logger: Logger): void;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { Logger } from '../logger';
|
|
1
2
|
import type { CliShortcut, NormalizedConfig } from '../types/config';
|
|
2
3
|
export declare const isCliShortcutsEnabled: (config: NormalizedConfig) => boolean;
|
|
3
|
-
export declare
|
|
4
|
+
export declare const normalizeShortcutInput: (input: string) => string;
|
|
5
|
+
export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger, }: {
|
|
4
6
|
help?: boolean | string;
|
|
5
7
|
openPage: () => Promise<void>;
|
|
6
8
|
closeServer: () => Promise<void>;
|
|
7
9
|
printUrls: () => void;
|
|
8
10
|
restartServer?: () => Promise<boolean>;
|
|
9
11
|
customShortcuts?: (shortcuts: CliShortcut[]) => CliShortcut[];
|
|
12
|
+
logger: Logger;
|
|
10
13
|
}): Promise<() => void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InternalContext, NormalizedConfig
|
|
1
|
+
import type { InternalContext, NormalizedConfig } from '../types';
|
|
2
2
|
import type { BuildManager } from './buildManager';
|
|
3
3
|
import type { RsbuildDevServer } from './devServer';
|
|
4
4
|
import type { UpgradeEvent } from './helper';
|
|
@@ -6,16 +6,14 @@ export type RsbuildDevMiddlewareOptions = {
|
|
|
6
6
|
config: NormalizedConfig;
|
|
7
7
|
context: InternalContext;
|
|
8
8
|
buildManager?: BuildManager;
|
|
9
|
-
|
|
9
|
+
devServer: RsbuildDevServer;
|
|
10
10
|
/**
|
|
11
|
-
* Callbacks returned by
|
|
11
|
+
* Callbacks returned by `onBeforeStartDevServer` hook and `server.setup` config
|
|
12
12
|
*/
|
|
13
|
-
postCallbacks: (() => void)[];
|
|
13
|
+
postCallbacks: (() => Promise<void> | void)[];
|
|
14
14
|
};
|
|
15
|
-
export type Middlewares = (RequestHandler | [string, RequestHandler])[];
|
|
16
15
|
export type GetDevMiddlewaresResult = {
|
|
17
16
|
close: () => Promise<void>;
|
|
18
17
|
onUpgrade: UpgradeEvent;
|
|
19
|
-
middlewares: Middlewares;
|
|
20
18
|
};
|
|
21
19
|
export declare const getDevMiddlewares: (options: RsbuildDevMiddlewareOptions) => Promise<GetDevMiddlewaresResult>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
|
|
4
|
+
import { type RsbuildServerBase, type StartDevServerResult } from './helper';
|
|
4
5
|
import type { ServerMessage } from './socketServer';
|
|
5
6
|
type HTTPServer = Server | Http2SecureServer;
|
|
6
7
|
type ExtractSocketMessageData<T extends ServerMessage['type']> = Extract<ServerMessage, {
|
|
@@ -9,39 +10,7 @@ type ExtractSocketMessageData<T extends ServerMessage['type']> = Extract<ServerM
|
|
|
9
10
|
data: infer D;
|
|
10
11
|
} ? D : undefined;
|
|
11
12
|
export type SockWrite = <T extends ServerMessage['type']>(type: T, data?: ExtractSocketMessageData<T>) => void;
|
|
12
|
-
export type RsbuildDevServer = {
|
|
13
|
-
/**
|
|
14
|
-
* The `connect` app instance.
|
|
15
|
-
* Can be used to attach custom middlewares to the dev server.
|
|
16
|
-
*/
|
|
17
|
-
middlewares: Connect.Server;
|
|
18
|
-
/**
|
|
19
|
-
* The Node.js HTTP server instance.
|
|
20
|
-
* - Will be `Http2SecureServer` if `server.https` config is used.
|
|
21
|
-
* - Will be `null` if `server.middlewareMode` is enabled.
|
|
22
|
-
*/
|
|
23
|
-
httpServer: import('node:http').Server | import('node:http2').Http2SecureServer | null;
|
|
24
|
-
/**
|
|
25
|
-
* Start listening on the Rsbuild dev server.
|
|
26
|
-
* Do not call this method if you are using a custom server.
|
|
27
|
-
*/
|
|
28
|
-
listen: () => Promise<{
|
|
29
|
-
port: number;
|
|
30
|
-
urls: string[];
|
|
31
|
-
server: {
|
|
32
|
-
close: () => Promise<void>;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Environment API of Rsbuild server.
|
|
37
|
-
*/
|
|
38
|
-
environments: EnvironmentAPI;
|
|
39
|
-
/**
|
|
40
|
-
* The resolved port.
|
|
41
|
-
* By default, Rsbuild server listens on port `3000` and automatically increments
|
|
42
|
-
* the port number if the port is occupied.
|
|
43
|
-
*/
|
|
44
|
-
port: number;
|
|
13
|
+
export type RsbuildDevServer = RsbuildServerBase & {
|
|
45
14
|
/**
|
|
46
15
|
* Notifies Rsbuild that the custom server has successfully started.
|
|
47
16
|
* Rsbuild will trigger the `onAfterStartDevServer` hook at this stage.
|
|
@@ -55,17 +24,14 @@ export type RsbuildDevServer = {
|
|
|
55
24
|
server: HTTPServer;
|
|
56
25
|
}) => void;
|
|
57
26
|
/**
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
close: () => Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Print the server URLs.
|
|
27
|
+
* Environment API of Rsbuild server.
|
|
63
28
|
*/
|
|
64
|
-
|
|
29
|
+
environments: EnvironmentAPI;
|
|
65
30
|
/**
|
|
66
|
-
*
|
|
31
|
+
* Start listening on the Rsbuild dev server.
|
|
32
|
+
* Do not call this method if you are using a custom server.
|
|
67
33
|
*/
|
|
68
|
-
|
|
34
|
+
listen: () => Promise<StartDevServerResult>;
|
|
69
35
|
/**
|
|
70
36
|
* Allows middleware to send some message to HMR client, and then the HMR
|
|
71
37
|
* client will take different actions depending on the message type.
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { IncomingMessage, Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
3
|
import type { Socket } from 'node:net';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Logger } from '../logger';
|
|
5
|
+
import type { Connect, InternalContext, NormalizedConfig, OutputStructure, PrintUrls, Routes, RsbuildConfig, RsbuildEntry } from '../types';
|
|
6
|
+
import type { RsbuildDevServer } from './devServer';
|
|
7
|
+
import type { RsbuildPreviewServer } from './previewServer';
|
|
5
8
|
/**
|
|
6
9
|
* It used to subscribe http upgrade event
|
|
7
10
|
*/
|
|
8
11
|
export type UpgradeEvent = (req: IncomingMessage, socket: Socket, head: any) => void;
|
|
9
|
-
export type
|
|
12
|
+
export type ServerStartResult<T> = {
|
|
10
13
|
/**
|
|
11
14
|
* The URLs that server is listening on.
|
|
12
15
|
*/
|
|
@@ -15,20 +18,19 @@ export type StartServerResult = {
|
|
|
15
18
|
* The actual port used by the server.
|
|
16
19
|
*/
|
|
17
20
|
port: number;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
close: () => Promise<void>;
|
|
24
|
-
};
|
|
21
|
+
/**
|
|
22
|
+
* The dev server or preview server instance.
|
|
23
|
+
*/
|
|
24
|
+
server: T;
|
|
25
25
|
};
|
|
26
|
+
export type StartDevServerResult = ServerStartResult<RsbuildDevServer>;
|
|
27
|
+
export type StartPreviewServerResult = ServerStartResult<RsbuildPreviewServer>;
|
|
26
28
|
export declare const normalizeUrl: (url: string) => string;
|
|
27
29
|
export declare const joinUrlSegments: (s1: string, s2: string) => string;
|
|
28
30
|
export declare const stripBase: (path: string, base: string) => string;
|
|
29
31
|
export declare const getRoutes: (context: InternalContext) => Routes;
|
|
30
32
|
export declare const formatRoutes: (entry: RsbuildEntry, base: string, distPathPrefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
|
|
31
|
-
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak, originalConfig, }: {
|
|
33
|
+
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak, originalConfig, logger, }: {
|
|
32
34
|
urls: {
|
|
33
35
|
url: string;
|
|
34
36
|
label: string;
|
|
@@ -39,6 +41,7 @@ export declare function printServerURLs({ urls: originalUrls, port, routes, prot
|
|
|
39
41
|
printUrls?: PrintUrls;
|
|
40
42
|
trailingLineBreak?: boolean;
|
|
41
43
|
originalConfig?: Readonly<RsbuildConfig>;
|
|
44
|
+
logger: Logger;
|
|
42
45
|
}): string | null;
|
|
43
46
|
/**
|
|
44
47
|
* Get available free port.
|
|
@@ -53,12 +56,8 @@ export declare const getPort: ({ host, port, strictPort, tryLimits, }: {
|
|
|
53
56
|
strictPort: boolean;
|
|
54
57
|
tryLimits?: number;
|
|
55
58
|
}) => Promise<number>;
|
|
56
|
-
export declare const
|
|
57
|
-
config: NormalizedConfig;
|
|
58
|
-
}) => Promise<{
|
|
59
|
+
export declare const resolvePort: (config: NormalizedConfig) => Promise<{
|
|
59
60
|
port: number;
|
|
60
|
-
host: string;
|
|
61
|
-
https: boolean;
|
|
62
61
|
portTip: string | undefined;
|
|
63
62
|
}>;
|
|
64
63
|
export declare const isWildcardHost: (host: string) => boolean;
|
|
@@ -68,7 +67,7 @@ type AddressUrl = {
|
|
|
68
67
|
url: string;
|
|
69
68
|
};
|
|
70
69
|
export declare const getAddressUrls: ({ protocol, port, host, }: {
|
|
71
|
-
protocol
|
|
70
|
+
protocol: string;
|
|
72
71
|
port: number;
|
|
73
72
|
host?: string;
|
|
74
73
|
}) => Promise<AddressUrl[]>;
|
|
@@ -89,4 +88,39 @@ export declare const HttpCode: {
|
|
|
89
88
|
readonly RangeNotSatisfiable: 416;
|
|
90
89
|
readonly InternalServerError: 500;
|
|
91
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* The public server API shared by both the dev and preview servers.
|
|
93
|
+
*/
|
|
94
|
+
export type RsbuildServerBase = {
|
|
95
|
+
/**
|
|
96
|
+
* Close the server.
|
|
97
|
+
* In the dev server, this will call the `onCloseDevServer` hook.
|
|
98
|
+
*/
|
|
99
|
+
close: () => Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* The Node.js HTTP server instance.
|
|
102
|
+
* - Will be `Http2SecureServer` if `server.https` config is used.
|
|
103
|
+
* - Will be `null` if `server.middlewareMode` is enabled.
|
|
104
|
+
*/
|
|
105
|
+
httpServer: import('node:http').Server | import('node:http2').Http2SecureServer | null;
|
|
106
|
+
/**
|
|
107
|
+
* The `connect` app instance.
|
|
108
|
+
* Can be used to attach custom middlewares to the server.
|
|
109
|
+
*/
|
|
110
|
+
middlewares: Connect.Server;
|
|
111
|
+
/**
|
|
112
|
+
* Open URL in the browser after starting the server.
|
|
113
|
+
*/
|
|
114
|
+
open: () => Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* The resolved port.
|
|
117
|
+
* By default, Rsbuild server listens on port `3000` and automatically increments
|
|
118
|
+
* the port number if the port is occupied.
|
|
119
|
+
*/
|
|
120
|
+
port: number;
|
|
121
|
+
/**
|
|
122
|
+
* Print the server URLs.
|
|
123
|
+
*/
|
|
124
|
+
printUrls: () => void;
|
|
125
|
+
};
|
|
92
126
|
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { Logger } from '../logger';
|
|
1
2
|
import type { HistoryApiFallbackOptions, RequestHandler } from '../types';
|
|
2
|
-
export declare function historyApiFallbackMiddleware(options?: HistoryApiFallbackOptions): RequestHandler;
|
|
3
|
+
export declare function historyApiFallbackMiddleware(logger: Logger, options?: HistoryApiFallbackOptions): RequestHandler;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Logger } from '../logger';
|
|
2
|
+
import type { Connect, EnvironmentAPI, RequestHandler } from '../types';
|
|
2
3
|
import type { BuildManager } from './buildManager';
|
|
3
4
|
export declare const faviconFallbackMiddleware: RequestHandler;
|
|
4
|
-
export declare const getRequestLoggerMiddleware: () => Connect.NextHandleFunction;
|
|
5
|
+
export declare const getRequestLoggerMiddleware: (logger: Logger) => Connect.NextHandleFunction;
|
|
5
6
|
export declare const notFoundMiddleware: RequestHandler;
|
|
6
7
|
export declare const optionsFallbackMiddleware: RequestHandler;
|
|
7
8
|
/**
|
|
@@ -23,11 +24,12 @@ export declare const getBaseUrlMiddleware: (params: {
|
|
|
23
24
|
export declare const getHtmlFallbackMiddleware: (params: {
|
|
24
25
|
distPath: string;
|
|
25
26
|
buildManager: BuildManager;
|
|
26
|
-
|
|
27
|
+
logger: Logger;
|
|
27
28
|
}) => RequestHandler;
|
|
28
29
|
/**
|
|
29
30
|
* Support viewing served files via `/rsbuild-dev-server` route
|
|
30
31
|
*/
|
|
31
32
|
export declare const viewingServedFilesMiddleware: (params: {
|
|
32
33
|
environments: EnvironmentAPI;
|
|
34
|
+
logger: Logger;
|
|
33
35
|
}) => RequestHandler;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { Logger } from '../logger';
|
|
1
2
|
import type { NormalizedConfig, Routes } from '../types';
|
|
2
3
|
export declare const replacePortPlaceholder: (url: string, port: number) => string;
|
|
3
4
|
export declare function resolveUrl(str: string, base: string): string;
|
|
4
|
-
export declare function open({
|
|
5
|
-
https?: boolean;
|
|
5
|
+
export declare function open({ port, routes, config, protocol, clearCache, logger, }: {
|
|
6
6
|
port: number;
|
|
7
7
|
routes: Routes;
|
|
8
8
|
config: NormalizedConfig;
|
|
9
|
+
protocol: string;
|
|
9
10
|
clearCache?: boolean;
|
|
11
|
+
logger: Logger;
|
|
10
12
|
}): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InternalContext, NormalizedConfig, PreviewOptions } from '../types';
|
|
2
|
+
import { type RsbuildServerBase, type StartPreviewServerResult } from './helper';
|
|
3
|
+
export type RsbuildPreviewServer = RsbuildServerBase;
|
|
4
|
+
export declare function startPreviewServer(context: InternalContext, config: NormalizedConfig, { getPortSilently }?: PreviewOptions): Promise<StartPreviewServerResult>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Logger } from '../logger';
|
|
1
2
|
import type { RequestHandler as Middleware, ProxyConfig } from '../types';
|
|
2
3
|
import { type UpgradeEvent } from './helper';
|
|
3
|
-
export declare function createProxyMiddleware(proxyOptions: ProxyConfig): {
|
|
4
|
+
export declare function createProxyMiddleware(proxyOptions: ProxyConfig, logger: Logger): Promise<{
|
|
4
5
|
middlewares: Middleware[];
|
|
5
6
|
upgrade: UpgradeEvent;
|
|
6
|
-
}
|
|
7
|
+
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Module, SyntheticModule } from 'node:vm';
|
|
2
|
-
export declare const asModule: (
|
|
2
|
+
export declare const asModule: (moduleExports: Record<string, unknown>, context: Record<string, unknown>, unlinked?: boolean) => Promise<Module | SyntheticModule>;
|
|
@@ -63,7 +63,7 @@ export declare class SocketServer {
|
|
|
63
63
|
upgrade: (req: IncomingMessage, socket: Socket, head: Buffer) => void;
|
|
64
64
|
private checkSockets;
|
|
65
65
|
private clearHeartbeatTimer;
|
|
66
|
-
prepare(): void
|
|
66
|
+
prepare(): Promise<void>;
|
|
67
67
|
onBuildDone(): void;
|
|
68
68
|
/**
|
|
69
69
|
* Send error messages to the client and render error overlay
|
|
@@ -82,6 +82,9 @@ export declare class SocketServer {
|
|
|
82
82
|
sockWrite(message: ServerMessage, token?: string): void;
|
|
83
83
|
close(): Promise<void>;
|
|
84
84
|
private onConnect;
|
|
85
|
+
private getEnvironmentByToken;
|
|
86
|
+
private getInitialChunks;
|
|
87
|
+
private ensureInitialChunks;
|
|
85
88
|
private getStats;
|
|
86
89
|
private sendStats;
|
|
87
90
|
private send;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FSWatcher } from '../../compiled/chokidar
|
|
1
|
+
import type { FSWatcher } from '../../compiled/chokidar';
|
|
2
2
|
import type { ChokidarOptions, NormalizedConfig } from '../types';
|
|
3
3
|
import type { BuildManager } from './buildManager';
|
|
4
4
|
type WatchFilesOptions = {
|