@ohos-ports/rsbuild-core 1.7.2-beta.1
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/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/@jridgewell/remapping/index.d.ts +1 -0
- package/compiled/@jridgewell/remapping/index.js +1222 -0
- package/compiled/@jridgewell/remapping/license +19 -0
- package/compiled/@jridgewell/remapping/package.json +1 -0
- package/compiled/@jridgewell/trace-mapping/index.d.ts +194 -0
- package/compiled/@jridgewell/trace-mapping/index.js +1408 -0
- package/compiled/@jridgewell/trace-mapping/license +19 -0
- package/compiled/@jridgewell/trace-mapping/package.json +1 -0
- package/compiled/chokidar/index.d.ts +384 -0
- package/compiled/chokidar/index.js +1793 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +1240 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/index.js +371 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/html-rspack-plugin/default_index.ejs +9 -0
- package/compiled/html-rspack-plugin/index.d.ts +290 -0
- package/compiled/html-rspack-plugin/index.js +1602 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +166 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +319 -0
- package/compiled/http-proxy-middleware/index.js +5284 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +719 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/memfs/index.d.ts +1462 -0
- package/compiled/memfs/index.js +1 -0
- package/compiled/memfs/license +201 -0
- package/compiled/memfs/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +456 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/picocolors/index.d.ts +55 -0
- package/compiled/picocolors/index.js +108 -0
- package/compiled/picocolors/license +15 -0
- package/compiled/picocolors/package.json +1 -0
- package/compiled/postcss/index.js +1 -0
- package/compiled/postcss/lib/at-rule.d.ts +140 -0
- package/compiled/postcss/lib/comment.d.ts +68 -0
- package/compiled/postcss/lib/container.d.ts +483 -0
- package/compiled/postcss/lib/css-syntax-error.d.ts +248 -0
- package/compiled/postcss/lib/declaration.d.ts +151 -0
- package/compiled/postcss/lib/document.d.ts +69 -0
- package/compiled/postcss/lib/fromJSON.d.ts +9 -0
- package/compiled/postcss/lib/input.d.ts +227 -0
- package/compiled/postcss/lib/lazy-result.d.ts +190 -0
- package/compiled/postcss/lib/list.d.ts +60 -0
- package/compiled/postcss/lib/no-work-result.d.ts +46 -0
- package/compiled/postcss/lib/node.d.ts +556 -0
- package/compiled/postcss/lib/parse.d.ts +9 -0
- package/compiled/postcss/lib/postcss.d.ts +458 -0
- package/compiled/postcss/lib/previous-map.d.ts +81 -0
- package/compiled/postcss/lib/processor.d.ts +115 -0
- package/compiled/postcss/lib/result.d.ts +205 -0
- package/compiled/postcss/lib/root.d.ts +87 -0
- package/compiled/postcss/lib/rule.d.ts +126 -0
- package/compiled/postcss/lib/source-map-js.d.ts +4 -0
- package/compiled/postcss/lib/stringifier.d.ts +46 -0
- package/compiled/postcss/lib/stringify.d.ts +9 -0
- package/compiled/postcss/lib/warning.d.ts +147 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +720 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rslog/index.d.ts +67 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/license +22 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-chain/types/index.d.ts +545 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/index.js +409 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/sirv/index.d.ts +1 -0
- package/compiled/sirv/index.js +274 -0
- package/compiled/sirv/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +427 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/tinyglobby/index.d.ts +46 -0
- package/compiled/tinyglobby/index.js +2664 -0
- package/compiled/tinyglobby/license +21 -0
- package/compiled/tinyglobby/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
- package/compiled/webpack-bundle-analyzer/index.js +23 -0
- package/compiled/webpack-bundle-analyzer/license +20 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-merge/index.d.ts +31 -0
- package/compiled/webpack-merge/index.js +1200 -0
- package/compiled/webpack-merge/license +20 -0
- package/compiled/webpack-merge/package.json +1 -0
- package/compiled/ws/index.d.ts +437 -0
- package/compiled/ws/index.js +3161 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/0~open.js +427 -0
- package/dist/0~range-parser.js +49 -0
- package/dist/0~range-parser.js.LICENSE.txt +6 -0
- package/dist/131.js +9305 -0
- package/dist/131.js.LICENSE.txt +26 -0
- package/dist/136.mjs +42 -0
- package/dist/2~open.cjs +436 -0
- package/dist/2~range-parser.cjs +52 -0
- package/dist/2~range-parser.cjs.LICENSE.txt +6 -0
- package/dist/client/59.js +22 -0
- package/dist/client/hmr.js +206 -0
- package/dist/client/overlay.js +203 -0
- package/dist/ignoreCssLoader.mjs +3 -0
- package/dist/index.cjs +9456 -0
- package/dist/index.cjs.LICENSE.txt +26 -0
- package/dist/index.js +1 -0
- package/dist/rslib-runtime.js +44 -0
- package/dist/transformLoader.mjs +1 -0
- package/dist/transformRawLoader.mjs +4 -0
- package/dist-types/cli/commands.d.ts +28 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/client/hmr.d.ts +3 -0
- package/dist-types/client/log.d.ts +13 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/configChain.d.ts +154 -0
- package/dist-types/constants.d.ts +52 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +5 -0
- package/dist-types/defaultConfig.d.ts +25 -0
- package/dist-types/helpers/compiler.d.ts +5 -0
- package/dist-types/helpers/exitHook.d.ts +3 -0
- package/dist-types/helpers/format.d.ts +2 -0
- package/dist-types/helpers/fs.d.ts +17 -0
- package/dist-types/helpers/index.d.ts +29 -0
- package/dist-types/helpers/path.d.ts +26 -0
- package/dist-types/helpers/stats.d.ts +18 -0
- package/dist-types/helpers/url.d.ts +11 -0
- package/dist-types/helpers/vendors.d.ts +29 -0
- package/dist-types/helpers/version.d.ts +7 -0
- package/dist-types/hooks.d.ts +44 -0
- package/dist-types/index.d.ts +22 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/inspectConfig.d.ts +35 -0
- package/dist-types/loadConfig.d.ts +60 -0
- package/dist-types/loadEnv.d.ts +63 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +3 -0
- package/dist-types/loader/transformLoader.d.ts +8 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +19 -0
- package/dist-types/mergeConfig.d.ts +2 -0
- package/dist-types/package.json +1 -0
- package/dist-types/pluginHelper.d.ts +12 -0
- package/dist-types/pluginManager.d.ts +21 -0
- package/dist-types/plugins/appIcon.d.ts +2 -0
- package/dist-types/plugins/asset.d.ts +3 -0
- package/dist-types/plugins/basic.d.ts +5 -0
- package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
- package/dist-types/plugins/cache.d.ts +2 -0
- package/dist-types/plugins/cleanOutput.d.ts +2 -0
- package/dist-types/plugins/css.d.ts +4 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/esm.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +6 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +6 -0
- package/dist-types/plugins/lazyCompilation.d.ts +2 -0
- package/dist-types/plugins/manifest.d.ts +2 -0
- package/dist-types/plugins/minimize.d.ts +10 -0
- package/dist-types/plugins/moduleFederation.d.ts +2 -0
- package/dist-types/plugins/moment.d.ts +2 -0
- package/dist-types/plugins/nodeAddons.d.ts +2 -0
- package/dist-types/plugins/nonce.d.ts +2 -0
- package/dist-types/plugins/output.d.ts +2 -0
- package/dist-types/plugins/performance.d.ts +5 -0
- package/dist-types/plugins/progress.d.ts +2 -0
- package/dist-types/plugins/resolve.d.ts +2 -0
- package/dist-types/plugins/resourceHints.d.ts +2 -0
- package/dist-types/plugins/rsdoctor.d.ts +2 -0
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +2 -0
- package/dist-types/plugins/sourceMap.d.ts +2 -0
- package/dist-types/plugins/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +5 -0
- package/dist-types/plugins/target.d.ts +2 -0
- package/dist-types/plugins/wasm.d.ts +2 -0
- package/dist-types/provider/build.d.ts +4 -0
- package/dist-types/provider/createCompiler.d.ts +6 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +19 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/restart.d.ts +18 -0
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +38 -0
- package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +32 -0
- package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +28 -0
- package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +23 -0
- package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +22 -0
- package/dist-types/rspack.d.ts +2 -0
- package/dist-types/server/ansiHTML.d.ts +4 -0
- package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +12 -0
- package/dist-types/server/assets-middleware/index.d.ts +37 -0
- package/dist-types/server/assets-middleware/middleware.d.ts +2 -0
- package/dist-types/server/assets-middleware/parseTokenList.d.ts +1 -0
- package/dist-types/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
- package/dist-types/server/browserLogs.d.ts +9 -0
- package/dist-types/server/buildManager.d.ts +33 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/devMiddlewares.d.ts +21 -0
- package/dist-types/server/devServer.d.ts +79 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/gracefulShutdown.d.ts +10 -0
- package/dist-types/server/gzipMiddleware.d.ts +2 -0
- package/dist-types/server/helper.d.ts +91 -0
- package/dist-types/server/historyApiFallback.d.ts +2 -0
- package/dist-types/server/hmrFallback.d.ts +1 -0
- package/dist-types/server/httpServer.d.ts +7 -0
- package/dist-types/server/middlewares.d.ts +33 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/overlay.d.ts +3 -0
- package/dist-types/server/prodServer.d.ts +24 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +29 -0
- package/dist-types/server/runner/cjs.d.ts +10 -0
- package/dist-types/server/runner/esm.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +4 -0
- package/dist-types/server/runner/type.d.ts +42 -0
- package/dist-types/server/socketServer.d.ts +81 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1882 -0
- package/dist-types/types/context.d.ts +110 -0
- package/dist-types/types/hooks.d.ts +275 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +585 -0
- package/dist-types/types/rsbuild.d.ts +286 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +186 -0
- package/dist-types/types/utils.d.ts +19 -0
- package/package.json +114 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +349 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Hooks } from '../hooks';
|
|
2
|
+
import type { SocketServer } from '../server/socketServer';
|
|
3
|
+
import type { NormalizedConfig, RsbuildConfig } from './config';
|
|
4
|
+
import type { EnvironmentContext } from './hooks';
|
|
5
|
+
import type { RsbuildPluginAPI } from './plugin';
|
|
6
|
+
import type { RsbuildStats } from './rsbuild';
|
|
7
|
+
export type BundlerType = 'rspack' | 'webpack';
|
|
8
|
+
export type ActionType = 'dev' | 'build' | 'preview';
|
|
9
|
+
/** The public context */
|
|
10
|
+
export type RsbuildContext = {
|
|
11
|
+
/** The Rsbuild core version. */
|
|
12
|
+
version: string;
|
|
13
|
+
/** The root path of current project. */
|
|
14
|
+
rootPath: string;
|
|
15
|
+
/** Absolute path of output files. */
|
|
16
|
+
distPath: string;
|
|
17
|
+
/** Absolute path of cache files. */
|
|
18
|
+
cachePath: string;
|
|
19
|
+
/**
|
|
20
|
+
* Dev server information when running in dev mode.
|
|
21
|
+
* Available after the dev server has been created.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { createRsbuild } from '@rsbuild/core';
|
|
26
|
+
*
|
|
27
|
+
* async function main() {
|
|
28
|
+
* const rsbuild = createRsbuild({
|
|
29
|
+
* // ...
|
|
30
|
+
* });
|
|
31
|
+
* await rsbuild.startDevServer();
|
|
32
|
+
* console.log(rsbuild.context.devServer);
|
|
33
|
+
* // { hostname: 'localhost', port: 3000, https: false }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
devServer?: {
|
|
38
|
+
/** The hostname the server is running on. */
|
|
39
|
+
hostname: string;
|
|
40
|
+
/** The actual port number the server is listening on. */
|
|
41
|
+
port: number;
|
|
42
|
+
/** Whether the server is using HTTPS protocol. */
|
|
43
|
+
https: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The current action type.
|
|
47
|
+
* - dev: will be set when running `rsbuild dev` or `rsbuild.startDevServer()`
|
|
48
|
+
* - build: will be set when running `rsbuild build` or `rsbuild.build()`
|
|
49
|
+
* - preview: will be set when running `rsbuild preview` or `rsbuild.preview()`
|
|
50
|
+
*/
|
|
51
|
+
action?: ActionType;
|
|
52
|
+
/**
|
|
53
|
+
* The bundler type, can be `rspack` or `webpack`.
|
|
54
|
+
*/
|
|
55
|
+
bundlerType: BundlerType;
|
|
56
|
+
/**
|
|
57
|
+
* The name of the framework or tool that is currently invoking Rsbuild,
|
|
58
|
+
* same as the `callerName` option in the `createRsbuild` method.
|
|
59
|
+
* @example
|
|
60
|
+
* - `rslib` is set when Rslib calls Rsbuild.
|
|
61
|
+
* - `rspress` is set when Rspress calls Rsbuild.
|
|
62
|
+
*/
|
|
63
|
+
callerName: string;
|
|
64
|
+
};
|
|
65
|
+
export type BuildStatus = 'idle' | 'building' | 'done';
|
|
66
|
+
export type BuildState = {
|
|
67
|
+
/**
|
|
68
|
+
* The stats object of the last build.
|
|
69
|
+
* Available after the build has been done.
|
|
70
|
+
*/
|
|
71
|
+
stats: RsbuildStats | null;
|
|
72
|
+
/** Current build status */
|
|
73
|
+
status: BuildStatus;
|
|
74
|
+
/** Whether there are build errors */
|
|
75
|
+
hasErrors: boolean;
|
|
76
|
+
/** The build time of each environment */
|
|
77
|
+
time: Record<string, number>;
|
|
78
|
+
};
|
|
79
|
+
/** The inner context. */
|
|
80
|
+
export type InternalContext = RsbuildContext & {
|
|
81
|
+
/** All hooks. */
|
|
82
|
+
hooks: Readonly<Hooks>;
|
|
83
|
+
/** Current Rsbuild config. */
|
|
84
|
+
config: Readonly<RsbuildConfig>;
|
|
85
|
+
/** The original Rsbuild config passed from the createRsbuild method. */
|
|
86
|
+
originalConfig: Readonly<RsbuildConfig>;
|
|
87
|
+
/** The normalized Rsbuild config. */
|
|
88
|
+
normalizedConfig?: NormalizedConfig;
|
|
89
|
+
/**
|
|
90
|
+
* Get the plugin API.
|
|
91
|
+
* When environment is undefined, the global plugin API is returned, which
|
|
92
|
+
* can be used in all environments.
|
|
93
|
+
*/
|
|
94
|
+
getPluginAPI?: (environment?: string) => RsbuildPluginAPI;
|
|
95
|
+
/** Context information for all environments. */
|
|
96
|
+
environments: Record<string, EnvironmentContext>;
|
|
97
|
+
/** Array of all environments. */
|
|
98
|
+
environmentList: EnvironmentContext[];
|
|
99
|
+
/** Only build specified environment. */
|
|
100
|
+
specifiedEnvironments?: string[];
|
|
101
|
+
/** Build state information */
|
|
102
|
+
buildState: BuildState;
|
|
103
|
+
/** The socket server instance. */
|
|
104
|
+
socketServer?: SocketServer;
|
|
105
|
+
/**
|
|
106
|
+
* Pathnames derived from public paths, stripped of `server.base`.
|
|
107
|
+
* Used for static asset serving.
|
|
108
|
+
*/
|
|
109
|
+
publicPathnames: string[];
|
|
110
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import type { rspack } from '@rspack/core';
|
|
2
|
+
import type { ChainIdentifier, ManifestData } from '..';
|
|
3
|
+
import type { RsbuildDevServer } from '../server/devServer';
|
|
4
|
+
import type { RspackChain } from '../types';
|
|
5
|
+
import type { EnvironmentConfig, HtmlBasicTag, MergedEnvironmentConfig, NormalizedEnvironmentConfig, RsbuildConfig } from './config';
|
|
6
|
+
import type { RsbuildEntry, RsbuildTarget } from './rsbuild';
|
|
7
|
+
import type { Rspack } from './rspack';
|
|
8
|
+
import type { HtmlRspackPlugin, WebpackConfig } from './thirdParty';
|
|
9
|
+
import type { MaybePromise } from './utils';
|
|
10
|
+
type CompileCommonParams = {
|
|
11
|
+
isFirstCompile: boolean;
|
|
12
|
+
isWatch: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type OnBeforeEnvironmentCompileFn<B = 'rspack'> = (params: CompileCommonParams & {
|
|
15
|
+
environment: EnvironmentContext;
|
|
16
|
+
bundlerConfig?: B extends 'rspack' ? Rspack.Configuration : WebpackConfig;
|
|
17
|
+
}) => MaybePromise<void>;
|
|
18
|
+
export type OnCloseBuildFn = () => MaybePromise<void>;
|
|
19
|
+
export type OnBeforeBuildFn<B = 'rspack'> = (params: CompileCommonParams & {
|
|
20
|
+
/**
|
|
21
|
+
* Context information for all environments.
|
|
22
|
+
*/
|
|
23
|
+
environments: Record<string, EnvironmentContext>;
|
|
24
|
+
bundlerConfigs?: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
|
|
25
|
+
}) => MaybePromise<void>;
|
|
26
|
+
export type OnBeforeDevCompileFn<B = 'rspack'> = (params: CompileCommonParams & {
|
|
27
|
+
/**
|
|
28
|
+
* Context information for all environments.
|
|
29
|
+
*/
|
|
30
|
+
environments: Record<string, EnvironmentContext>;
|
|
31
|
+
bundlerConfigs?: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
|
|
32
|
+
}) => MaybePromise<void>;
|
|
33
|
+
export type OnAfterEnvironmentCompileFn = (params: CompileCommonParams & {
|
|
34
|
+
stats?: Rspack.Stats;
|
|
35
|
+
/**
|
|
36
|
+
* The time it takes to build the current environment in milliseconds.
|
|
37
|
+
*/
|
|
38
|
+
time: number;
|
|
39
|
+
environment: EnvironmentContext;
|
|
40
|
+
}) => MaybePromise<void>;
|
|
41
|
+
export type OnAfterBuildFn = (params: CompileCommonParams & {
|
|
42
|
+
stats?: Rspack.Stats | Rspack.MultiStats;
|
|
43
|
+
/**
|
|
44
|
+
* Context information for all environments.
|
|
45
|
+
*/
|
|
46
|
+
environments: Record<string, EnvironmentContext>;
|
|
47
|
+
}) => MaybePromise<void>;
|
|
48
|
+
export type OnCloseDevServerFn = () => MaybePromise<void>;
|
|
49
|
+
export type OnAfterDevCompileFn = (params: {
|
|
50
|
+
isFirstCompile: boolean;
|
|
51
|
+
stats: Rspack.Stats | Rspack.MultiStats;
|
|
52
|
+
/**
|
|
53
|
+
* Context information for all environments.
|
|
54
|
+
*/
|
|
55
|
+
environments: Record<string, EnvironmentContext>;
|
|
56
|
+
}) => MaybePromise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use `OnAfterDevCompileFn` instead.
|
|
59
|
+
*/
|
|
60
|
+
export type OnDevCompileDoneFn = OnAfterDevCompileFn;
|
|
61
|
+
export type OnBeforeStartDevServerFn = (params: {
|
|
62
|
+
/**
|
|
63
|
+
* The dev server instance, the same as the return value of `createDevServer`.
|
|
64
|
+
*/
|
|
65
|
+
server: RsbuildDevServer;
|
|
66
|
+
/**
|
|
67
|
+
* Context information for all environments.
|
|
68
|
+
*/
|
|
69
|
+
environments: Record<string, EnvironmentContext>;
|
|
70
|
+
}) => MaybePromise<(() => void) | void>;
|
|
71
|
+
export type OnBeforeStartProdServerFn = () => MaybePromise<void>;
|
|
72
|
+
export type Routes = {
|
|
73
|
+
entryName: string;
|
|
74
|
+
pathname: string;
|
|
75
|
+
}[];
|
|
76
|
+
export type OnAfterStartDevServerFn = (params: {
|
|
77
|
+
port: number;
|
|
78
|
+
routes: Routes;
|
|
79
|
+
/**
|
|
80
|
+
* Context information for all environments.
|
|
81
|
+
*/
|
|
82
|
+
environments: Record<string, EnvironmentContext>;
|
|
83
|
+
}) => MaybePromise<void>;
|
|
84
|
+
export type OnAfterStartProdServerFn = (params: {
|
|
85
|
+
port: number;
|
|
86
|
+
routes: Routes;
|
|
87
|
+
/**
|
|
88
|
+
* Context information for all environments.
|
|
89
|
+
*/
|
|
90
|
+
environments: Record<string, EnvironmentContext>;
|
|
91
|
+
}) => MaybePromise<void>;
|
|
92
|
+
export type OnBeforeCreateCompilerFn<B = 'rspack'> = (params: {
|
|
93
|
+
bundlerConfigs: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
|
|
94
|
+
/**
|
|
95
|
+
* Context information for all environments.
|
|
96
|
+
*/
|
|
97
|
+
environments: Record<string, EnvironmentContext>;
|
|
98
|
+
}) => MaybePromise<void>;
|
|
99
|
+
export type OnAfterCreateCompilerFn<Compiler = Rspack.Compiler | Rspack.MultiCompiler> = (params: {
|
|
100
|
+
compiler: Compiler;
|
|
101
|
+
/**
|
|
102
|
+
* Context information for all environments.
|
|
103
|
+
*/
|
|
104
|
+
environments: Record<string, EnvironmentContext>;
|
|
105
|
+
}) => MaybePromise<void>;
|
|
106
|
+
export type OnExitFn = (context: {
|
|
107
|
+
exitCode: number;
|
|
108
|
+
}) => void;
|
|
109
|
+
export type ModifyHTMLContext = {
|
|
110
|
+
/**
|
|
111
|
+
* The Compilation object of Rspack.
|
|
112
|
+
*/
|
|
113
|
+
compilation: Rspack.Compilation;
|
|
114
|
+
/**
|
|
115
|
+
* The Compiler object of Rspack.
|
|
116
|
+
*/
|
|
117
|
+
compiler: Rspack.Compiler;
|
|
118
|
+
/**
|
|
119
|
+
* The name of the HTML file, relative to the dist directory.
|
|
120
|
+
* @example 'index.html'
|
|
121
|
+
*/
|
|
122
|
+
filename: string;
|
|
123
|
+
/**
|
|
124
|
+
* The environment context for current build.
|
|
125
|
+
*/
|
|
126
|
+
environment: EnvironmentContext;
|
|
127
|
+
};
|
|
128
|
+
export type ModifyHTMLFn = (html: string, context: ModifyHTMLContext) => MaybePromise<string>;
|
|
129
|
+
type HTMLTags = {
|
|
130
|
+
headTags: HtmlBasicTag[];
|
|
131
|
+
bodyTags: HtmlBasicTag[];
|
|
132
|
+
};
|
|
133
|
+
export type ModifyHTMLTagsContext = Pick<ModifyHTMLContext, 'compilation' | 'compiler' | 'filename' | 'environment'> & {
|
|
134
|
+
/**
|
|
135
|
+
* URL prefix of assets.
|
|
136
|
+
* @example 'https://example.com/'
|
|
137
|
+
*/
|
|
138
|
+
assetPrefix: string;
|
|
139
|
+
};
|
|
140
|
+
export type ModifyHTMLTagsFn = (tags: HTMLTags, context: ModifyHTMLTagsContext) => MaybePromise<HTMLTags>;
|
|
141
|
+
export type ModifyRsbuildConfigUtils = {
|
|
142
|
+
/** Merge multiple Rsbuild config objects into one. */
|
|
143
|
+
mergeRsbuildConfig: (...configs: RsbuildConfig[]) => RsbuildConfig;
|
|
144
|
+
};
|
|
145
|
+
type ArrayAtLeastOne<A, B> = [A, ...(A | B)[]] | [...(A | B)[], A];
|
|
146
|
+
export type ModifyEnvironmentConfigUtils = {
|
|
147
|
+
/** environment name. */
|
|
148
|
+
name: string;
|
|
149
|
+
/** Merge multiple Rsbuild environment config objects into one. */
|
|
150
|
+
mergeEnvironmentConfig: (...configs: ArrayAtLeastOne<MergedEnvironmentConfig, EnvironmentConfig>) => MergedEnvironmentConfig;
|
|
151
|
+
};
|
|
152
|
+
export type ModifyRsbuildConfigFn = (config: RsbuildConfig, utils: ModifyRsbuildConfigUtils) => MaybePromise<RsbuildConfig | void>;
|
|
153
|
+
export type ModifyEnvironmentConfigFn = (config: MergedEnvironmentConfig, utils: ModifyEnvironmentConfigUtils) => MaybePromise<MergedEnvironmentConfig | void>;
|
|
154
|
+
export type EnvironmentContext = {
|
|
155
|
+
/**
|
|
156
|
+
* The index of the current environment.
|
|
157
|
+
*/
|
|
158
|
+
index: number;
|
|
159
|
+
/**
|
|
160
|
+
* The unique name of the current environment is used to distinguish and locate the
|
|
161
|
+
* environment, corresponds to the key in the `environments` configuration.
|
|
162
|
+
*/
|
|
163
|
+
name: string;
|
|
164
|
+
/**
|
|
165
|
+
* The entry object from the `source.entry` option.
|
|
166
|
+
*/
|
|
167
|
+
entry: RsbuildEntry;
|
|
168
|
+
/**
|
|
169
|
+
* The path information for all HTML assets.
|
|
170
|
+
* This value is an object, the key is the entry name and the value is the relative
|
|
171
|
+
* path of the HTML file in the dist directory.
|
|
172
|
+
*/
|
|
173
|
+
htmlPaths: Record<string, string>;
|
|
174
|
+
/**
|
|
175
|
+
* The absolute path of the output directory, corresponding to the `output.distPath.root`
|
|
176
|
+
* config of Rsbuild.
|
|
177
|
+
*/
|
|
178
|
+
distPath: string;
|
|
179
|
+
/**
|
|
180
|
+
* The browserslist configuration of the current environment.
|
|
181
|
+
*/
|
|
182
|
+
browserslist: string[];
|
|
183
|
+
/**
|
|
184
|
+
* The absolute path of the tsconfig.json file, or `undefined` if the tsconfig.json file
|
|
185
|
+
* does not exist in current project.
|
|
186
|
+
*/
|
|
187
|
+
tsconfigPath?: string;
|
|
188
|
+
/**
|
|
189
|
+
* The normalized Rsbuild config for the current environment.
|
|
190
|
+
*/
|
|
191
|
+
config: NormalizedEnvironmentConfig;
|
|
192
|
+
/**
|
|
193
|
+
* Manifest data. Only available when:
|
|
194
|
+
* - The `output.manifest` config is enabled
|
|
195
|
+
* - The build has completed, accessible in hooks like `onAfterBuild`,
|
|
196
|
+
* `onAfterDevCompile` and `onAfterEnvironmentCompile` or via the environment API
|
|
197
|
+
*/
|
|
198
|
+
manifest?: Record<string, unknown> | ManifestData;
|
|
199
|
+
/**
|
|
200
|
+
* WebSocket authentication token, used to authenticate WebSocket connections and
|
|
201
|
+
* prevent unauthorized access. Only available in the development mode, and is
|
|
202
|
+
* an empty string in the production mode.
|
|
203
|
+
*/
|
|
204
|
+
webSocketToken: string;
|
|
205
|
+
};
|
|
206
|
+
export type ModifyChainUtils = {
|
|
207
|
+
/**
|
|
208
|
+
* The value of `process.env.NODE_ENV`
|
|
209
|
+
*/
|
|
210
|
+
env: string;
|
|
211
|
+
/**
|
|
212
|
+
* A boolean value indicating whether this is a development build.
|
|
213
|
+
* Set to `true` when the `mode` is `development`.
|
|
214
|
+
*/
|
|
215
|
+
isDev: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* A boolean value indicating whether this is a production build.
|
|
218
|
+
* Set to `true` when the `mode` is `production`.
|
|
219
|
+
*/
|
|
220
|
+
isProd: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* The current build target.
|
|
223
|
+
*/
|
|
224
|
+
target: RsbuildTarget;
|
|
225
|
+
/**
|
|
226
|
+
* A boolean value indicating whether the build target is `node`.
|
|
227
|
+
* Equivalent to `target === 'node'`.
|
|
228
|
+
*/
|
|
229
|
+
isServer: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* A boolean value indicating whether the build target is `web-worker`.
|
|
232
|
+
* Equivalent to `target === 'web-worker'`.
|
|
233
|
+
*/
|
|
234
|
+
isWebWorker: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Predefined chain IDs.
|
|
237
|
+
*/
|
|
238
|
+
CHAIN_ID: ChainIdentifier;
|
|
239
|
+
/**
|
|
240
|
+
* The environment context for current build.
|
|
241
|
+
*/
|
|
242
|
+
environment: EnvironmentContext;
|
|
243
|
+
/**
|
|
244
|
+
* Context information for all environments.
|
|
245
|
+
*/
|
|
246
|
+
environments: Record<string, EnvironmentContext>;
|
|
247
|
+
/**
|
|
248
|
+
* The Rspack instance, same as `import { rspack } from '@rsbuild/core'`.
|
|
249
|
+
*/
|
|
250
|
+
rspack: typeof rspack;
|
|
251
|
+
/**
|
|
252
|
+
* The default export of `html-rspack-plugin`.
|
|
253
|
+
*/
|
|
254
|
+
HtmlPlugin: typeof HtmlRspackPlugin;
|
|
255
|
+
};
|
|
256
|
+
interface PluginInstance {
|
|
257
|
+
apply: (compiler: any) => void;
|
|
258
|
+
[k: string]: any;
|
|
259
|
+
}
|
|
260
|
+
export type ModifyBundlerChainUtils = ModifyChainUtils & {
|
|
261
|
+
bundler: {
|
|
262
|
+
BannerPlugin: PluginInstance;
|
|
263
|
+
DefinePlugin: PluginInstance;
|
|
264
|
+
IgnorePlugin: PluginInstance;
|
|
265
|
+
ProvidePlugin: PluginInstance;
|
|
266
|
+
SourceMapDevToolPlugin: PluginInstance;
|
|
267
|
+
HotModuleReplacementPlugin: PluginInstance;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
export type ModifyBundlerChainFn = (chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>;
|
|
271
|
+
export type CreateAsyncHook<Callback extends (...args: any[]) => any> = {
|
|
272
|
+
tap: (cb: Callback) => void;
|
|
273
|
+
call: (...args: Parameters<Callback>) => Promise<Parameters<Callback>>;
|
|
274
|
+
};
|
|
275
|
+
export {};
|