@rsbuild/core 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/cli/commands.d.ts +12 -15
  2. package/dist/cli/commands.js +2 -2
  3. package/dist/cli/config.d.ts +12 -12
  4. package/dist/cli/prepare.d.ts +1 -1
  5. package/dist/cli/prepare.js +1 -1
  6. package/dist/client/hmr/createSocketUrl.d.ts +6 -11
  7. package/dist/client/hmr/index.d.ts +1 -1
  8. package/dist/client/hmr.js +236 -33
  9. package/dist/createRsbuild.d.ts +1 -1
  10. package/dist/index.d.ts +3 -2
  11. package/dist/index.js +3 -0
  12. package/dist/loadEnv.d.ts +7 -10
  13. package/dist/loadEnv.js +15 -14
  14. package/dist/plugins/asset.d.ts +1 -1
  15. package/dist/plugins/basic.d.ts +1 -1
  16. package/dist/plugins/bundleAnalyzer.d.ts +1 -1
  17. package/dist/plugins/cache.d.ts +1 -1
  18. package/dist/plugins/cleanOutput.d.ts +1 -1
  19. package/dist/plugins/define.d.ts +1 -1
  20. package/dist/plugins/entry.d.ts +1 -1
  21. package/dist/plugins/entry.js +7 -2
  22. package/dist/plugins/externals.d.ts +1 -1
  23. package/dist/plugins/fileSize.d.ts +1 -1
  24. package/dist/plugins/html.d.ts +5 -5
  25. package/dist/plugins/index.d.ts +1 -1
  26. package/dist/plugins/inlineChunk.d.ts +1 -1
  27. package/dist/plugins/moment.d.ts +1 -1
  28. package/dist/plugins/networkPerformance.d.ts +1 -1
  29. package/dist/plugins/nodeAddons.d.ts +1 -1
  30. package/dist/plugins/performance.d.ts +1 -1
  31. package/dist/plugins/preloadOrPrefetch.d.ts +1 -1
  32. package/dist/plugins/splitChunks.d.ts +1 -1
  33. package/dist/plugins/splitChunks.js +1 -3
  34. package/dist/plugins/startUrl.d.ts +1 -1
  35. package/dist/plugins/target.d.ts +1 -1
  36. package/dist/plugins/toml.d.ts +1 -1
  37. package/dist/plugins/wasm.d.ts +1 -1
  38. package/dist/plugins/yaml.d.ts +1 -1
  39. package/dist/provider/config.d.ts +1 -1
  40. package/dist/provider/core/build.d.ts +10 -14
  41. package/dist/provider/core/createCompiler.d.ts +4 -7
  42. package/dist/provider/core/createContext.d.ts +1 -1
  43. package/dist/provider/core/createContext.js +1 -1
  44. package/dist/provider/core/devMiddleware.d.ts +1 -1
  45. package/dist/provider/core/initConfigs.d.ts +7 -14
  46. package/dist/provider/core/initHooks.d.ts +18 -18
  47. package/dist/provider/core/initPlugins.d.ts +4 -7
  48. package/dist/provider/core/inspectConfig.d.ts +4 -10
  49. package/dist/provider/core/rspackConfig.d.ts +4 -7
  50. package/dist/provider/core/rspackConfig.js +2 -2
  51. package/dist/provider/css-modules-typescript-pre-loader/index.d.ts +3 -3
  52. package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.d.ts +5 -5
  53. package/dist/provider/htmlPluginUtil.d.ts +9 -0
  54. package/dist/provider/htmlPluginUtil.js +47 -0
  55. package/dist/provider/index.d.ts +2 -1
  56. package/dist/provider/index.js +5 -0
  57. package/dist/provider/plugins/css.d.ts +7 -19
  58. package/dist/provider/plugins/hmr.d.ts +1 -1
  59. package/dist/provider/plugins/less.d.ts +1 -1
  60. package/dist/provider/plugins/minimize.d.ts +1 -1
  61. package/dist/provider/plugins/output.d.ts +1 -1
  62. package/dist/provider/plugins/progress.d.ts +1 -1
  63. package/dist/provider/plugins/resolve.d.ts +1 -1
  64. package/dist/provider/plugins/rspackProfile.d.ts +1 -1
  65. package/dist/provider/plugins/sass.d.ts +1 -1
  66. package/dist/provider/plugins/server.d.ts +1 -1
  67. package/dist/provider/plugins/swc.d.ts +1 -1
  68. package/dist/provider/plugins/swc.js +29 -37
  69. package/dist/provider/plugins/transition.d.ts +1 -1
  70. package/dist/provider/provider.d.ts +1 -1
  71. package/dist/provider/shared.d.ts +1 -1
  72. package/dist/rspack/HtmlAppIconPlugin.d.ts +8 -8
  73. package/dist/rspack/HtmlAppIconPlugin.js +15 -18
  74. package/dist/rspack/HtmlBasicPlugin.d.ts +8 -8
  75. package/dist/rspack/HtmlBasicPlugin.js +12 -25
  76. package/dist/rspack/HtmlCrossOriginPlugin.d.ts +6 -6
  77. package/dist/rspack/HtmlCrossOriginPlugin.js +13 -26
  78. package/dist/rspack/HtmlNetworkPerformancePlugin.d.ts +5 -5
  79. package/dist/rspack/HtmlNetworkPerformancePlugin.js +2 -12
  80. package/dist/rspack/HtmlNoncePlugin.d.ts +6 -6
  81. package/dist/rspack/HtmlNoncePlugin.js +8 -21
  82. package/dist/rspack/HtmlTagsPlugin.d.ts +13 -13
  83. package/dist/rspack/HtmlTagsPlugin.js +2 -12
  84. package/dist/rspack/InlineChunkHtmlPlugin.d.ts +39 -49
  85. package/dist/rspack/InlineChunkHtmlPlugin.js +2 -12
  86. package/dist/rspack/RemoveCssSourcemapPlugin.d.ts +4 -4
  87. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +8 -8
  88. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +3 -13
  89. package/dist/rspack/preload/helpers/determineAsValue.d.ts +4 -7
  90. package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +6 -9
  91. package/dist/rspack/preload/helpers/extractChunks.d.ts +4 -7
  92. package/dist/rspack/preload/helpers/index.d.ts +1 -1
  93. package/dist/rspack/preload/helpers/type.d.ts +10 -10
  94. package/dist/server/compilerDevMiddleware.d.ts +15 -19
  95. package/dist/server/devServer.d.ts +7 -15
  96. package/dist/server/devServer.js +3 -5
  97. package/dist/server/getDevMiddlewares.d.ts +10 -10
  98. package/dist/server/httpServer.d.ts +3 -3
  99. package/dist/server/index.d.ts +1 -1
  100. package/dist/server/middlewares.d.ts +4 -4
  101. package/dist/server/prodServer.d.ts +16 -19
  102. package/dist/server/proxy.d.ts +3 -3
  103. package/dist/server/restart.d.ts +4 -6
  104. package/dist/server/restart.js +5 -4
  105. package/dist/server/socketServer.d.ts +17 -17
  106. package/dist/types.d.ts +11 -11
  107. package/package.json +4 -4
@@ -2,4 +2,4 @@ import type { RsbuildPlugin } from '../types';
2
2
  /**
3
3
  * Apply some configs of Rsbuild performance
4
4
  */
5
- export declare const pluginPerformance: () => RsbuildPlugin;
5
+ export declare const pluginPerformance: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginPreloadOrPrefetch: () => RsbuildPlugin;
2
+ export declare const pluginPreloadOrPrefetch: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare function pluginSplitChunks(): RsbuildPlugin;
2
+ export declare function pluginSplitChunks(): RsbuildPlugin;
@@ -98,10 +98,8 @@ function splitByModule(ctx) {
98
98
  vendors: {
99
99
  priority: -10,
100
100
  test: import_shared.NODE_MODULES_REGEX,
101
- // TODO: not support in rspack
102
- // @ts-expect-error
103
101
  name(module2) {
104
- return (0, import_shared.getPackageNameFromModulePath)(module2.context);
102
+ return module2 ? (0, import_shared.getPackageNameFromModulePath)(module2.context) : void 0;
105
103
  }
106
104
  },
107
105
  ...override.cacheGroups
@@ -9,4 +9,4 @@ import type { RsbuildPlugin } from '../types';
9
9
  */
10
10
  export declare function openBrowser(url: string): Promise<boolean>;
11
11
  export declare const replacePlaceholder: (url: string, port: number) => string;
12
- export declare function pluginStartUrl(): RsbuildPlugin;
12
+ export declare function pluginStartUrl(): RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginTarget: () => RsbuildPlugin;
2
+ export declare const pluginTarget: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginToml: () => RsbuildPlugin;
2
+ export declare const pluginToml: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginWasm: () => RsbuildPlugin;
2
+ export declare const pluginWasm: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginYaml: () => RsbuildPlugin;
2
+ export declare const pluginYaml: () => RsbuildPlugin;
@@ -6,4 +6,4 @@ export declare const withDefaultConfig: (config: RsbuildConfig) => RsbuildConfig
6
6
  * 2. Object value that should not be empty.
7
7
  * 3. Meaningful and can be filled by constant value.
8
8
  */
9
- export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
9
+ export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
@@ -1,19 +1,15 @@
1
1
  import { InitConfigsOptions } from './initConfigs';
2
2
  import type { Stats, MultiStats, BuildOptions, RspackCompiler, RspackMultiCompiler } from '@rsbuild/shared';
3
3
  export type BuildExecuter = {
4
- (compiler: RspackCompiler): Promise<{
5
- stats?: Stats;
6
- }>;
7
- (compiler: RspackMultiCompiler): Promise<{
8
- stats?: MultiStats;
9
- }>;
10
- (compiler: RspackCompiler | RspackMultiCompiler): Promise<{
11
- stats?: Stats | MultiStats;
12
- }>;
4
+ (compiler: RspackCompiler): Promise<{
5
+ stats?: Stats;
6
+ }>;
7
+ (compiler: RspackMultiCompiler): Promise<{
8
+ stats?: MultiStats;
9
+ }>;
10
+ (compiler: RspackCompiler | RspackMultiCompiler): Promise<{
11
+ stats?: Stats | MultiStats;
12
+ }>;
13
13
  };
14
14
  export declare const rspackBuild: BuildExecuter;
15
- export declare const build: (initOptions: InitConfigsOptions, {
16
- mode,
17
- watch,
18
- compiler: customCompiler
19
- }?: BuildOptions, executer?: BuildExecuter) => Promise<void>;
15
+ export declare const build: (initOptions: InitConfigsOptions, { mode, watch, compiler: customCompiler }?: BuildOptions, executer?: BuildExecuter) => Promise<void>;
@@ -1,11 +1,8 @@
1
1
  import { type RspackConfig, type RspackCompiler, type RspackMultiCompiler, type CreateDevMiddlewareReturns } from '@rsbuild/shared';
2
2
  import { type InitConfigsOptions } from './initConfigs';
3
3
  import type { Context } from '../../types';
4
- export declare function createCompiler({
5
- context,
6
- rspackConfigs
7
- }: {
8
- context: Context;
9
- rspackConfigs: RspackConfig[];
4
+ export declare function createCompiler({ context, rspackConfigs, }: {
5
+ context: Context;
6
+ rspackConfigs: RspackConfig[];
10
7
  }): Promise<RspackCompiler | RspackMultiCompiler>;
11
- export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: RspackCompiler | RspackMultiCompiler): Promise<CreateDevMiddlewareReturns>;
8
+ export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: RspackCompiler | RspackMultiCompiler): Promise<CreateDevMiddlewareReturns>;
@@ -10,4 +10,4 @@ export declare function createPublicContext(context: BaseContext): Readonly<Base
10
10
  * Generate the actual context used in the build,
11
11
  * which can have a lot of overhead and take some side effects.
12
12
  */
13
- export declare function createContext(options: Required<CreateRsbuildOptions>, userRsbuildConfig: RsbuildConfig, bundlerType: BundlerType): Promise<Context>;
13
+ export declare function createContext(options: Required<CreateRsbuildOptions>, userRsbuildConfig: RsbuildConfig, bundlerType: BundlerType): Promise<Context>;
@@ -59,7 +59,7 @@ function createContextByConfig(options, bundlerType, config = {}) {
59
59
  const context = {
60
60
  entry: config.source?.entry || getDefaultEntry(rootPath),
61
61
  targets: config.output?.targets || [],
62
- version: "0.2.7",
62
+ version: "0.2.9",
63
63
  rootPath,
64
64
  distPath,
65
65
  cachePath,
@@ -1,3 +1,3 @@
1
1
  import { DevMiddleware } from '@rsbuild/shared';
2
2
  import type { Compiler, MultiCompiler } from '@rspack/core';
3
- export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => NonNullable<DevMiddleware>;
3
+ export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => NonNullable<DevMiddleware>;
@@ -1,18 +1,11 @@
1
1
  import { type PluginStore, type RspackConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
2
2
  import type { Context, NormalizedConfig } from '../../types';
3
3
  export type InitConfigsOptions = {
4
- context: Context;
5
- pluginStore: PluginStore;
6
- rsbuildOptions: Required<CreateRsbuildOptions>;
4
+ context: Context;
5
+ pluginStore: PluginStore;
6
+ rsbuildOptions: Required<CreateRsbuildOptions>;
7
7
  };
8
- export declare function initRsbuildConfig({
9
- context,
10
- pluginStore
11
- }: Pick<InitConfigsOptions, 'context' | 'pluginStore'>): Promise<NormalizedConfig>;
12
- export declare function initConfigs({
13
- context,
14
- pluginStore,
15
- rsbuildOptions
16
- }: InitConfigsOptions): Promise<{
17
- rspackConfigs: RspackConfig[];
18
- }>;
8
+ export declare function initRsbuildConfig({ context, pluginStore, }: Pick<InitConfigsOptions, 'context' | 'pluginStore'>): Promise<NormalizedConfig>;
9
+ export declare function initConfigs({ context, pluginStore, rsbuildOptions, }: InitConfigsOptions): Promise<{
10
+ rspackConfigs: RspackConfig[];
11
+ }>;
@@ -1,21 +1,21 @@
1
1
  import type { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterStartProdServerFn, OnBeforeStartProdServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn } from '@rsbuild/shared';
2
2
  export declare function initHooks(): {
3
- /** parameters are not bundler-related */
4
- onExitHook: import("@rsbuild/shared").AsyncHook<OnExitFn>;
5
- onDevCompileDoneHook: import("@rsbuild/shared").AsyncHook<OnDevCompileDoneFn>;
6
- onAfterStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnAfterStartDevServerFn>;
7
- onBeforeStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnBeforeStartDevServerFn>;
8
- onAfterStartProdServerHook: import("@rsbuild/shared").AsyncHook<OnAfterStartProdServerFn>;
9
- onBeforeStartProdServerHook: import("@rsbuild/shared").AsyncHook<OnBeforeStartProdServerFn>;
10
- /** parameters are bundler-related */
11
- onAfterBuildHook: import("@rsbuild/shared").AsyncHook<OnAfterBuildFn>;
12
- onBeforeBuildHook: import("@rsbuild/shared").AsyncHook<OnBeforeBuildFn>;
13
- modifyRspackConfigHook: import("@rsbuild/shared").AsyncHook<ModifyRspackConfigFn>;
14
- modifyBundlerChainHook: import("@rsbuild/shared").AsyncHook<ModifyBundlerChainFn>;
15
- modifyWebpackChainHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackChainFn>;
16
- modifyWebpackConfigHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackConfigFn>;
17
- modifyRsbuildConfigHook: import("@rsbuild/shared").AsyncHook<ModifyRsbuildConfigFn>;
18
- onAfterCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnAfterCreateCompilerFn>;
19
- onBeforeCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnBeforeCreateCompilerFn>;
3
+ /** parameters are not bundler-related */
4
+ onExitHook: import("@rsbuild/shared").AsyncHook<OnExitFn>;
5
+ onDevCompileDoneHook: import("@rsbuild/shared").AsyncHook<OnDevCompileDoneFn>;
6
+ onAfterStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnAfterStartDevServerFn>;
7
+ onBeforeStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnBeforeStartDevServerFn>;
8
+ onAfterStartProdServerHook: import("@rsbuild/shared").AsyncHook<OnAfterStartProdServerFn>;
9
+ onBeforeStartProdServerHook: import("@rsbuild/shared").AsyncHook<OnBeforeStartProdServerFn>;
10
+ /** parameters are bundler-related */
11
+ onAfterBuildHook: import("@rsbuild/shared").AsyncHook<OnAfterBuildFn>;
12
+ onBeforeBuildHook: import("@rsbuild/shared").AsyncHook<OnBeforeBuildFn>;
13
+ modifyRspackConfigHook: import("@rsbuild/shared").AsyncHook<ModifyRspackConfigFn>;
14
+ modifyBundlerChainHook: import("@rsbuild/shared").AsyncHook<ModifyBundlerChainFn>;
15
+ modifyWebpackChainHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackChainFn>;
16
+ modifyWebpackConfigHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackConfigFn>;
17
+ modifyRsbuildConfigHook: import("@rsbuild/shared").AsyncHook<ModifyRsbuildConfigFn>;
18
+ onAfterCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnAfterCreateCompilerFn>;
19
+ onBeforeCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnBeforeCreateCompilerFn>;
20
20
  };
21
- export type Hooks = ReturnType<typeof initHooks>;
21
+ export type Hooks = ReturnType<typeof initHooks>;
@@ -1,9 +1,6 @@
1
1
  import { type PluginStore, type RsbuildPluginAPI } from '@rsbuild/shared';
2
2
  import type { Context } from '../../types';
3
- export declare function getPluginAPI({
4
- context,
5
- pluginStore
6
- }: {
7
- context: Context;
8
- pluginStore: PluginStore;
9
- }): RsbuildPluginAPI;
3
+ export declare function getPluginAPI({ context, pluginStore, }: {
4
+ context: Context;
5
+ pluginStore: PluginStore;
6
+ }): RsbuildPluginAPI;
@@ -1,12 +1,6 @@
1
1
  import { type InitConfigsOptions } from './initConfigs';
2
2
  import { type RspackConfig, type InspectConfigResult, type InspectConfigOptions } from '@rsbuild/shared';
3
- export declare function inspectConfig({
4
- context,
5
- pluginStore,
6
- rsbuildOptions,
7
- bundlerConfigs,
8
- inspectOptions
9
- }: InitConfigsOptions & {
10
- inspectOptions?: InspectConfigOptions;
11
- bundlerConfigs?: RspackConfig[];
12
- }): Promise<InspectConfigResult<'rspack'>>;
3
+ export declare function inspectConfig({ context, pluginStore, rsbuildOptions, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
4
+ inspectOptions?: InspectConfigOptions;
5
+ bundlerConfigs?: RspackConfig[];
6
+ }): Promise<InspectConfigResult<'rspack'>>;
@@ -1,9 +1,6 @@
1
1
  import { type RspackConfig, type RsbuildTarget } from '@rsbuild/shared';
2
2
  import type { Context } from '../../types';
3
- export declare function generateRspackConfig({
4
- target,
5
- context
6
- }: {
7
- target: RsbuildTarget;
8
- context: Context;
9
- }): Promise<RspackConfig>;
3
+ export declare function generateRspackConfig({ target, context, }: {
4
+ target: RsbuildTarget;
5
+ context: Context;
6
+ }): Promise<RspackConfig>;
@@ -33,6 +33,7 @@ __export(rspackConfig_exports, {
33
33
  module.exports = __toCommonJS(rspackConfig_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
35
  var import_shared2 = require("../shared");
36
+ var import_htmlPluginUtil = require("../htmlPluginUtil");
36
37
  async function modifyRspackConfig(context, rspackConfig, utils) {
37
38
  (0, import_shared.debug)("modify Rspack config");
38
39
  let [modifiedConfig] = await context.hooks.modifyRspackConfigHook.call(
@@ -92,7 +93,6 @@ async function getConfigUtils(config, chainUtils) {
92
93
  }
93
94
  async function getChainUtils(target) {
94
95
  const nodeEnv = process.env.NODE_ENV;
95
- const { default: HtmlPlugin } = await Promise.resolve().then(() => __toESM(require("html-webpack-plugin")));
96
96
  return {
97
97
  env: nodeEnv,
98
98
  target,
@@ -102,7 +102,7 @@ async function getChainUtils(target) {
102
102
  isWebWorker: target === "web-worker",
103
103
  getCompiledPath: import_shared2.getCompiledPath,
104
104
  CHAIN_ID: import_shared.CHAIN_ID,
105
- HtmlPlugin
105
+ HtmlPlugin: (0, import_htmlPluginUtil.getHTMLPlugin)()
106
106
  };
107
107
  }
108
108
  async function generateRspackConfig({
@@ -1,6 +1,6 @@
1
1
  import { CssModules } from '@rsbuild/shared';
2
2
  import type { LoaderContext } from '@rspack/core';
3
3
  export default function (this: LoaderContext<{
4
- modules: Required<CssModules>;
5
- mode: string;
6
- }>, content: string, ...input: any[]): Promise<any>;
4
+ modules: Required<CssModules>;
5
+ mode: string;
6
+ }>, content: string, ...input: any[]): Promise<any>;
@@ -1,11 +1,11 @@
1
1
  import { type CssModuleLocalsConvention } from '@rsbuild/shared';
2
2
  import type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
3
3
  export type PostcssParsePluginOptions = {
4
- exportLocalsConvention: CssModuleLocalsConvention;
5
- cssModuleKeys: string[];
4
+ exportLocalsConvention: CssModuleLocalsConvention;
5
+ cssModuleKeys: string[];
6
6
  };
7
7
  declare const plugin: {
8
- (options: PostcssParsePluginOptions): PostCSSPlugin;
9
- postcss: boolean;
8
+ (options: PostcssParsePluginOptions): PostCSSPlugin;
9
+ postcss: boolean;
10
10
  };
11
- export default plugin;
11
+ export default plugin;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is used to provide/set a global html-plugin singleton
3
+ */
4
+ import HtmlWebpackPlugin from 'html-webpack-plugin';
5
+ /**
6
+ * This method is used to override the Rsbuild default html-plugin (html-rspack-plugin).
7
+ */
8
+ export declare const setHTMLPlugin: (plugin: typeof HtmlWebpackPlugin) => void;
9
+ export declare const getHTMLPlugin: () => typeof HtmlWebpackPlugin;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var htmlPluginUtil_exports = {};
30
+ __export(htmlPluginUtil_exports, {
31
+ getHTMLPlugin: () => getHTMLPlugin,
32
+ setHTMLPlugin: () => setHTMLPlugin
33
+ });
34
+ module.exports = __toCommonJS(htmlPluginUtil_exports);
35
+ var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
36
+ let htmlPlugin;
37
+ const setHTMLPlugin = (plugin) => {
38
+ htmlPlugin = plugin;
39
+ };
40
+ const getHTMLPlugin = () => {
41
+ return htmlPlugin || import_html_webpack_plugin.default;
42
+ };
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ getHTMLPlugin,
46
+ setHTMLPlugin
47
+ });
@@ -7,4 +7,5 @@ export { withDefaultConfig } from './config';
7
7
  export { initRsbuildConfig } from './core/initConfigs';
8
8
  export { getPluginAPI } from './core/initPlugins';
9
9
  export { applyBaseCSSRule, applyCSSModuleRule } from './plugins/css';
10
- export type { Context } from '../types';
10
+ export type { Context } from '../types';
11
+ export { setHTMLPlugin, getHTMLPlugin } from './htmlPluginUtil';
@@ -22,11 +22,13 @@ __export(provider_exports, {
22
22
  applyCSSModuleRule: () => import_css.applyCSSModuleRule,
23
23
  createContext: () => import_createContext.createContext,
24
24
  createPublicContext: () => import_createContext.createPublicContext,
25
+ getHTMLPlugin: () => import_htmlPluginUtil.getHTMLPlugin,
25
26
  getPluginAPI: () => import_initPlugins.getPluginAPI,
26
27
  initHooks: () => import_initHooks.initHooks,
27
28
  initPlugins: () => import_shared.initPlugins,
28
29
  initRsbuildConfig: () => import_initConfigs.initRsbuildConfig,
29
30
  rspackProvider: () => import_provider.rspackProvider,
31
+ setHTMLPlugin: () => import_htmlPluginUtil.setHTMLPlugin,
30
32
  withDefaultConfig: () => import_config.withDefaultConfig
31
33
  });
32
34
  module.exports = __toCommonJS(provider_exports);
@@ -38,16 +40,19 @@ var import_config = require("./config");
38
40
  var import_initConfigs = require("./core/initConfigs");
39
41
  var import_initPlugins = require("./core/initPlugins");
40
42
  var import_css = require("./plugins/css");
43
+ var import_htmlPluginUtil = require("./htmlPluginUtil");
41
44
  // Annotate the CommonJS export names for ESM import in node:
42
45
  0 && (module.exports = {
43
46
  applyBaseCSSRule,
44
47
  applyCSSModuleRule,
45
48
  createContext,
46
49
  createPublicContext,
50
+ getHTMLPlugin,
47
51
  getPluginAPI,
48
52
  initHooks,
49
53
  initPlugins,
50
54
  initRsbuildConfig,
51
55
  rspackProvider,
56
+ setHTMLPlugin,
52
57
  withDefaultConfig
53
58
  });
@@ -1,24 +1,12 @@
1
1
  import { type BundlerChain, type Context, type RspackRule, type ModifyBundlerChainUtils } from '@rsbuild/shared';
2
2
  import type { RsbuildPlugin, NormalizedConfig } from '../../types';
3
3
  export declare const enableNativeCss: (config: NormalizedConfig) => boolean;
4
- export declare function applyBaseCSSRule({
5
- rule,
6
- config,
7
- context,
8
- utils: {
9
- target,
10
- isProd,
11
- isServer,
12
- isWebWorker,
13
- CHAIN_ID
14
- },
15
- importLoaders
16
- }: {
17
- rule: ReturnType<BundlerChain['module']['rule']>;
18
- config: NormalizedConfig;
19
- context: Context;
20
- utils: ModifyBundlerChainUtils;
21
- importLoaders?: number;
4
+ export declare function applyBaseCSSRule({ rule, config, context, utils: { target, isProd, isServer, isWebWorker, CHAIN_ID }, importLoaders, }: {
5
+ rule: ReturnType<BundlerChain['module']['rule']>;
6
+ config: NormalizedConfig;
7
+ context: Context;
8
+ utils: ModifyBundlerChainUtils;
9
+ importLoaders?: number;
22
10
  }): Promise<void>;
23
11
  /**
24
12
  * Use type: "css/module" rule instead of css-loader modules.auto config
@@ -26,4 +14,4 @@ export declare function applyBaseCSSRule({
26
14
  * applyCSSModuleRule in modifyRspackConfig, so that other plugins can easily adjust css rule in Chain.
27
15
  */
28
16
  export declare const applyCSSModuleRule: (rules: RspackRule[] | undefined, ruleTest: RegExp, config: NormalizedConfig) => void;
29
- export declare const pluginCss: () => RsbuildPlugin;
17
+ export declare const pluginCss: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare const pluginHMR: () => RsbuildPlugin;
2
+ export declare const pluginHMR: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare function pluginLess(): RsbuildPlugin;
2
+ export declare function pluginLess(): RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare const pluginMinimize: () => RsbuildPlugin;
2
+ export declare const pluginMinimize: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare const pluginOutput: () => RsbuildPlugin;
2
+ export declare const pluginOutput: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare const pluginProgress: () => RsbuildPlugin;
2
+ export declare const pluginProgress: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare const pluginResolve: () => RsbuildPlugin;
2
+ export declare const pluginResolve: () => RsbuildPlugin;
@@ -2,4 +2,4 @@
2
2
  import type { RsbuildPlugin } from '../../types';
3
3
  import inspector from 'inspector';
4
4
  export declare const stopProfiler: (output: string, profileSession?: inspector.Session) => void;
5
- export declare const pluginRspackProfile: () => RsbuildPlugin;
5
+ export declare const pluginRspackProfile: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare function pluginSass(): RsbuildPlugin;
2
+ export declare function pluginSass(): RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../../types';
2
- export declare const pluginServer: () => RsbuildPlugin;
2
+ export declare const pluginServer: () => RsbuildPlugin;
@@ -4,4 +4,4 @@ export declare function getDefaultSwcConfig(config: NormalizedConfig, rootPath:
4
4
  /**
5
5
  * Provide some swc configs of rspack
6
6
  */
7
- export declare const pluginSwc: () => RsbuildPlugin;
7
+ export declare const pluginSwc: () => RsbuildPlugin;
@@ -62,45 +62,37 @@ async function getDefaultSwcConfig(config, rootPath, target) {
62
62
  const pluginSwc = () => ({
63
63
  name: "rsbuild:swc",
64
64
  setup(api) {
65
- api.modifyBundlerChain(
66
- async (chain, { CHAIN_ID, target, isServer, isServiceWorker }) => {
67
- const config = api.getNormalizedConfig();
68
- (0, import_shared.addCoreJsEntry)({
69
- chain,
70
- config,
71
- isServer,
72
- isServiceWorker
73
- });
74
- const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.SCRIPT_REGEX).type("javascript/auto");
75
- (0, import_shared.applyScriptCondition)({
76
- rule,
77
- config,
78
- context: api.context,
79
- includes: [],
80
- excludes: []
81
- });
82
- const swcConfig = await getDefaultSwcConfig(
83
- config,
84
- api.context.rootPath,
85
- target
86
- );
87
- applyTransformImport(swcConfig, config.source.transformImport);
88
- applyDecorator(swcConfig, config.output.enableLatestDecorators);
89
- if ((0, import_shared.isWebTarget)(target)) {
90
- const polyfillMode = config.output.polyfill;
91
- if (polyfillMode === "off" || polyfillMode === "ua") {
92
- swcConfig.env.mode = void 0;
93
- } else {
94
- swcConfig.env.mode = polyfillMode;
95
- await applyCoreJs(swcConfig, chain, polyfillMode);
96
- }
65
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
66
+ const config = api.getNormalizedConfig();
67
+ const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.SCRIPT_REGEX).type("javascript/auto");
68
+ (0, import_shared.applyScriptCondition)({
69
+ rule,
70
+ config,
71
+ context: api.context,
72
+ includes: [],
73
+ excludes: []
74
+ });
75
+ const swcConfig = await getDefaultSwcConfig(
76
+ config,
77
+ api.context.rootPath,
78
+ target
79
+ );
80
+ applyTransformImport(swcConfig, config.source.transformImport);
81
+ applyDecorator(swcConfig, config.output.enableLatestDecorators);
82
+ if ((0, import_shared.isWebTarget)(target)) {
83
+ const polyfillMode = config.output.polyfill;
84
+ if (polyfillMode === "off" || polyfillMode === "ua") {
85
+ swcConfig.env.mode = void 0;
86
+ } else {
87
+ swcConfig.env.mode = polyfillMode;
88
+ await applyCoreJs(swcConfig, chain, polyfillMode);
97
89
  }
98
- rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(swcConfig);
99
- chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
100
- or: ["text/javascript", "application/javascript"]
101
- }).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(swcConfig));
102
90
  }
103
- );
91
+ rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(swcConfig);
92
+ chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
93
+ or: ["text/javascript", "application/javascript"]
94
+ }).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(swcConfig));
95
+ });
104
96
  }
105
97
  });
106
98
  async function applyCoreJs(swcConfig, chain, polyfillMode) {
@@ -2,4 +2,4 @@ import type { RsbuildPlugin } from '../../types';
2
2
  /**
3
3
  * Provide some temporary configurations for Rspack early transition
4
4
  */
5
- export declare const pluginTransition: () => RsbuildPlugin;
5
+ export declare const pluginTransition: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import { type RsbuildProvider } from '@rsbuild/shared';
2
- export declare const rspackProvider: RsbuildProvider;
2
+ export declare const rspackProvider: RsbuildProvider;
@@ -4,4 +4,4 @@ export declare const applyDefaultPlugins: (plugins: Plugins) => import("@rsbuild
4
4
  export declare const rspackMinVersion = "0.4.0";
5
5
  export declare const isSatisfyRspackVersion: (version: string) => Promise<boolean>;
6
6
  export declare const getCompiledPath: (packageName: string) => string;
7
- export declare const BUILTIN_LOADER = "builtin:";
7
+ export declare const BUILTIN_LOADER = "builtin:";
@@ -1,13 +1,13 @@
1
1
  import type { Compiler } from '@rspack/core';
2
2
  type AppIconOptions = {
3
- distDir: string;
4
- iconPath: string;
3
+ distDir: string;
4
+ iconPath: string;
5
5
  };
6
6
  export declare class HtmlAppIconPlugin {
7
- readonly name: string;
8
- readonly distDir: string;
9
- readonly iconPath: string;
10
- constructor(options: AppIconOptions);
11
- apply(compiler: Compiler): void;
7
+ readonly name: string;
8
+ readonly distDir: string;
9
+ readonly iconPath: string;
10
+ constructor(options: AppIconOptions);
11
+ apply(compiler: Compiler): void;
12
12
  }
13
- export {};
13
+ export {};