@rsbuild/core 2.1.6 → 2.1.8
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/cors/index.d.ts +1 -1
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.d.ts +1 -1
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/postcss.d.ts +4 -1
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/index.d.ts +7 -0
- package/compiled/rslog/package.json +1 -1
- package/dist/{711.js → 626.js} +336 -252
- package/dist/build.d.ts +4 -0
- package/dist/chokidar.js +1 -1046
- package/{dist-types → dist}/cli/commands.d.ts +2 -2
- package/{dist-types → dist}/cli/init.d.ts +3 -4
- package/dist/client/hmr.js +1 -1
- package/dist/client/overlay.js +1 -1
- package/{dist-types → dist}/configChain.d.ts +2 -2
- package/dist/connect-next.js +1 -876
- package/dist/cors.js +1 -1
- package/{dist-types → dist}/createCompiler.d.ts +2 -2
- package/{dist-types → dist}/createContext.d.ts +4 -3
- package/{dist-types → dist}/createRsbuild.d.ts +1 -1
- package/{dist-types → dist}/defaultConfig.d.ts +1 -1
- package/{dist-types → dist}/helpers/compiler.d.ts +1 -1
- package/{dist-types → dist}/helpers/css.d.ts +1 -1
- package/{dist-types → dist}/helpers/format.d.ts +1 -1
- package/{dist-types → dist}/helpers/fs.d.ts +2 -2
- package/{dist-types → dist}/helpers/index.d.ts +4 -4
- package/{dist-types → dist}/helpers/overlayConfig.d.ts +1 -1
- package/{dist-types → dist}/helpers/path.d.ts +1 -1
- package/dist/helpers/restartManager.d.ts +13 -0
- package/{dist-types → dist}/helpers/stats.d.ts +2 -2
- package/{dist-types → dist}/helpers/url.d.ts +2 -2
- package/{dist-types → dist}/helpers/vendors.d.ts +1 -1
- package/{dist-types → dist}/hooks.d.ts +2 -1
- package/dist/http-proxy-middleware.js +5 -3010
- package/{dist-types → dist}/index.d.ts +14 -14
- package/dist/index.js +1 -1
- package/{dist-types → dist}/initConfigs.d.ts +1 -1
- package/{dist-types → dist}/initPlugins.d.ts +2 -2
- package/{dist-types → dist}/inspectConfig.d.ts +2 -2
- package/dist/launch-editor-middleware.js +1 -544
- package/{dist-types → dist}/loadConfig.d.ts +6 -6
- package/{dist-types → dist}/loader/cssUrlLoader.d.ts +1 -1
- package/{dist-types → dist}/loader/ignoreCssLoader.d.ts +1 -1
- package/{dist-types → dist}/loader/transformLoader.d.ts +1 -1
- package/{dist-types → dist}/loader/transformRawLoader.d.ts +1 -1
- package/{dist-types → dist}/logger.d.ts +1 -1
- package/dist/manifest-plugin.js +1 -692
- package/dist/memfs.js +1 -5695
- package/{dist-types → dist}/mergeConfig.d.ts +1 -1
- package/dist/open.js +2 -439
- package/{dist-types → dist}/pluginHelper.d.ts +1 -1
- package/{dist-types → dist}/pluginManager.d.ts +2 -2
- package/{dist-types → dist}/plugins/appIcon.d.ts +1 -1
- package/{dist-types → dist}/plugins/asset.d.ts +1 -1
- package/{dist-types → dist}/plugins/basic.d.ts +1 -1
- package/dist/plugins/cache.d.ts +2 -0
- package/{dist-types → dist}/plugins/cleanOutput.d.ts +1 -1
- package/{dist-types → dist}/plugins/css.d.ts +1 -1
- package/{dist-types → dist}/plugins/define.d.ts +1 -1
- package/dist/plugins/entry.d.ts +2 -0
- package/{dist-types → dist}/plugins/externals.d.ts +2 -2
- package/{dist-types → dist}/plugins/fileSize.d.ts +1 -1
- package/{dist-types → dist}/plugins/html.d.ts +1 -1
- package/{dist-types → dist}/plugins/inlineChunk.d.ts +1 -1
- package/{dist-types → dist}/plugins/lazyCompilation.d.ts +1 -1
- package/{dist-types → dist}/plugins/manifest.d.ts +1 -1
- package/{dist-types → dist}/plugins/minimize.d.ts +3 -3
- package/{dist-types → dist}/plugins/moduleFederation.d.ts +1 -1
- package/{dist-types → dist}/plugins/nodeAddons.d.ts +1 -1
- package/dist/plugins/nonce.d.ts +2 -0
- package/{dist-types → dist}/plugins/output.d.ts +1 -1
- package/{dist-types → dist}/plugins/progress.d.ts +1 -1
- package/{dist-types → dist}/plugins/resolve.d.ts +1 -1
- package/{dist-types → dist}/plugins/resourceHints.d.ts +1 -1
- package/{dist-types → dist}/plugins/rsdoctor.d.ts +1 -1
- package/{dist-types → dist}/plugins/rspackProfile.d.ts +1 -1
- package/{dist-types → dist}/plugins/server.d.ts +1 -1
- package/{dist-types → dist}/plugins/sourceMap.d.ts +1 -1
- package/{dist-types → dist}/plugins/splitChunks.d.ts +1 -1
- package/dist/plugins/sri.d.ts +2 -0
- package/{dist-types → dist}/plugins/swc.d.ts +1 -1
- package/{dist-types → dist}/plugins/target.d.ts +1 -1
- package/dist/plugins/wasm.d.ts +2 -0
- package/{dist-types → dist}/plugins/worker.d.ts +1 -1
- package/dist/range-parser.js +1 -1
- package/dist/restart.d.ts +15 -0
- package/{dist-types → dist}/rspack-plugins/RsbuildHtmlPlugin.d.ts +1 -1
- package/{dist-types → dist}/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +1 -1
- package/{dist-types → dist}/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +1 -1
- package/{dist-types → dist}/rspack-plugins/resource-hints/extractChunks.d.ts +1 -1
- package/{dist-types → dist}/rspackConfig.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/getFileFromUrl.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/index.d.ts +2 -2
- package/{dist-types → dist}/server/assets-middleware/middleware.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/setupOutputFileSystem.d.ts +1 -1
- package/{dist-types → dist}/server/assets-middleware/setupWriteToDisk.d.ts +2 -2
- package/{dist-types → dist}/server/browserLogs.d.ts +1 -1
- package/{dist-types → dist}/server/buildManager.d.ts +3 -3
- package/{dist-types → dist}/server/cliShortcuts.d.ts +2 -2
- package/{dist-types → dist}/server/devMiddlewares.d.ts +4 -4
- package/{dist-types → dist}/server/devServer.d.ts +4 -4
- package/{dist-types → dist}/server/environment.d.ts +1 -1
- package/{dist-types → dist}/server/gzipMiddleware.d.ts +1 -1
- package/{dist-types → dist}/server/helper.d.ts +4 -4
- package/{dist-types → dist}/server/historyApiFallback.d.ts +2 -2
- package/{dist-types → dist}/server/httpServer.d.ts +1 -1
- package/{dist-types → dist}/server/middlewares.d.ts +2 -2
- package/{dist-types → dist}/server/open.d.ts +2 -2
- package/{dist-types → dist}/server/previewServer.d.ts +2 -2
- package/{dist-types → dist}/server/proxy.d.ts +3 -3
- package/{dist-types → dist}/server/runner/basic.d.ts +1 -1
- package/{dist-types → dist}/server/runner/cjs.d.ts +2 -2
- package/{dist-types → dist}/server/runner/esm.d.ts +2 -2
- package/{dist-types → dist}/server/runner/index.d.ts +1 -1
- package/{dist-types → dist}/server/serverSetup.d.ts +1 -1
- package/{dist-types → dist}/server/socketServer.d.ts +1 -1
- package/{dist-types → dist}/server/watchFiles.d.ts +4 -3
- package/dist/sirv.js +1 -1
- package/dist/tinyglobby.js +1 -1670
- package/{dist-types → dist}/types/config.d.ts +36 -19
- package/{dist-types → dist}/types/context.d.ts +11 -7
- package/{dist-types → dist}/types/hooks.d.ts +36 -9
- package/dist/types/index.d.ts +8 -0
- package/{dist-types → dist}/types/plugin.d.ts +10 -7
- package/{dist-types → dist}/types/rsbuild.d.ts +21 -14
- package/{dist-types → dist}/types/rspack.d.ts +2 -2
- package/{dist-types → dist}/types/thirdParty.d.ts +5 -5
- package/dist/ws.js +2 -1528
- package/package.json +11 -12
- package/dist-types/build.d.ts +0 -4
- package/dist-types/package.json +0 -1
- package/dist-types/plugins/cache.d.ts +0 -2
- package/dist-types/plugins/entry.d.ts +0 -2
- package/dist-types/plugins/nonce.d.ts +0 -2
- package/dist-types/plugins/sri.d.ts +0 -2
- package/dist-types/plugins/wasm.d.ts +0 -2
- package/dist-types/restart.d.ts +0 -19
- package/dist-types/types/index.d.ts +0 -8
- /package/dist/{711.js.LICENSE.txt → 626.js.LICENSE.txt} +0 -0
- /package/{dist-types → dist}/cli/index.d.ts +0 -0
- /package/dist/client/{307.js → 307~0.js} +0 -0
- /package/{dist-types → dist}/constants.d.ts +0 -0
- /package/{dist-types → dist}/helpers/exitHook.d.ts +0 -0
- /package/{dist-types → dist}/helpers/packageJson.d.ts +0 -0
- /package/{dist-types → dist}/helpers/version.d.ts +0 -0
- /package/{dist-types → dist}/loadEnv.d.ts +0 -0
- /package/{dist-types → dist}/loader/workerLoader.d.ts +0 -0
- /package/dist/{1~rslib-runtime.js → rslib-runtime.js} +0 -0
- /package/{dist-types → dist}/rspack-plugins/resource-hints/getResourceType.d.ts +0 -0
- /package/{dist-types → dist}/server/ansiHTML.d.ts +0 -0
- /package/{dist-types → dist}/server/assets-middleware/parseTokenList.d.ts +0 -0
- /package/{dist-types → dist}/server/compileState.d.ts +0 -0
- /package/{dist-types → dist}/server/gracefulShutdown.d.ts +0 -0
- /package/{dist-types → dist}/server/hmrFallback.d.ts +0 -0
- /package/{dist-types → dist}/server/overlay.d.ts +0 -0
- /package/{dist-types → dist}/server/publicPathnames.d.ts +0 -0
- /package/{dist-types → dist}/server/runner/asModule.d.ts +0 -0
- /package/{dist-types → dist}/server/runner/type.d.ts +0 -0
- /package/{dist-types → dist}/types/utils.d.ts +0 -0
|
@@ -3,20 +3,20 @@ import type { SecureServerSessionOptions } from 'node:http2';
|
|
|
3
3
|
import type { ServerOptions as HttpsServerOptions } from 'node:https';
|
|
4
4
|
import type { URL } from 'node:url';
|
|
5
5
|
import type { CopyRspackPluginOptions, DefinePluginOptions, Externals, LightningCssMinimizerRspackPluginOptions, ModuleFederationPluginOptions, RuleSetCondition, SwcJsMinimizerRspackPluginOptions, SwcLoaderOptions } from '@rspack/core';
|
|
6
|
-
import type { ChokidarOptions } from '../../compiled/chokidar';
|
|
7
|
-
import type Cors from '../../compiled/cors';
|
|
8
|
-
import type { Options as HttpProxyOptions, Filter as ProxyFilter } from '../../compiled/http-proxy-middleware';
|
|
9
|
-
import type { RspackChain } from '../../compiled/rspack-chain/types';
|
|
10
|
-
import type { FileDescriptor } from '../../compiled/rspack-manifest-plugin';
|
|
11
|
-
import type { HotSend, RsbuildDevServer } from '../server/devServer';
|
|
12
|
-
import type { RsbuildPreviewServer } from '../server/previewServer';
|
|
13
|
-
import type { Logger } from '../logger';
|
|
14
|
-
import type { EnvironmentContext, ModifyBundlerChainUtils, ModifyChainUtils, Routes } from './hooks';
|
|
15
|
-
import type { RsbuildPlugins } from './plugin';
|
|
16
|
-
import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild';
|
|
17
|
-
import type { Rspack, RspackRule } from './rspack';
|
|
18
|
-
import type { Connect, CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, LoosePostCSSPlugin, PostCSSLoaderOptions, StyleLoaderOptions } from './thirdParty';
|
|
19
|
-
import type { ConfigChain, ConfigChainAsyncWithContext, ConfigChainWithContext, LiteralUnion, MaybePromise, OneOrMany, Optional, TwoLevelReadonly } from './utils';
|
|
6
|
+
import type { ChokidarOptions } from '../../compiled/chokidar/index.js';
|
|
7
|
+
import type Cors from '../../compiled/cors/index.js';
|
|
8
|
+
import type { Options as HttpProxyOptions, Filter as ProxyFilter } from '../../compiled/http-proxy-middleware/index.js';
|
|
9
|
+
import type { RspackChain } from '../../compiled/rspack-chain/types/index.js';
|
|
10
|
+
import type { FileDescriptor } from '../../compiled/rspack-manifest-plugin/index.js';
|
|
11
|
+
import type { HotSend, RsbuildDevServer } from '../server/devServer.js';
|
|
12
|
+
import type { RsbuildPreviewServer } from '../server/previewServer.js';
|
|
13
|
+
import type { Logger } from '../logger.js';
|
|
14
|
+
import type { EnvironmentContext, ModifyBundlerChainUtils, ModifyChainUtils, Routes, WatchFileEvent } from './hooks.js';
|
|
15
|
+
import type { RsbuildPlugins } from './plugin.js';
|
|
16
|
+
import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild.js';
|
|
17
|
+
import type { Rspack, RspackRule } from './rspack.js';
|
|
18
|
+
import type { Connect, CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, LoosePostCSSPlugin, PostCSSLoaderOptions, StyleLoaderOptions } from './thirdParty.js';
|
|
19
|
+
import type { ConfigChain, ConfigChainAsyncWithContext, ConfigChainWithContext, LiteralUnion, MaybePromise, OneOrMany, Optional, TwoLevelReadonly } from './utils.js';
|
|
20
20
|
export type ToolsSwcConfig = ConfigChain<SwcLoaderOptions>;
|
|
21
21
|
export type ToolsBundlerChainConfig = OneOrMany<(chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>>;
|
|
22
22
|
export type ToolsPostCSSContext = {
|
|
@@ -870,8 +870,10 @@ export type Minify = boolean | {
|
|
|
870
870
|
*/ js?: boolean | 'always';
|
|
871
871
|
/**
|
|
872
872
|
* Minimizer options of JavaScript, which will be passed to SWC.
|
|
873
|
+
* When using an array, each item registers a separate minimizer and the first matching item
|
|
874
|
+
* applies to each JavaScript asset.
|
|
873
875
|
* @default {}
|
|
874
|
-
*/ jsOptions?: SwcJsMinimizerRspackPluginOptions
|
|
876
|
+
*/ jsOptions?: OneOrMany<SwcJsMinimizerRspackPluginOptions>;
|
|
875
877
|
/**
|
|
876
878
|
* Whether to enable minification for CSS bundles.
|
|
877
879
|
* - `true`: Enabled in production mode.
|
|
@@ -881,8 +883,10 @@ export type Minify = boolean | {
|
|
|
881
883
|
*/ css?: boolean | 'always';
|
|
882
884
|
/**
|
|
883
885
|
* Minimizer options of CSS, which will be passed to LightningCSS.
|
|
886
|
+
* When using an array, each item registers a separate minimizer and the first matching item
|
|
887
|
+
* applies to each CSS asset.
|
|
884
888
|
* @default inherit from `tools.lightningcssLoader` config
|
|
885
|
-
*/ cssOptions?: LightningCssMinimizerRspackPluginOptions
|
|
889
|
+
*/ cssOptions?: OneOrMany<LightningCssMinimizerRspackPluginOptions>;
|
|
886
890
|
};
|
|
887
891
|
export type InlineChunkTestFunction = (params: {
|
|
888
892
|
size: number;
|
|
@@ -1497,12 +1501,22 @@ export type WatchFiles = {
|
|
|
1497
1501
|
* Paths of the files or directories to watch, supports glob syntax.
|
|
1498
1502
|
*/ paths: string | string[];
|
|
1499
1503
|
/**
|
|
1504
|
+
* File events that trigger the configured action.
|
|
1505
|
+
* - `add`: A file is created.
|
|
1506
|
+
* - `change`: A file is modified.
|
|
1507
|
+
* - `unlink`: A file is deleted.
|
|
1508
|
+
* @default ['add', 'change', 'unlink']
|
|
1509
|
+
*/ events?: WatchFileEvent[];
|
|
1510
|
+
/**
|
|
1500
1511
|
* Watch options passed to [chokidar](https://github.com/paulmillr/chokidar).
|
|
1501
1512
|
*/ options?: ChokidarOptions;
|
|
1502
1513
|
/**
|
|
1503
|
-
* Specifies
|
|
1514
|
+
* Specifies the action to take when files change.
|
|
1515
|
+
* - `reload-page`: Reload the page.
|
|
1516
|
+
* - `restart`: Trigger a restart request for the dev server or watch build.
|
|
1517
|
+
* - `reload-server`: Deprecated alias for `restart`.
|
|
1504
1518
|
* @default 'reload-page'
|
|
1505
|
-
*/ type?: 'reload-page' | 'reload-server';
|
|
1519
|
+
*/ type?: 'reload-page' | 'restart' | 'reload-server';
|
|
1506
1520
|
};
|
|
1507
1521
|
export type CliShortcut = {
|
|
1508
1522
|
/**
|
|
@@ -1589,7 +1603,7 @@ export interface DevConfig {
|
|
|
1589
1603
|
*/ writeToDisk?: WriteToDisk;
|
|
1590
1604
|
/**
|
|
1591
1605
|
* Watch specified files and directories for changes. When a file change is detected,
|
|
1592
|
-
* it can trigger a page reload or restart the dev server.
|
|
1606
|
+
* it can trigger a page reload or a restart request for the dev server or watch build.
|
|
1593
1607
|
* @default undefined
|
|
1594
1608
|
*/ watchFiles?: WatchFiles | WatchFiles[];
|
|
1595
1609
|
/**
|
|
@@ -1649,6 +1663,9 @@ export type RsbuildConfigMeta = {
|
|
|
1649
1663
|
/**
|
|
1650
1664
|
* Path to the rsbuild config file.
|
|
1651
1665
|
*/ configFilePath: string;
|
|
1666
|
+
/**
|
|
1667
|
+
* Paths to files imported by the rsbuild config file.
|
|
1668
|
+
*/ configFileDependencies?: string[];
|
|
1652
1669
|
};
|
|
1653
1670
|
/**
|
|
1654
1671
|
* Only some dev options can be defined in the environment config
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import type { Hooks } from '../hooks';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
1
|
+
import type { Hooks } from '../hooks.js';
|
|
2
|
+
import type { RestartManager } from '../helpers/restartManager.js';
|
|
3
|
+
import type { Logger } from '../logger.js';
|
|
4
|
+
import type { SocketServer } from '../server/socketServer.js';
|
|
5
|
+
import type { NormalizedConfig, RsbuildConfig } from './config.js';
|
|
6
|
+
import type { EnvironmentContext } from './hooks.js';
|
|
7
|
+
import type { RsbuildPluginAPI } from './plugin.js';
|
|
8
|
+
import type { RsbuildStats } from './rsbuild.js';
|
|
8
9
|
export type BundlerType = 'rspack';
|
|
9
10
|
export type ActionType = 'dev' | 'build' | 'preview';
|
|
10
11
|
/** The public context */ export type RsbuildContext = {
|
|
11
12
|
/** The Rsbuild core version. */ version: string;
|
|
12
13
|
/** The root path of current project. */ rootPath: string;
|
|
14
|
+
/** Absolute path to the loaded configuration file. */ configFile?: string;
|
|
15
|
+
/** Absolute paths of files imported by the configuration file. */ configFileDependencies: readonly string[];
|
|
13
16
|
/** Absolute path of output files. */ distPath: string;
|
|
14
17
|
/** Absolute path of cache files. */ cachePath: string;
|
|
15
18
|
/**
|
|
@@ -65,6 +68,7 @@ export type BuildState = {
|
|
|
65
68
|
/** The inner context. */ export type InternalContext = RsbuildContext & {
|
|
66
69
|
/** The logger associated with current Rsbuild instance. */ logger: Logger;
|
|
67
70
|
/** All hooks. */ hooks: Readonly<Hooks>;
|
|
71
|
+
/** Manage callbacks for restarting the current Rsbuild instance. */ restartManager: RestartManager;
|
|
68
72
|
/** Current Rsbuild config. */ config: Readonly<RsbuildConfig>;
|
|
69
73
|
/** The original Rsbuild config passed from the createRsbuild method. */ originalConfig: Readonly<RsbuildConfig>;
|
|
70
74
|
/** The normalized Rsbuild config. */ normalizedConfig?: NormalizedConfig;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { rspack } from '@rspack/core';
|
|
2
|
-
import type { ChainIdentifier, ManifestData } from '
|
|
3
|
-
import type { RsbuildDevServer } from '../server/devServer';
|
|
4
|
-
import type { RsbuildPreviewServer } from '../server/previewServer';
|
|
5
|
-
import type { RspackChain } from '../types';
|
|
6
|
-
import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
7
|
-
import type { RsbuildEntry, RsbuildTarget } from './rsbuild';
|
|
8
|
-
import type { Rspack } from './rspack';
|
|
9
|
-
import type { HtmlRspackPlugin } from './thirdParty';
|
|
10
|
-
import type { MaybePromise } from './utils';
|
|
2
|
+
import type { ChainIdentifier, ManifestData } from '../index.js';
|
|
3
|
+
import type { RsbuildDevServer } from '../server/devServer.js';
|
|
4
|
+
import type { RsbuildPreviewServer } from '../server/previewServer.js';
|
|
5
|
+
import type { RspackChain } from '../types/index.js';
|
|
6
|
+
import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config.js';
|
|
7
|
+
import type { BuildOptions, RsbuildEntry, RsbuildTarget, StartDevServerOptions } from './rsbuild.js';
|
|
8
|
+
import type { Rspack } from './rspack.js';
|
|
9
|
+
import type { HtmlRspackPlugin } from './thirdParty.js';
|
|
10
|
+
import type { MaybePromise } from './utils.js';
|
|
11
11
|
type CompileCommonParams = {
|
|
12
12
|
isFirstCompile: boolean;
|
|
13
13
|
isWatch: boolean;
|
|
@@ -102,6 +102,33 @@ export type OnAfterCreateCompilerFn<Compiler = Rspack.Compiler | Rspack.MultiCom
|
|
|
102
102
|
export type OnExitFn = (context: {
|
|
103
103
|
exitCode: number;
|
|
104
104
|
}) => void;
|
|
105
|
+
export type WatchFileEvent = 'add' | 'change' | 'unlink';
|
|
106
|
+
export type RestartContext = {
|
|
107
|
+
/**
|
|
108
|
+
* The absolute path of the file that triggered the restart.
|
|
109
|
+
* It is undefined when the restart is manually triggered.
|
|
110
|
+
*/ filePath?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The file event that triggered the restart.
|
|
113
|
+
* It is undefined when the restart is manually triggered.
|
|
114
|
+
*/ event?: WatchFileEvent;
|
|
115
|
+
} & ({
|
|
116
|
+
/**
|
|
117
|
+
* The current Rsbuild action being restarted.
|
|
118
|
+
*/ action: 'build';
|
|
119
|
+
/**
|
|
120
|
+
* The options passed to `rsbuild.build()`.
|
|
121
|
+
*/ options: BuildOptions;
|
|
122
|
+
} | {
|
|
123
|
+
/**
|
|
124
|
+
* The current Rsbuild action being restarted.
|
|
125
|
+
*/ action: 'dev';
|
|
126
|
+
/**
|
|
127
|
+
* The options passed to `rsbuild.startDevServer()`.
|
|
128
|
+
*/ options: StartDevServerOptions;
|
|
129
|
+
});
|
|
130
|
+
/** Restart the current Rsbuild task and return whether the restart succeeded. */ export type RestartFn = (context: RestartContext) => MaybePromise<boolean>;
|
|
131
|
+
export type OnRestartFn = (context: RestartContext) => MaybePromise<void>;
|
|
105
132
|
export type ModifyHTMLContext = {
|
|
106
133
|
/**
|
|
107
134
|
* The Compilation object of Rspack.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type * from './config.js';
|
|
2
|
+
export type * from './context.js';
|
|
3
|
+
export type * from './hooks.js';
|
|
4
|
+
export type * from './plugin.js';
|
|
5
|
+
export type * from './rsbuild.js';
|
|
6
|
+
export type * from './rspack.js';
|
|
7
|
+
export type * from './thirdParty.js';
|
|
8
|
+
export type * from './utils.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Logger } from '../logger';
|
|
2
|
-
import type { ModifyRspackConfigUtils, NarrowedRspackConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
3
|
-
import type { RsbuildContext } from './context';
|
|
4
|
-
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnExitFn } from './hooks';
|
|
5
|
-
import type { AddPluginsOptions, RsbuildInstance, RsbuildTarget } from './rsbuild';
|
|
6
|
-
import type { Rspack } from './rspack';
|
|
7
|
-
import type { Falsy, MaybePromise } from './utils';
|
|
1
|
+
import type { Logger } from '../logger.js';
|
|
2
|
+
import type { ModifyRspackConfigUtils, NarrowedRspackConfig, NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config.js';
|
|
3
|
+
import type { RsbuildContext } from './context.js';
|
|
4
|
+
import type { EnvironmentContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterDevCompileFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartPreviewServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeDevCompileFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartPreviewServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnExitFn, OnRestartFn } from './hooks.js';
|
|
5
|
+
import type { AddPluginsOptions, RsbuildInstance, RsbuildTarget } from './rsbuild.js';
|
|
6
|
+
import type { Rspack } from './rspack.js';
|
|
7
|
+
import type { Falsy, MaybePromise } from './utils.js';
|
|
8
8
|
type HookOrder = 'pre' | 'post' | 'default';
|
|
9
9
|
export type HookDescriptor<T extends (...args: any[]) => any> = {
|
|
10
10
|
handler: T;
|
|
@@ -452,6 +452,9 @@ export type GetNormalizedConfig = {
|
|
|
452
452
|
* synchronous code.
|
|
453
453
|
*/ onExit: PluginHook<OnExitFn>;
|
|
454
454
|
/**
|
|
455
|
+
* Called when a restart is requested for the dev server or watch build.
|
|
456
|
+
*/ onRestart: PluginHook<OnRestartFn>;
|
|
457
|
+
/**
|
|
455
458
|
* Modify assets before emitting, the same as Rspack's
|
|
456
459
|
* [compilation.hooks.processAssets](https://rspack.rs/api/plugin-api/compilation-hooks#processassets) hook.
|
|
457
460
|
*/ processAssets: ProcessAssetsHook;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
2
|
+
import type { LoadConfigResult } from '../loadConfig.js';
|
|
3
|
+
import type { LoadEnvOptions } from '../loadEnv.js';
|
|
4
|
+
import type { Logger } from '../logger.js';
|
|
5
|
+
import type { RsbuildDevServer } from '../server/devServer.js';
|
|
6
|
+
import type { StartDevServerResult, StartPreviewServerResult } from '../server/helper.js';
|
|
7
|
+
import type { NormalizedConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config.js';
|
|
8
|
+
import type { RsbuildContext } from './context.js';
|
|
9
|
+
import type { RestartFn } from './hooks.js';
|
|
10
|
+
import type { RsbuildPlugin, RsbuildPluginAPI } from './plugin.js';
|
|
11
|
+
import type { Rspack } from './rspack.js';
|
|
12
|
+
import type { Falsy } from './utils.js';
|
|
11
13
|
export type StartDevServerOptions = {
|
|
12
14
|
/**
|
|
13
15
|
* Whether to get port silently and not print any logs.
|
|
@@ -90,6 +92,7 @@ export type InspectConfigResult = {
|
|
|
90
92
|
};
|
|
91
93
|
};
|
|
92
94
|
export type CreateCompiler = () => Promise<Compiler | MultiCompiler>;
|
|
95
|
+
type RsbuildConfigInput = RsbuildConfig | LoadConfigResult;
|
|
93
96
|
export type CreateRsbuildOptions = {
|
|
94
97
|
/**
|
|
95
98
|
* The root path of current project.
|
|
@@ -109,18 +112,21 @@ export type CreateRsbuildOptions = {
|
|
|
109
112
|
/**
|
|
110
113
|
* Alias for `config`.
|
|
111
114
|
* This option will be deprecated in the future.
|
|
112
|
-
*/ rsbuildConfig?:
|
|
115
|
+
*/ rsbuildConfig?: RsbuildConfigInput | (() => Promise<RsbuildConfigInput>);
|
|
113
116
|
/**
|
|
114
|
-
* Rsbuild
|
|
117
|
+
* Rsbuild configuration or the result returned by `loadConfig`.
|
|
115
118
|
* Passing a function to load the config asynchronously with custom logic.
|
|
116
|
-
*/ config?:
|
|
119
|
+
*/ config?: RsbuildConfigInput | (() => Promise<RsbuildConfigInput>);
|
|
117
120
|
/**
|
|
118
121
|
* Whether to call `loadEnv` to load environment variables and define them
|
|
119
122
|
* as global variables via `source.define`.
|
|
120
123
|
* @default false
|
|
121
124
|
*/ loadEnv?: boolean | LoadEnvOptions;
|
|
125
|
+
/**
|
|
126
|
+
* Function used to restart the current dev server or watch build.
|
|
127
|
+
*/ restart?: RestartFn;
|
|
122
128
|
};
|
|
123
|
-
export type ResolvedCreateRsbuildOptions = Required<Pick<CreateRsbuildOptions, 'cwd' | 'callerName'>> & Pick<CreateRsbuildOptions, 'loadEnv' | 'environment'> & {
|
|
129
|
+
export type ResolvedCreateRsbuildOptions = Required<Pick<CreateRsbuildOptions, 'cwd' | 'callerName'>> & Pick<CreateRsbuildOptions, 'loadEnv' | 'environment' | 'restart'> & {
|
|
124
130
|
rsbuildConfig: RsbuildConfig;
|
|
125
131
|
};
|
|
126
132
|
export type CreateDevServer = (options?: CreateDevServerOptions) => Promise<RsbuildDevServer>;
|
|
@@ -214,7 +220,7 @@ export type RsbuildInstance = {
|
|
|
214
220
|
* 1. Start a development server that serves your application.
|
|
215
221
|
* 2. Watch for file changes and trigger recompilation.
|
|
216
222
|
*/ startDevServer: StartDevServer;
|
|
217
|
-
} & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | 'onAfterStartPreviewServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeDevCompile' | 'onBeforeEnvironmentCompile' | 'onBeforeStartDevServer' | 'onBeforeStartPreviewServer' | 'onCloseBuild' | 'onCloseDevServer' | 'onDevCompileDone' | 'onExit'>;
|
|
223
|
+
} & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | 'onAfterStartPreviewServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeDevCompile' | 'onBeforeEnvironmentCompile' | 'onBeforeStartDevServer' | 'onBeforeStartPreviewServer' | 'onCloseBuild' | 'onCloseDevServer' | 'onDevCompileDone' | 'onExit' | 'onRestart'>;
|
|
218
224
|
export type RsbuildTarget = 'web' | 'node' | 'web-worker';
|
|
219
225
|
export type RsbuildEntryDescription = Rspack.EntryDescription & {
|
|
220
226
|
/**
|
|
@@ -231,3 +237,4 @@ export type RsbuildStatsItem = Pick<Rspack.StatsCompilation, 'errors' | 'warning
|
|
|
231
237
|
*/ export type RsbuildStats = RsbuildStatsItem & {
|
|
232
238
|
children: RsbuildStatsItem[];
|
|
233
239
|
};
|
|
240
|
+
export { };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Rspack from '@rspack/core';
|
|
2
|
-
import type { RspackChain } from '../../compiled/rspack-chain/types';
|
|
3
|
-
import type { TransformHandler } from './plugin';
|
|
2
|
+
import type { RspackChain } from '../../compiled/rspack-chain/types/index.js';
|
|
3
|
+
import type { TransformHandler } from './plugin.js';
|
|
4
4
|
export type { Rspack, RspackChain };
|
|
5
5
|
declare module '@rspack/core' {
|
|
6
6
|
interface Compiler {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { CssExtractRspackLoaderOptions, CssExtractRspackPluginOptions } from '@rspack/core';
|
|
2
|
-
import type * as Connect from '../../compiled/connect-next';
|
|
3
|
-
import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin';
|
|
4
|
-
import type { AcceptedPlugin, ProcessOptions } from '../../compiled/postcss';
|
|
5
|
-
import type { Rspack } from './rspack';
|
|
6
|
-
import type { LiteralUnion } from './utils';
|
|
2
|
+
import type * as Connect from '../../compiled/connect-next/index.js';
|
|
3
|
+
import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin/index.js';
|
|
4
|
+
import type { AcceptedPlugin, ProcessOptions } from '../../compiled/postcss/lib/postcss.js';
|
|
5
|
+
import type { Rspack } from './rspack.js';
|
|
6
|
+
import type { LiteralUnion } from './utils.js';
|
|
7
7
|
export type { Connect };
|
|
8
8
|
export type { HtmlRspackPlugin };
|
|
9
9
|
export interface CSSExtractOptions {
|