@ohos-ports/rsbuild-core 1.1.14-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 +28 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/chokidar/index.d.ts +345 -0
- package/compiled/chokidar/index.js +1778 -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/connect-history-api-fallback/index.d.ts +1 -0
- package/compiled/connect-history-api-fallback/index.js +149 -0
- package/compiled/connect-history-api-fallback/license +21 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/compiled/cors/index.d.ts +1 -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 +8008 -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 +289 -0
- package/compiled/html-rspack-plugin/index.js +1583 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +162 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +318 -0
- package/compiled/http-proxy-middleware/index.js +5280 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/jiti/index.d.ts +1 -0
- package/compiled/jiti/index.js +416 -0
- package/compiled/jiti/license +21 -0
- package/compiled/jiti/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +694 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +452 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/on-finished/index.d.ts +13 -0
- package/compiled/on-finished/index.js +197 -0
- package/compiled/on-finished/license +23 -0
- package/compiled/on-finished/package.json +1 -0
- package/compiled/open/index.d.ts +153 -0
- package/compiled/open/index.js +409 -0
- package/compiled/open/package.json +1 -0
- package/compiled/open/xdg-open +1066 -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.d.ts +1 -0
- package/compiled/postcss/index.js +5997 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-load-config/index.d.ts +1 -0
- package/compiled/postcss-load-config/index.js +739 -0
- package/compiled/postcss-load-config/license +20 -0
- package/compiled/postcss-load-config/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +741 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rsbuild-dev-middleware/index.d.ts +1 -0
- package/compiled/rsbuild-dev-middleware/index.js +6158 -0
- package/compiled/rsbuild-dev-middleware/license +20 -0
- package/compiled/rsbuild-dev-middleware/package.json +1 -0
- package/compiled/rslog/index.d.ts +66 -0
- package/compiled/rslog/index.js +334 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/index.d.ts +611 -0
- package/compiled/rspack-chain/index.js +1740 -0
- package/compiled/rspack-chain/license +373 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +44 -0
- package/compiled/rspack-manifest-plugin/index.js +394 -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 +709 -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 +25 -0
- package/compiled/tinyglobby/index.js +2749 -0
- package/compiled/tinyglobby/index1.js +17 -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 +13480 -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 +401 -0
- package/compiled/ws/index.js +3153 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/client/hmr.js +143 -0
- package/dist/client/overlay.js +210 -0
- package/dist/ignoreCssLoader.mjs +4 -0
- package/dist/index.cjs +7251 -0
- package/dist/index.js +7118 -0
- package/dist/transformLoader.mjs +22 -0
- package/dist/transformRawLoader.mjs +22 -0
- package/dist-types/cli/commands.d.ts +23 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/cli/prepare.d.ts +1 -0
- package/dist-types/client/hmr.d.ts +1 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/config.d.ts +90 -0
- package/dist-types/configChain.d.ts +139 -0
- package/dist-types/constants.d.ts +37 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +2 -0
- package/dist-types/helpers/format.d.ts +5 -0
- package/dist-types/helpers/fs.d.ts +13 -0
- package/dist-types/helpers/index.d.ts +47 -0
- package/dist-types/helpers/path.d.ts +11 -0
- package/dist-types/helpers/stats.d.ts +9 -0
- package/dist-types/hooks.d.ts +48 -0
- package/dist-types/index.d.ts +26 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/internal.d.ts +6 -0
- package/dist-types/loadEnv.d.ts +50 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +2 -0
- package/dist-types/loader/transformLoader.d.ts +7 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +4 -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 +9 -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 +3 -0
- package/dist-types/plugins/css.d.ts +3 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +4 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +2 -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/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +7 -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 +3 -0
- package/dist-types/provider/createCompiler.d.ts +27 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +10 -0
- package/dist-types/provider/inspectConfig.d.ts +6 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/rspack/RsbuildHtmlPlugin.d.ts +37 -0
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/determineAsValue.d.ts +22 -0
- package/dist-types/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/extractChunks.d.ts +28 -0
- package/dist-types/rspack/preload/helpers/index.d.ts +4 -0
- package/dist-types/rspack/preload/helpers/type.d.ts +13 -0
- package/dist-types/server/ansiHTML.d.ts +12 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/compilerDevMiddleware.d.ts +31 -0
- package/dist-types/server/devMiddleware.d.ts +27 -0
- package/dist-types/server/devServer.d.ts +60 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/getDevMiddlewares.d.ts +25 -0
- package/dist-types/server/gzipMiddleware.d.ts +4 -0
- package/dist-types/server/helper.d.ts +71 -0
- package/dist-types/server/httpServer.d.ts +8 -0
- package/dist-types/server/middlewares.d.ts +34 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/prodServer.d.ts +25 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/restart.d.ts +14 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +25 -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 +8 -0
- package/dist-types/server/runner/type.d.ts +36 -0
- package/dist-types/server/socketServer.d.ts +26 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1309 -0
- package/dist-types/types/context.d.ts +52 -0
- package/dist-types/types/hooks.d.ts +146 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +329 -0
- package/dist-types/types/rsbuild.d.ts +156 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +176 -0
- package/dist-types/types/utils.d.ts +12 -0
- package/package.json +61 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +221 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is used to get/set the global instance for html-plugin and css-extract plugin.
|
|
3
|
+
*/
|
|
4
|
+
import rspack from '@rspack/core';
|
|
5
|
+
import type { HtmlRspackPlugin } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* This method is used to override the Rsbuild default html-plugin (html-rspack-plugin).
|
|
8
|
+
*/
|
|
9
|
+
export declare const setHTMLPlugin: (plugin: typeof HtmlRspackPlugin) => void;
|
|
10
|
+
export declare const getHTMLPlugin: () => typeof HtmlRspackPlugin;
|
|
11
|
+
export declare const setCssExtractPlugin: (plugin: unknown) => void;
|
|
12
|
+
export declare const getCssExtractPlugin: () => typeof rspack.CssExtractRspackPlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginManager, PluginMeta, RsbuildPluginAPI } from './types';
|
|
2
|
+
export declare const RSBUILD_ALL_ENVIRONMENT_SYMBOL = "RSBUILD_ALL_ENVIRONMENT_SYMBOL";
|
|
3
|
+
export declare const isPluginMatchEnvironment: (pluginEnvironment: string, currentEnvironment: string) => boolean;
|
|
4
|
+
export declare function createPluginManager(): PluginManager;
|
|
5
|
+
export declare const pluginDagSort: (plugins: PluginMeta[]) => PluginMeta[];
|
|
6
|
+
export declare function initPlugins({ getPluginAPI, pluginManager, }: {
|
|
7
|
+
getPluginAPI: (environment?: string) => RsbuildPluginAPI;
|
|
8
|
+
pluginManager: PluginManager;
|
|
9
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ModifyHTMLTagsFn, NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
|
|
2
|
+
export declare function getTemplate(entryName: string, config: NormalizedEnvironmentConfig, rootPath: string): Promise<{
|
|
3
|
+
templatePath: string;
|
|
4
|
+
templateContent?: string;
|
|
5
|
+
} | {
|
|
6
|
+
templatePath: undefined;
|
|
7
|
+
templateContent: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const pluginHtml: (modifyTagsFn?: (environment: string) => ModifyHTMLTagsFn) => RsbuildPlugin;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LightningCssMinimizerRspackPluginOptions, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
|
|
2
|
+
import type { NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
|
|
3
|
+
export declare const getSwcMinimizerOptions: (config: NormalizedEnvironmentConfig, jsOptions?: SwcJsMinimizerRspackPluginOptions) => SwcJsMinimizerRspackPluginOptions;
|
|
4
|
+
export declare const parseMinifyOptions: (config: NormalizedEnvironmentConfig, isProd: boolean) => {
|
|
5
|
+
minifyJs: boolean;
|
|
6
|
+
minifyCss: boolean;
|
|
7
|
+
jsOptions?: SwcJsMinimizerRspackPluginOptions;
|
|
8
|
+
cssOptions?: LightningCssMinimizerRspackPluginOptions;
|
|
9
|
+
};
|
|
10
|
+
export declare const pluginMinimize: () => RsbuildPlugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SwcLoaderOptions } from '@rspack/core';
|
|
2
|
+
import type { NormalizedEnvironmentConfig, RsbuildPlugin } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Provide some SWC configs of Rspack
|
|
5
|
+
*/
|
|
6
|
+
export declare const pluginSwc: () => RsbuildPlugin;
|
|
7
|
+
export declare function applySwcDecoratorConfig(swcConfig: SwcLoaderOptions, config: NormalizedEnvironmentConfig): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DevConfig, Rspack } from '../types';
|
|
2
|
+
import { type InitConfigsOptions } from './initConfigs';
|
|
3
|
+
export declare function createCompiler(options: InitConfigsOptions): Promise<{
|
|
4
|
+
compiler: Rspack.Compiler | Rspack.MultiCompiler;
|
|
5
|
+
rspackConfigs: Rspack.Configuration[];
|
|
6
|
+
}>;
|
|
7
|
+
export type MiddlewareCallbacks = {
|
|
8
|
+
onInvalid: () => void;
|
|
9
|
+
onDone: (stats: any) => void;
|
|
10
|
+
};
|
|
11
|
+
export type DevMiddlewareOptions = {
|
|
12
|
+
/** To ensure HMR works, the devMiddleware need inject the HMR client path into page when HMR enable. */
|
|
13
|
+
clientPaths?: string[];
|
|
14
|
+
clientConfig: DevConfig['client'];
|
|
15
|
+
publicPath?: string;
|
|
16
|
+
/** When liveReload is disabled, the page does not reload. */
|
|
17
|
+
liveReload?: boolean;
|
|
18
|
+
etag?: 'weak' | 'strong';
|
|
19
|
+
/** The options need by compiler middleware (like webpackMiddleware) */
|
|
20
|
+
headers?: Record<string, string | string[]>;
|
|
21
|
+
writeToDisk?: boolean | ((filename: string, compilationName?: string) => boolean);
|
|
22
|
+
stats?: boolean;
|
|
23
|
+
/** should trigger when compiler hook called */
|
|
24
|
+
callbacks: MiddlewareCallbacks;
|
|
25
|
+
/** whether use Server Side Render */
|
|
26
|
+
serverSideRender?: boolean;
|
|
27
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for `@rsbuild/webpack`.
|
|
3
|
+
*/
|
|
4
|
+
export { setCssExtractPlugin, setHTMLPlugin } from '../pluginHelper';
|
|
5
|
+
export { initRsbuildConfig } from './initConfigs';
|
|
6
|
+
export { stringifyConfig, getRsbuildInspectConfig, outputInspectConfigFiles, } from '../config';
|
|
7
|
+
export { getHTMLPlugin } from '../pluginHelper';
|
|
8
|
+
export { formatStats, getStatsOptions, prettyTime } from '../helpers';
|
|
9
|
+
export { registerBuildHook, registerDevHook } from '../hooks';
|
|
10
|
+
export { getChainUtils, getConfigUtils } from './rspackConfig';
|
|
11
|
+
export { chainToConfig, modifyBundlerChain } from '../configChain';
|
|
12
|
+
export { createDevServer } from '../server/devServer';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InternalContext, NormalizedConfig, PluginManager, ResolvedCreateRsbuildOptions, Rspack } from '../types';
|
|
2
|
+
export type InitConfigsOptions = {
|
|
3
|
+
context: InternalContext;
|
|
4
|
+
pluginManager: PluginManager;
|
|
5
|
+
rsbuildOptions: ResolvedCreateRsbuildOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare function initRsbuildConfig({ context, pluginManager, }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
|
|
8
|
+
export declare function initConfigs({ context, pluginManager, rsbuildOptions, }: InitConfigsOptions): Promise<{
|
|
9
|
+
rspackConfigs: Rspack.Configuration[];
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InspectConfigOptions, InspectConfigResult, Rspack } from '../types';
|
|
2
|
+
import { type InitConfigsOptions } from './initConfigs';
|
|
3
|
+
export declare function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
|
|
4
|
+
inspectOptions?: InspectConfigOptions;
|
|
5
|
+
bundlerConfigs?: Rspack.Configuration[];
|
|
6
|
+
}): Promise<InspectConfigResult<'rspack'>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EnvironmentContext, InternalContext, ModifyChainUtils, ModifyRspackConfigUtils, RsbuildTarget, Rspack } from '../types';
|
|
2
|
+
export declare function getConfigUtils(config: Rspack.Configuration, chainUtils: ModifyChainUtils): Promise<ModifyRspackConfigUtils>;
|
|
3
|
+
export declare function getChainUtils(target: RsbuildTarget, environment: EnvironmentContext): ModifyChainUtils;
|
|
4
|
+
export declare function generateRspackConfig({ target, context, environment, }: {
|
|
5
|
+
environment: string;
|
|
6
|
+
target: RsbuildTarget;
|
|
7
|
+
context: InternalContext;
|
|
8
|
+
}): Promise<Rspack.Configuration>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Compiler } from '@rspack/core';
|
|
2
|
+
import type { HtmlRspackPlugin } from '../types';
|
|
3
|
+
import type { EnvironmentContext, HtmlTag, HtmlTagDescriptor, ModifyHTMLTagsFn } from '../types';
|
|
4
|
+
type HtmlTagObject = HtmlRspackPlugin.HtmlTagObject;
|
|
5
|
+
export type TagConfig = {
|
|
6
|
+
tags?: HtmlTagDescriptor[];
|
|
7
|
+
hash?: HtmlTag['hash'];
|
|
8
|
+
append?: HtmlTag['append'];
|
|
9
|
+
publicPath?: HtmlTag['publicPath'];
|
|
10
|
+
};
|
|
11
|
+
export declare const FILE_ATTRS: {
|
|
12
|
+
link: string;
|
|
13
|
+
script: string;
|
|
14
|
+
};
|
|
15
|
+
export type HtmlInfo = {
|
|
16
|
+
favicon?: string;
|
|
17
|
+
tagConfig?: TagConfig;
|
|
18
|
+
templateContent?: string;
|
|
19
|
+
};
|
|
20
|
+
export type RsbuildHtmlPluginOptions = Record<string, HtmlInfo>;
|
|
21
|
+
export type AlterAssetTagGroupsData = {
|
|
22
|
+
headTags: HtmlTagObject[];
|
|
23
|
+
bodyTags: HtmlTagObject[];
|
|
24
|
+
outputName: string;
|
|
25
|
+
publicPath: string;
|
|
26
|
+
plugin: HtmlRspackPlugin;
|
|
27
|
+
};
|
|
28
|
+
export declare const hasTitle: (html?: string) => boolean;
|
|
29
|
+
export declare class RsbuildHtmlPlugin {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly getEnvironment: () => EnvironmentContext;
|
|
32
|
+
readonly options: RsbuildHtmlPluginOptions;
|
|
33
|
+
readonly modifyTagsFn?: ModifyHTMLTagsFn;
|
|
34
|
+
constructor(options: RsbuildHtmlPluginOptions, getEnvironment: () => EnvironmentContext, modifyTagsFn?: ModifyHTMLTagsFn);
|
|
35
|
+
apply(compiler: Compiler): void;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This method is modified based on source found in
|
|
3
|
+
* https://github.com/vuejs/preload-webpack-plugin/blob/master/src/index.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2018 Google Inc.
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
19
|
+
import type { HtmlRspackPlugin, PreloadOrPreFetchOption } from '../../types';
|
|
20
|
+
type LinkType = 'preload' | 'prefetch';
|
|
21
|
+
export declare class HtmlPreloadOrPrefetchPlugin implements RspackPluginInstance {
|
|
22
|
+
readonly options: PreloadOrPreFetchOption;
|
|
23
|
+
resourceHints: HtmlRspackPlugin.HtmlTagObject[];
|
|
24
|
+
type: LinkType;
|
|
25
|
+
HTMLCount: number;
|
|
26
|
+
constructor(options: true | PreloadOrPreFetchOption, type: LinkType, HTMLCount: number);
|
|
27
|
+
apply(compiler: Compiler): void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This method is modified based on source found in
|
|
3
|
+
* https://github.com/vuejs/preload-webpack-plugin/blob/master/src/lib/determine-as-value.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2018 Google Inc.
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { As } from './type';
|
|
19
|
+
export declare function determineAsValue({ href, file, }: {
|
|
20
|
+
href: string;
|
|
21
|
+
file: string;
|
|
22
|
+
}): As;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This method is modified based on source found in
|
|
3
|
+
* https://github.com/vuejs/preload-webpack-plugin/blob/master/src/lib/does-chunk-belong-to-html.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2018 Google Inc.
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { Chunk, Compilation } from '@rspack/core';
|
|
19
|
+
import type { PreloadOrPreFetchOption } from '../../../types';
|
|
20
|
+
import type { BeforeAssetTagGenerationHtmlPluginData } from './type';
|
|
21
|
+
interface DoesChunkBelongToHtmlOptions {
|
|
22
|
+
chunk: Chunk;
|
|
23
|
+
compilation?: Compilation;
|
|
24
|
+
htmlPluginData: BeforeAssetTagGenerationHtmlPluginData;
|
|
25
|
+
pluginOptions?: PreloadOrPreFetchOption;
|
|
26
|
+
}
|
|
27
|
+
export declare function recursiveChunkEntryNames(chunk: Chunk): string[];
|
|
28
|
+
export declare function doesChunkBelongToHtml({ chunk, htmlPluginData, }: DoesChunkBelongToHtmlOptions): boolean;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This method is modified based on source found in
|
|
3
|
+
* https://github.com/vuejs/preload-webpack-plugin/blob/master/src/lib/extract-chunks.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2018 Google Inc.
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { Chunk, Compilation } from '@rspack/core';
|
|
19
|
+
import type { PreloadIncludeType } from '../../../types';
|
|
20
|
+
interface ExtractChunks {
|
|
21
|
+
compilation: Compilation;
|
|
22
|
+
includeType?: PreloadIncludeType;
|
|
23
|
+
}
|
|
24
|
+
export declare function extractChunks({ compilation, includeType }: ExtractChunks): Chunk[] | Array<{
|
|
25
|
+
files: string[];
|
|
26
|
+
auxiliaryFiles?: string[];
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HtmlRspackPlugin } from '../../../types';
|
|
2
|
+
export type BeforeAssetTagGenerationHtmlPluginData = {
|
|
3
|
+
assets: {
|
|
4
|
+
publicPath: string;
|
|
5
|
+
js: Array<string>;
|
|
6
|
+
css: Array<string>;
|
|
7
|
+
favicon?: string;
|
|
8
|
+
manifest?: string;
|
|
9
|
+
};
|
|
10
|
+
outputName: string;
|
|
11
|
+
plugin: HtmlRspackPlugin;
|
|
12
|
+
};
|
|
13
|
+
export type As = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module is modified based on `ansi-html-community`
|
|
3
|
+
* https://github.com/mahdyar/ansi-html-community
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* https://github.com/mahdyar/ansi-html-community/blob/master/LICENSE
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Converts text with ANSI color codes to HTML markup.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ansiHTML(text: string): string;
|
|
12
|
+
export default ansiHTML;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CliShortcut, NormalizedDevConfig } from '../types/config';
|
|
2
|
+
export declare const isCliShortcutsEnabled: (devConfig: NormalizedDevConfig) => boolean;
|
|
3
|
+
export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, }: {
|
|
4
|
+
help?: boolean;
|
|
5
|
+
openPage: () => Promise<void>;
|
|
6
|
+
closeServer: () => Promise<void>;
|
|
7
|
+
printUrls: () => void;
|
|
8
|
+
restartServer?: () => Promise<void>;
|
|
9
|
+
customShortcuts?: (shortcuts: CliShortcut[]) => CliShortcut[];
|
|
10
|
+
}): () => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'node:http';
|
|
2
|
+
import type { Socket } from 'node:net';
|
|
3
|
+
import type { EnvironmentContext, DevConfig as OriginDevConfig, Rspack, ServerConfig } from '../types';
|
|
4
|
+
import { type DevMiddlewareAPI } from './devMiddleware';
|
|
5
|
+
type Options = {
|
|
6
|
+
publicPaths: string[];
|
|
7
|
+
environments: Record<string, EnvironmentContext>;
|
|
8
|
+
dev: OriginDevConfig;
|
|
9
|
+
server: ServerConfig;
|
|
10
|
+
compiler: Rspack.Compiler | Rspack.MultiCompiler;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Setup compiler-related logic:
|
|
14
|
+
* 1. setup rsbuild-dev-middleware
|
|
15
|
+
* 2. establish webSocket connect
|
|
16
|
+
*/
|
|
17
|
+
export declare class CompilerDevMiddleware {
|
|
18
|
+
middleware: DevMiddlewareAPI;
|
|
19
|
+
private devConfig;
|
|
20
|
+
private serverConfig;
|
|
21
|
+
private compiler;
|
|
22
|
+
private publicPaths;
|
|
23
|
+
private socketServer;
|
|
24
|
+
constructor({ dev, server, compiler, publicPaths, environments }: Options);
|
|
25
|
+
init(): Promise<void>;
|
|
26
|
+
upgrade(req: IncomingMessage, sock: Socket, head: any): void;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
sockWrite(type: string, data?: Record<string, any> | string | boolean): void;
|
|
29
|
+
private setupDevMiddleware;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
3
|
+
import type { DevMiddlewareOptions } from '../provider/createCompiler';
|
|
4
|
+
import type { NextFunction } from '../types';
|
|
5
|
+
type ServerCallbacks = {
|
|
6
|
+
onInvalid: (compilationId?: string, fileName?: string | null) => void;
|
|
7
|
+
onDone: (stats: any) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const isClientCompiler: (compiler: {
|
|
10
|
+
options: {
|
|
11
|
+
target?: Compiler["options"]["target"];
|
|
12
|
+
};
|
|
13
|
+
}) => boolean;
|
|
14
|
+
export declare const setupServerHooks: (compiler: Compiler, hookCallbacks: ServerCallbacks) => void;
|
|
15
|
+
export type Middleware = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => Promise<void>;
|
|
16
|
+
export type DevMiddlewareAPI = Middleware & {
|
|
17
|
+
close: (callback: (err: Error | null | undefined) => void) => any;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The rsbuild/server do nothing about compiler, the devMiddleware need do such things to ensure dev works well:
|
|
21
|
+
* - Call compiler.watch (normally did by rsbuild-dev-middleware).
|
|
22
|
+
* - Inject the HMR client path into page (the HMR client rsbuild/server already provide).
|
|
23
|
+
* - Notify server when compiler hooks are triggered.
|
|
24
|
+
*/
|
|
25
|
+
export type DevMiddleware = (options: DevMiddlewareOptions) => DevMiddlewareAPI;
|
|
26
|
+
export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => Promise<NonNullable<DevMiddleware>>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Server } from 'node:http';
|
|
2
|
+
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
+
import type Connect from '../../compiled/connect/index.js';
|
|
4
|
+
import type { CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
|
|
5
|
+
type HTTPServer = Server | Http2SecureServer;
|
|
6
|
+
export type RsbuildDevServer = {
|
|
7
|
+
/**
|
|
8
|
+
* Listen the Rsbuild server.
|
|
9
|
+
* Do not call this method if you are using a custom server.
|
|
10
|
+
*/
|
|
11
|
+
listen: () => Promise<{
|
|
12
|
+
port: number;
|
|
13
|
+
urls: string[];
|
|
14
|
+
server: {
|
|
15
|
+
close: () => Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Environment API of Rsbuild server.
|
|
20
|
+
*/
|
|
21
|
+
environments: EnvironmentAPI;
|
|
22
|
+
/**
|
|
23
|
+
* The resolved port.
|
|
24
|
+
* By default, Rsbuild server listens on port `3000` and automatically increments the port number if the port is occupied.
|
|
25
|
+
*/
|
|
26
|
+
port: number;
|
|
27
|
+
/**
|
|
28
|
+
* The `connect` app instance.
|
|
29
|
+
* Can be used to attach custom middlewares to the dev server.
|
|
30
|
+
*/
|
|
31
|
+
middlewares: Connect.Server;
|
|
32
|
+
/**
|
|
33
|
+
* Notify that the Rsbuild server has been started.
|
|
34
|
+
* Rsbuild will trigger `onAfterStartDevServer` hook in this stage.
|
|
35
|
+
*/
|
|
36
|
+
afterListen: () => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Activate socket connection.
|
|
39
|
+
* This ensures that HMR works properly.
|
|
40
|
+
*/
|
|
41
|
+
connectWebSocket: (options: {
|
|
42
|
+
server: HTTPServer;
|
|
43
|
+
}) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Close the Rsbuild server.
|
|
46
|
+
*/
|
|
47
|
+
close: () => Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Print the server URLs.
|
|
50
|
+
*/
|
|
51
|
+
printUrls: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Open URL in the browser after starting the server.
|
|
54
|
+
*/
|
|
55
|
+
open: () => Promise<void>;
|
|
56
|
+
};
|
|
57
|
+
export declare function createDevServer<Options extends {
|
|
58
|
+
context: InternalContext;
|
|
59
|
+
}>(options: Options, createCompiler: CreateCompiler, config: NormalizedConfig, { compiler: customCompiler, getPortSilently, runCompile, }?: CreateDevServerOptions): Promise<RsbuildDevServer>;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EnvironmentContext, Rspack } from '../types';
|
|
2
|
+
export type ServerUtils = {
|
|
3
|
+
readFileSync: (fileName: string) => string;
|
|
4
|
+
environment: EnvironmentContext;
|
|
5
|
+
};
|
|
6
|
+
export declare const loadBundle: <T>(stats: Rspack.Stats, entryName: string, utils: ServerUtils) => Promise<T>;
|
|
7
|
+
export declare const getTransformedHtml: (entryName: string, utils: ServerUtils) => Promise<string>;
|
|
8
|
+
export declare const createCacheableFunction: <T>(getter: (stats: Rspack.Stats, entryName: string, utils: ServerUtils) => Promise<T>) => (stats: Rspack.Stats, entryName: string, utils: ServerUtils) => Promise<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DevConfig, EnvironmentAPI, RequestHandler, Rspack, ServerConfig, SetupMiddlewaresServer } from '../types';
|
|
2
|
+
import type { UpgradeEvent } from './helper';
|
|
3
|
+
export type CompileMiddlewareAPI = {
|
|
4
|
+
middleware: RequestHandler;
|
|
5
|
+
sockWrite: SetupMiddlewaresServer['sockWrite'];
|
|
6
|
+
onUpgrade: UpgradeEvent;
|
|
7
|
+
close: () => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export type RsbuildDevMiddlewareOptions = {
|
|
10
|
+
pwd: string;
|
|
11
|
+
dev: DevConfig;
|
|
12
|
+
server: ServerConfig;
|
|
13
|
+
environments: EnvironmentAPI;
|
|
14
|
+
compileMiddlewareAPI?: CompileMiddlewareAPI;
|
|
15
|
+
outputFileSystem: Rspack.OutputFileSystem;
|
|
16
|
+
output: {
|
|
17
|
+
distPath: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type Middlewares = Array<RequestHandler | [string, RequestHandler]>;
|
|
21
|
+
export declare const getMiddlewares: (options: RsbuildDevMiddlewareOptions) => Promise<{
|
|
22
|
+
close: () => Promise<void>;
|
|
23
|
+
onUpgrade: UpgradeEvent;
|
|
24
|
+
middlewares: Middlewares;
|
|
25
|
+
}>;
|