@rsbuild/core 0.0.23 → 0.0.25

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 (68) hide show
  1. package/dist/cli/commands.js +35 -11
  2. package/dist/cli/config.d.ts +1 -2
  3. package/dist/cli/run.d.ts +0 -2
  4. package/dist/cli/run.js +0 -6
  5. package/dist/createRsbuild.d.ts +2 -2
  6. package/dist/createRsbuild.js +6 -3
  7. package/dist/index.d.ts +2 -1
  8. package/dist/plugins/asset.d.ts +2 -2
  9. package/dist/plugins/bundleAnalyzer.d.ts +2 -2
  10. package/dist/plugins/cache.d.ts +2 -2
  11. package/dist/plugins/cache.js +0 -3
  12. package/dist/plugins/cleanOutput.d.ts +2 -2
  13. package/dist/plugins/define.d.ts +2 -2
  14. package/dist/plugins/devtool.d.ts +2 -2
  15. package/dist/plugins/entry.d.ts +2 -2
  16. package/dist/plugins/entry.js +11 -0
  17. package/dist/plugins/externals.d.ts +2 -2
  18. package/dist/plugins/fileSize.d.ts +2 -2
  19. package/dist/plugins/fileSize.js +2 -2
  20. package/dist/plugins/html.d.ts +3 -2
  21. package/dist/plugins/inlineChunk.d.ts +2 -2
  22. package/dist/plugins/moment.d.ts +2 -2
  23. package/dist/plugins/networkPerformance.d.ts +2 -2
  24. package/dist/plugins/nodeAddons.d.ts +2 -2
  25. package/dist/plugins/performance.d.ts +2 -2
  26. package/dist/plugins/preloadOrPrefetch.d.ts +2 -2
  27. package/dist/plugins/splitChunks.d.ts +2 -2
  28. package/dist/plugins/startUrl.d.ts +2 -2
  29. package/dist/plugins/startUrl.js +7 -3
  30. package/dist/plugins/target.d.ts +2 -2
  31. package/dist/plugins/toml.d.ts +2 -2
  32. package/dist/plugins/wasm.d.ts +2 -2
  33. package/dist/plugins/yaml.d.ts +2 -2
  34. package/dist/{rspack-provider/rspackPlugin/removeCssSourcemapPlugin.js → rspack-plugins/RemoveCssSourcemapPlugin.js} +3 -3
  35. package/dist/rspack-provider/config/defaults.d.ts +1 -1
  36. package/dist/rspack-provider/config/normalize.d.ts +1 -1
  37. package/dist/rspack-provider/core/createCompiler.d.ts +1 -1
  38. package/dist/rspack-provider/core/createContext.d.ts +1 -1
  39. package/dist/rspack-provider/core/initConfigs.d.ts +1 -1
  40. package/dist/rspack-provider/core/initConfigs.js +1 -0
  41. package/dist/rspack-provider/core/initHooks.d.ts +2 -2
  42. package/dist/rspack-provider/core/initPlugins.d.ts +1 -1
  43. package/dist/rspack-provider/core/rspackConfig.d.ts +1 -1
  44. package/dist/rspack-provider/index.d.ts +0 -1
  45. package/dist/rspack-provider/plugins/basic.d.ts +1 -1
  46. package/dist/rspack-provider/plugins/css.d.ts +1 -1
  47. package/dist/rspack-provider/plugins/css.js +1 -1
  48. package/dist/rspack-provider/plugins/hmr.d.ts +1 -1
  49. package/dist/rspack-provider/plugins/less.d.ts +1 -1
  50. package/dist/rspack-provider/plugins/minimize.d.ts +1 -1
  51. package/dist/rspack-provider/plugins/output.d.ts +1 -1
  52. package/dist/rspack-provider/plugins/progress.d.ts +1 -1
  53. package/dist/rspack-provider/plugins/resolve.d.ts +1 -1
  54. package/dist/rspack-provider/plugins/rspackProfile.d.ts +1 -1
  55. package/dist/rspack-provider/plugins/sass.d.ts +1 -1
  56. package/dist/rspack-provider/plugins/swc.d.ts +1 -1
  57. package/dist/rspack-provider/plugins/transition.d.ts +1 -1
  58. package/dist/rspack-provider/provider.d.ts +1 -1
  59. package/dist/rspack-provider/shared/plugin.d.ts +1 -1
  60. package/dist/types.d.ts +19 -0
  61. package/dist/{rspack-provider/types/plugin.js → types.js} +2 -2
  62. package/package.json +3 -3
  63. package/dist/rspack-provider/types/context.d.ts +0 -16
  64. package/dist/rspack-provider/types/context.js +0 -16
  65. package/dist/rspack-provider/types/index.d.ts +0 -3
  66. package/dist/rspack-provider/types/index.js +0 -24
  67. package/dist/rspack-provider/types/plugin.d.ts +0 -4
  68. /package/dist/{rspack-provider/rspackPlugin/removeCssSourcemapPlugin.d.ts → rspack-plugins/RemoveCssSourcemapPlugin.d.ts} +0 -0
@@ -29,23 +29,47 @@ function setupProgram(rsbuild) {
29
29
  const { version } = import_shared.fse.readJSONSync(pkgJson);
30
30
  import_commander.program.name("rsbuild").usage("<command> [options]").version(version);
31
31
  import_commander.program.command("dev").option(`--open`, "open the page in browser on startup").description("starting the dev server").action(async (options) => {
32
- await rsbuild.startDevServer({
33
- open: options.open
34
- });
32
+ try {
33
+ await rsbuild.startDevServer({
34
+ open: options.open
35
+ });
36
+ } catch (err) {
37
+ import_shared.logger.error("Failed to start dev server, please check logs.");
38
+ import_shared.logger.error(err);
39
+ process.exit(1);
40
+ }
35
41
  });
36
42
  import_commander.program.command("build").description("build the app for production").action(async () => {
37
- await rsbuild.build();
43
+ try {
44
+ await rsbuild.build();
45
+ } catch (err) {
46
+ import_shared.logger.error("Failed to build, please check logs.");
47
+ import_shared.logger.error(err);
48
+ process.exit(1);
49
+ }
38
50
  });
39
51
  import_commander.program.command("preview").description("preview the production build locally").action(async () => {
40
- await rsbuild.preview();
52
+ try {
53
+ await rsbuild.preview();
54
+ } catch (err) {
55
+ import_shared.logger.error("Failed to start preview server, please check logs.");
56
+ import_shared.logger.error(err);
57
+ process.exit(1);
58
+ }
41
59
  });
42
60
  import_commander.program.command("inspect").description("inspect the Rspack and Rsbuild configs").option(`--env <env>`, "specify env mode", "development").option("--output <output>", "specify inspect content output path", "/").option("--verbose", "show full function definitions in output").action(async (options) => {
43
- rsbuild.inspectConfig({
44
- env: options.env,
45
- verbose: options.verbose,
46
- outputPath: (0, import_path.join)(rsbuild.context.distPath, options.output),
47
- writeToDisk: true
48
- });
61
+ try {
62
+ await rsbuild.inspectConfig({
63
+ env: options.env,
64
+ verbose: options.verbose,
65
+ outputPath: (0, import_path.join)(rsbuild.context.distPath, options.output),
66
+ writeToDisk: true
67
+ });
68
+ } catch (err) {
69
+ import_shared.logger.error("Failed to inspect config, please check logs.");
70
+ import_shared.logger.error(err);
71
+ process.exit(1);
72
+ }
49
73
  });
50
74
  import_commander.program.parse();
51
75
  }
@@ -1,6 +1,5 @@
1
- import type { RsbuildPlugin, RsbuildConfig as BaseRsbuildConfig } from '@rsbuild/shared';
1
+ import type { RsbuildConfig as BaseRsbuildConfig } from '@rsbuild/shared';
2
2
  export type RsbuildConfig = BaseRsbuildConfig & {
3
- plugins?: RsbuildPlugin[];
4
3
  /**
5
4
  * @private only for testing
6
5
  */
package/dist/cli/run.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { type RsbuildPlugin } from '..';
2
1
  type RunCliOptions = {
3
2
  isRestart?: boolean;
4
- defaultPlugins?: RsbuildPlugin[];
5
3
  };
6
4
  export declare function runCli(options?: RunCliOptions): Promise<import("..").RsbuildInstance<any>>;
7
5
  export {};
package/dist/cli/run.js CHANGED
@@ -30,12 +30,6 @@ async function runCli(options = {}) {
30
30
  rsbuildConfig: config,
31
31
  provider: config.provider
32
32
  });
33
- if (options.defaultPlugins) {
34
- rsbuild.addPlugins(options.defaultPlugins);
35
- }
36
- if (config.plugins) {
37
- rsbuild.addPlugins(config.plugins);
38
- }
39
33
  if (!options.isRestart) {
40
34
  (0, import_commands.setupProgram)(rsbuild);
41
35
  }
@@ -1,11 +1,11 @@
1
1
  import { type RsbuildInstance, type RsbuildProvider, type CreateRsbuildOptions } from '@rsbuild/shared';
2
- import type { RsbuildConfig } from './rspack-provider';
2
+ import type { RsbuildConfig } from './types';
3
3
  export declare const getCreateRsbuildDefaultOptions: () => Required<CreateRsbuildOptions>;
4
4
  export declare function createRsbuild<P extends ({
5
5
  rsbuildConfig
6
6
  }: {
7
7
  rsbuildConfig: T;
8
- }) => RsbuildProvider, T = RsbuildConfig>(options: CreateRsbuildOptions & {
8
+ }) => RsbuildProvider, T extends RsbuildConfig>(options: CreateRsbuildOptions & {
9
9
  rsbuildConfig: T;
10
10
  provider?: P;
11
11
  }): Promise<RsbuildInstance<ReturnType<P>>>;
@@ -42,8 +42,7 @@ const getRspackProvider = async (rsbuildConfig) => {
42
42
  };
43
43
  const getCreateRsbuildDefaultOptions = () => ({
44
44
  cwd: process.cwd(),
45
- target: ["web"],
46
- configPath: null
45
+ target: ["web"]
47
46
  });
48
47
  async function createRsbuild(options) {
49
48
  const { rsbuildConfig } = options;
@@ -71,7 +70,7 @@ async function createRsbuild(options) {
71
70
  (0, import_shared.debug)("add default plugins");
72
71
  await applyDefaultPlugins(pluginStore);
73
72
  (0, import_shared.debug)("add default plugins done");
74
- return {
73
+ const rsbuild = {
75
74
  ...(0, import_shared.pick)(pluginStore, ["addPlugins", "removePlugins", "isPluginExists"]),
76
75
  ...(0, import_shared.pick)(pluginAPI, [
77
76
  "onBeforeBuild",
@@ -94,6 +93,10 @@ async function createRsbuild(options) {
94
93
  startDevServer,
95
94
  context: publicContext
96
95
  };
96
+ if (rsbuildConfig.plugins) {
97
+ rsbuild.addPlugins(rsbuildConfig.plugins);
98
+ }
99
+ return rsbuild;
97
100
  }
98
101
  // Annotate the CommonJS export names for ESM import in node:
99
102
  0 && (module.exports = {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { createRsbuild, getCreateRsbuildDefaultOptions } from './createRsbuild';
2
2
  export { mergeRsbuildConfig } from '@rsbuild/shared';
3
3
  export { defineConfig } from './cli';
4
- export type { Rspack, RsbuildConfig, RsbuildPlugin, RsbuildPluginAPI } from './rspack-provider';
4
+ export type { Rspack } from './rspack-provider';
5
+ export type { RsbuildConfig, NormalizedConfig, RsbuildPlugin, RsbuildPluginAPI } from './types';
5
6
  export type { Context, RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn } from '@rsbuild/shared';
@@ -1,3 +1,3 @@
1
- import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '../types';
2
2
  export declare function getRegExpForExts(exts: string[]): RegExp;
3
- export declare const pluginAsset: () => DefaultRsbuildPlugin;
3
+ export declare const pluginAsset: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare function pluginBundleAnalyzer(): DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare function pluginBundleAnalyzer(): RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginCache: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginCache: () => RsbuildPlugin;
@@ -64,9 +64,6 @@ async function getBuildDependencies(context) {
64
64
  if (await (0, import_shared2.isFileExists)(rootPackageJson)) {
65
65
  buildDependencies.packageJson = [rootPackageJson];
66
66
  }
67
- if (context.configPath) {
68
- buildDependencies.config = [context.configPath];
69
- }
70
67
  if (context.tsconfigPath) {
71
68
  buildDependencies.tsconfig = [context.tsconfigPath];
72
69
  }
@@ -1,2 +1,2 @@
1
- import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginCleanOutput: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginCleanOutput: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginDefine: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginDefine: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginDevtool: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginDevtool: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginEntry: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginEntry: () => RsbuildPlugin;
@@ -34,6 +34,17 @@ const pluginEntry = () => ({
34
34
  (0, import_shared.castArray)(entry[entryName]).forEach(appendEntry);
35
35
  });
36
36
  });
37
+ api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
38
+ if (bundlerConfigs.every((config) => !config.entry)) {
39
+ throw new Error(
40
+ `Could not find any entry module, please make sure that ${import_shared.color.cyan(
41
+ `src/index.(ts|js|tsx|jsx|mjs|cjs)`
42
+ )} exists, or customize entry through the ${import_shared.color.cyan(
43
+ `source.entry`
44
+ )} configuration.`
45
+ );
46
+ }
47
+ });
37
48
  }
38
49
  });
39
50
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare function pluginExternals(): DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare function pluginExternals(): RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '../types';
2
2
  /** Filter source map and license files */
3
3
  export declare const filterAsset: (asset: string) => boolean;
4
- export declare const pluginFileSize: () => DefaultRsbuildPlugin;
4
+ export declare const pluginFileSize: () => RsbuildPlugin;
@@ -144,8 +144,8 @@ const pluginFileSize = () => ({
144
144
  try {
145
145
  await printFileSizes(stats, api.context.distPath);
146
146
  } catch (err) {
147
- import_shared2.logger.error("Failed to print file size.");
148
- import_shared2.logger.error(err);
147
+ import_shared2.logger.warn("Failed to print file size.");
148
+ import_shared2.logger.warn(err);
149
149
  }
150
150
  }
151
151
  });
@@ -1,4 +1,5 @@
1
- import type { MetaAttrs, HtmlConfig, MetaOptions, NormalizedConfig, DefaultRsbuildPlugin, SharedRsbuildPluginAPI, NormalizedOutputConfig } from '@rsbuild/shared';
1
+ import type { MetaAttrs, HtmlConfig, MetaOptions, NormalizedConfig, SharedRsbuildPluginAPI, NormalizedOutputConfig } from '@rsbuild/shared';
2
+ import type { RsbuildPlugin } from '../types';
2
3
  export declare function getTitle(entryName: string, config: NormalizedConfig): string;
3
4
  export declare function getInject(entryName: string, config: NormalizedConfig): import("@rsbuild/shared").ScriptInject;
4
5
  export declare function getTemplatePath(entryName: string, config: NormalizedConfig): string;
@@ -11,4 +12,4 @@ export declare function getMetaTags(entryName: string, config: {
11
12
  output: NormalizedOutputConfig;
12
13
  }): Promise<MetaAttrs[]>;
13
14
  export declare const applyInjectTags: (api: SharedRsbuildPluginAPI) => void;
14
- export declare const pluginHtml: () => DefaultRsbuildPlugin;
15
+ export declare const pluginHtml: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginInlineChunk: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginInlineChunk: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginMoment: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginMoment: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginNetworkPerformance: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginNetworkPerformance: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginNodeAddons: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginNodeAddons: () => RsbuildPlugin;
@@ -1,5 +1,5 @@
1
- import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '../types';
2
2
  /**
3
3
  * Apply some configs of Rsbuild performance
4
4
  */
5
- export declare const pluginPerformance: () => DefaultRsbuildPlugin;
5
+ export declare const pluginPerformance: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginPreloadOrPrefetch: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginPreloadOrPrefetch: () => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '../types';
2
2
  /** Expect to match path just like "./node_modules/react-router/" */
3
3
  export declare const createDependenciesRegExp: (...dependencies: (string | RegExp)[]) => RegExp;
4
- export declare function pluginSplitChunks(): DefaultRsbuildPlugin;
4
+ export declare function pluginSplitChunks(): RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
1
+ import type { RsbuildPlugin } from '../types';
2
2
  /**
3
3
  * This method is modified based on source found in
4
4
  * https://github.com/facebook/create-react-app
@@ -9,4 +9,4 @@ import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
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(): DefaultRsbuildPlugin;
12
+ export declare function pluginStartUrl(): RsbuildPlugin;
@@ -107,9 +107,13 @@ function pluginStartUrl() {
107
107
  const urls = [];
108
108
  if (startUrl === true || !startUrl) {
109
109
  const protocol = https ? "https" : "http";
110
- urls.push(
111
- (0, import_shared.normalizeUrl)(`${protocol}://localhost:${port}/${routes[0].route}`)
112
- );
110
+ if (routes.length) {
111
+ urls.push(
112
+ (0, import_shared.normalizeUrl)(
113
+ `${protocol}://localhost:${port}/${routes[0].route}`
114
+ )
115
+ );
116
+ }
113
117
  } else {
114
118
  urls.push(
115
119
  ...(0, import_shared.castArray)(startUrl).map(
@@ -1,2 +1,2 @@
1
- import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginTarget: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginTarget: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginToml: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginToml: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginWasm: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginWasm: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginYaml: () => DefaultRsbuildPlugin;
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginYaml: () => RsbuildPlugin;
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var removeCssSourcemapPlugin_exports = {};
20
- __export(removeCssSourcemapPlugin_exports, {
19
+ var RemoveCssSourcemapPlugin_exports = {};
20
+ __export(RemoveCssSourcemapPlugin_exports, {
21
21
  RemoveCssSourcemapPlugin: () => RemoveCssSourcemapPlugin
22
22
  });
23
- module.exports = __toCommonJS(removeCssSourcemapPlugin_exports);
23
+ module.exports = __toCommonJS(RemoveCssSourcemapPlugin_exports);
24
24
  var import_shared = require("@rsbuild/shared");
25
25
  class RemoveCssSourcemapPlugin {
26
26
  constructor(htmlPlugin) {
@@ -1,3 +1,3 @@
1
- import type { RsbuildConfig } from '../types';
1
+ import type { RsbuildConfig } from '../../types';
2
2
  export declare const createDefaultConfig: () => RsbuildConfig;
3
3
  export declare const withDefaultConfig: (config: RsbuildConfig) => RsbuildConfig;
@@ -1,4 +1,4 @@
1
- import { RsbuildConfig, NormalizedConfig } from '../types';
1
+ import { RsbuildConfig, NormalizedConfig } from '../../types';
2
2
  /** #__PURE__
3
3
  * 1. May used by multiple plugins.
4
4
  * 2. Object value that should not be empty.
@@ -1,7 +1,7 @@
1
1
  import { type RspackConfig } from '@rsbuild/shared';
2
2
  import { type RspackCompiler, type RspackMultiCompiler } from '@rsbuild/shared';
3
3
  import { type InitConfigsOptions } from './initConfigs';
4
- import type { Context } from '../types';
4
+ import type { Context } from '../../types';
5
5
  export declare function createCompiler({
6
6
  context,
7
7
  rspackConfigs
@@ -1,5 +1,5 @@
1
1
  import { type CreateRsbuildOptions } from '@rsbuild/shared';
2
- import type { Context, RsbuildConfig } from '../types';
2
+ import type { Context, RsbuildConfig } from '../../types';
3
3
  /**
4
4
  * Generate the actual context used in the build,
5
5
  * which can have a lot of overhead and take some side effects.
@@ -1,5 +1,5 @@
1
1
  import { type PluginStore, type CreateRsbuildOptions } from '@rsbuild/shared';
2
- import type { Context } from '../types';
2
+ import type { Context } from '../../types';
3
3
  export type InitConfigsOptions = {
4
4
  context: Context;
5
5
  pluginStore: PluginStore;
@@ -45,6 +45,7 @@ async function initConfigs({
45
45
  });
46
46
  await modifyRsbuildConfig(context);
47
47
  context.normalizedConfig = (0, import_normalize.normalizeConfig)(context.config);
48
+ (0, import_shared.updateContextByNormalizedConfig)(context, context.normalizedConfig);
48
49
  const targets = (0, import_shared.castArray)(rsbuildOptions.target);
49
50
  const rspackConfigs = await Promise.all(
50
51
  targets.map((target) => (0, import_rspackConfig.generateRspackConfig)({ target, context }))
@@ -1,5 +1,5 @@
1
- import { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn, ModifyBundlerChainFn, type RspackConfig, type ModifyRspackConfigFn } from '@rsbuild/shared';
2
- import type { RsbuildConfig } from '../types';
1
+ import { type OnExitFn, type OnAfterBuildFn, type OnBeforeBuildFn, type OnDevCompileDoneFn, type ModifyRsbuildConfigFn, type OnAfterStartDevServerFn, type OnBeforeStartDevServerFn, type OnAfterCreateCompilerFn, type OnBeforeCreateCompilerFn, type ModifyBundlerChainFn, type RspackConfig, type ModifyRspackConfigFn } from '@rsbuild/shared';
2
+ import type { RsbuildConfig } from '../../types';
3
3
  import type { Compiler, MultiCompiler } from '@rspack/core';
4
4
  export declare function initHooks(): {
5
5
  /** parameters are not bundler-related */
@@ -1,5 +1,5 @@
1
1
  import { type PluginStore } from '@rsbuild/shared';
2
- import type { Context, RsbuildPluginAPI } from '../types';
2
+ import type { Context, RsbuildPluginAPI } from '../../types';
3
3
  export declare function getPluginAPI({
4
4
  context,
5
5
  pluginStore
@@ -1,5 +1,5 @@
1
1
  import { type RspackConfig, type RsbuildTarget } from '@rsbuild/shared';
2
- import type { Context } from '../types';
2
+ import type { Context } from '../../types';
3
3
  export declare function generateRspackConfig({
4
4
  target,
5
5
  context
@@ -1,5 +1,4 @@
1
1
  export { getRspackVersion } from './shared/rspackVersion';
2
2
  export { rspackProvider } from './provider';
3
3
  export type { RspackProvider } from './provider';
4
- export type { RsbuildConfig, NormalizedConfig, RsbuildPlugin, RsbuildPluginAPI } from './types';
5
4
  export type { Rspack, RspackConfig } from '@rsbuild/shared';
@@ -1,4 +1,4 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  /**
3
3
  * Provide some basic configs of rspack
4
4
  */
@@ -1,5 +1,5 @@
1
1
  import { type BundlerChain, type Context, type RspackRule, type ModifyBundlerChainUtils } from '@rsbuild/shared';
2
- import type { RsbuildPlugin, NormalizedConfig } from '../types';
2
+ import type { RsbuildPlugin, NormalizedConfig } from '../../types';
3
3
  export declare const enableNativeCss: (config: NormalizedConfig) => boolean;
4
4
  export declare function applyBaseCSSRule({
5
5
  rule,
@@ -166,7 +166,7 @@ const pluginCss = () => {
166
166
  const enableSourceMap = (0, import_shared.isUseCssSourceMap)(config);
167
167
  const enableExtractCSS = (0, import_shared.isUseCssExtract)(config, utils.target);
168
168
  if (!enableSourceMap && enableExtractCSS) {
169
- const { RemoveCssSourcemapPlugin } = await Promise.resolve().then(() => __toESM(require("../rspackPlugin/removeCssSourcemapPlugin")));
169
+ const { RemoveCssSourcemapPlugin } = await Promise.resolve().then(() => __toESM(require("../../rspack-plugins/RemoveCssSourcemapPlugin")));
170
170
  chain.plugin("remove-css-sourcemap").use(RemoveCssSourcemapPlugin, [utils.HtmlPlugin]);
171
171
  }
172
172
  });
@@ -1,2 +1,2 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  export declare const pluginHMR: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  export declare function pluginLess(): RsbuildPlugin;
@@ -1,5 +1,5 @@
1
1
  import { type BundlerChain } from '@rsbuild/shared';
2
- import type { RsbuildPlugin, NormalizedConfig } from '../types';
2
+ import type { RsbuildPlugin, NormalizedConfig } from '../../types';
3
3
  export declare function applyJSMinimizer(chain: BundlerChain, config: NormalizedConfig): void;
4
4
  export declare function applyCSSMinimizer(chain: BundlerChain): void;
5
5
  export declare const pluginMinimize: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  export declare const pluginOutput: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  export declare const pluginProgress: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  export declare const pluginResolve: () => RsbuildPlugin;
@@ -1,4 +1,4 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  import inspector from 'inspector';
3
3
  export declare const stopProfiler: (output: string, profileSession?: inspector.Session) => void;
4
4
  export declare const pluginRspackProfile: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  export declare function pluginSass(): RsbuildPlugin;
@@ -1,5 +1,5 @@
1
1
  import { type RsbuildTarget, type BuiltinSwcLoaderOptions } from '@rsbuild/shared';
2
- import type { RsbuildPlugin, NormalizedConfig } from '../types';
2
+ import type { RsbuildPlugin, NormalizedConfig } from '../../types';
3
3
  export declare function getDefaultSwcConfig(config: NormalizedConfig, rootPath: string, target: RsbuildTarget): Promise<BuiltinSwcLoaderOptions>;
4
4
  /**
5
5
  * Provide some swc configs of rspack
@@ -1,4 +1,4 @@
1
- import type { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../../types';
2
2
  /**
3
3
  * Provide some temporary configurations for Rspack early transition
4
4
  */
@@ -1,5 +1,5 @@
1
1
  import { type RsbuildProvider, type RspackConfig, type RspackCompiler, type RspackMultiCompiler } from '@rsbuild/shared';
2
- import type { RsbuildConfig, NormalizedConfig } from './types';
2
+ import type { RsbuildConfig, NormalizedConfig } from '../types';
3
3
  export type RspackProvider = RsbuildProvider<RsbuildConfig, RspackConfig, NormalizedConfig, RspackCompiler | RspackMultiCompiler>;
4
4
  export declare function rspackProvider({
5
5
  rsbuildConfig: originalRsbuildConfig
@@ -1,3 +1,3 @@
1
- import { RsbuildPlugin } from '../types';
1
+ import { RsbuildPlugin } from '../../types';
2
2
  import { Plugins } from '@rsbuild/shared';
3
3
  export declare const applyDefaultPlugins: (plugins: Plugins) => import("@rsbuild/shared").AwaitableGetter<RsbuildPlugin>;
@@ -0,0 +1,19 @@
1
+ import type { Context as BaseContext, RsbuildConfig, NormalizedConfig, DefaultRsbuildPluginAPI, RsbuildPlugin as BaseRsbuildPlugin } from '@rsbuild/shared';
2
+ import type { Hooks } from './rspack-provider/core/initHooks';
3
+ import type { RspackConfig, RspackCompiler, RspackMultiCompiler } from '@rsbuild/shared';
4
+ export interface RsbuildPluginAPI extends DefaultRsbuildPluginAPI<RsbuildConfig, NormalizedConfig, RspackConfig, RspackCompiler | RspackMultiCompiler> {}
5
+ export type RsbuildPlugin<T = RsbuildPluginAPI> = BaseRsbuildPlugin<T>;
6
+ /** The inner context. */
7
+ export type Context = BaseContext & {
8
+ /** All hooks. */
9
+ hooks: Readonly<Hooks>;
10
+ /** Current Rsbuild config. */
11
+ config: Readonly<RsbuildConfig>;
12
+ /** The original Rsbuild config passed from the createRsbuild method. */
13
+ originalConfig: Readonly<RsbuildConfig>;
14
+ /** The normalized Rsbuild config. */
15
+ normalizedConfig?: NormalizedConfig;
16
+ /** The plugin API. */
17
+ pluginAPI?: RsbuildPluginAPI;
18
+ };
19
+ export type { RsbuildConfig, NormalizedConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, OutputConfig, SecurityConfig, PerformanceConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig } from '@rsbuild/shared';
@@ -12,5 +12,5 @@ var __copyProps = (to, from, except, desc) => {
12
12
  return to;
13
13
  };
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var plugin_exports = {};
16
- module.exports = __toCommonJS(plugin_exports);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "Unleash the power of Rspack with the out-of-the-box build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -58,7 +58,7 @@
58
58
  "types.d.ts"
59
59
  ],
60
60
  "dependencies": {
61
- "@rspack/core": "0.3.12",
61
+ "@rspack/core": "0.3.14",
62
62
  "core-js": "~3.32.2",
63
63
  "html-webpack-plugin": "npm:html-rspack-plugin@5.5.5",
64
64
  "http-proxy-middleware": "^2.0.1",
@@ -67,7 +67,7 @@
67
67
  "semver": "^7.5.4",
68
68
  "sirv": "^2.0.3",
69
69
  "ws": "^8.2.0",
70
- "@rsbuild/shared": "0.0.23"
70
+ "@rsbuild/shared": "0.0.25"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/node": "^16",
@@ -1,16 +0,0 @@
1
- import type { Context as BaseContext, RsbuildConfig, NormalizedConfig } from '@rsbuild/shared';
2
- import type { Hooks } from '../core/initHooks';
3
- import type { RsbuildPluginAPI } from './plugin';
4
- /** The inner context. */
5
- export type Context = BaseContext & {
6
- /** All hooks. */
7
- hooks: Readonly<Hooks>;
8
- /** Current Rsbuild config. */
9
- config: Readonly<RsbuildConfig>;
10
- /** The original Rsbuild config passed from the createRsbuild method. */
11
- originalConfig: Readonly<RsbuildConfig>;
12
- /** The normalized Rsbuild config. */
13
- normalizedConfig?: NormalizedConfig;
14
- /** The plugin API. */
15
- pluginAPI?: RsbuildPluginAPI;
16
- };
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var context_exports = {};
16
- module.exports = __toCommonJS(context_exports);
@@ -1,3 +0,0 @@
1
- export * from './plugin';
2
- export * from './context';
3
- export type { RsbuildConfig, NormalizedConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, OutputConfig, SecurityConfig, PerformanceConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig } from '@rsbuild/shared';
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var types_exports = {};
17
- module.exports = __toCommonJS(types_exports);
18
- __reExport(types_exports, require("./plugin"), module.exports);
19
- __reExport(types_exports, require("./context"), module.exports);
20
- // Annotate the CommonJS export names for ESM import in node:
21
- 0 && (module.exports = {
22
- ...require("./plugin"),
23
- ...require("./context")
24
- });
@@ -1,4 +0,0 @@
1
- import type { RsbuildConfig, NormalizedConfig, DefaultRsbuildPluginAPI, RsbuildPlugin as BaseRsbuildPlugin } from '@rsbuild/shared';
2
- import type { RspackConfig, RspackCompiler, RspackMultiCompiler } from '@rsbuild/shared';
3
- export interface RsbuildPluginAPI extends DefaultRsbuildPluginAPI<RsbuildConfig, NormalizedConfig, RspackConfig, RspackCompiler | RspackMultiCompiler> {}
4
- export type RsbuildPlugin<T = RsbuildPluginAPI> = BaseRsbuildPlugin<T>;