@rsbuild/core 0.7.0-beta.2 → 0.7.0-beta.4

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 (181) hide show
  1. package/bin/rsbuild.js +4 -3
  2. package/compiled/css-loader/index.js +20 -20
  3. package/compiled/less-loader/index.js +8 -8
  4. package/compiled/postcss-loader/index.js +11 -11
  5. package/compiled/rspack-manifest-plugin/index.js +4 -4
  6. package/dist/client/{hmr.mjs → hmr.js} +2 -3
  7. package/dist/client/{overlay.mjs → overlay.js} +2 -6
  8. package/dist/{rspack/ignoreCssLoader.js → ignoreCssLoader.cjs} +2 -0
  9. package/dist/index.cjs +7201 -0
  10. package/dist/index.js +7435 -40
  11. package/dist/{rspack/transformLoader.js → transformLoader.cjs} +2 -0
  12. package/dist/{rspack/transformRawLoader.js → transformRawLoader.cjs} +37 -13
  13. package/{dist → dist-types}/constants.d.ts +3 -0
  14. package/dist-types/helpers.d.ts +32 -0
  15. package/{dist → dist-types}/index.d.ts +6 -0
  16. package/{dist → dist-types}/internal.d.ts +5 -2
  17. package/dist-types/package.json +1 -0
  18. package/{dist → dist-types}/plugins/html.d.ts +2 -1
  19. package/{dist → dist-types}/plugins/index.d.ts +1 -0
  20. package/dist-types/plugins/minimize.d.ts +12 -0
  21. package/{dist/provider → dist-types}/plugins/progress.d.ts +1 -1
  22. package/{dist/provider → dist-types}/plugins/resolve.d.ts +1 -1
  23. package/{dist/provider → dist-types}/plugins/rspackProfile.d.ts +1 -1
  24. package/{dist/provider → dist-types}/plugins/swc.d.ts +1 -1
  25. package/dist-types/server/devMiddleware.d.ts +18 -0
  26. package/{dist → dist-types}/server/helper.d.ts +11 -0
  27. package/package.json +14 -16
  28. package/dist/cli/commands.js +0 -110
  29. package/dist/cli/init.js +0 -101
  30. package/dist/cli/prepare.js +0 -43
  31. package/dist/client/format.js +0 -72
  32. package/dist/config.js +0 -306
  33. package/dist/constants.js +0 -40
  34. package/dist/createContext.js +0 -116
  35. package/dist/createRsbuild.js +0 -103
  36. package/dist/initHooks.js +0 -82
  37. package/dist/initPlugins.js +0 -152
  38. package/dist/internal.js +0 -79
  39. package/dist/loadEnv.js +0 -93
  40. package/dist/mergeConfig.js +0 -80
  41. package/dist/pluginHelper.js +0 -66
  42. package/dist/pluginManager.js +0 -180
  43. package/dist/plugins/asset.js +0 -101
  44. package/dist/plugins/basic.js +0 -77
  45. package/dist/plugins/bundleAnalyzer.js +0 -69
  46. package/dist/plugins/cache.js +0 -116
  47. package/dist/plugins/cleanOutput.js +0 -68
  48. package/dist/plugins/css.js +0 -257
  49. package/dist/plugins/define.js +0 -45
  50. package/dist/plugins/entry.js +0 -76
  51. package/dist/plugins/externals.js +0 -48
  52. package/dist/plugins/fileSize.js +0 -199
  53. package/dist/plugins/html.js +0 -327
  54. package/dist/plugins/index.js +0 -66
  55. package/dist/plugins/inlineChunk.js +0 -69
  56. package/dist/plugins/less.js +0 -107
  57. package/dist/plugins/manifest.js +0 -142
  58. package/dist/plugins/moduleFederation.js +0 -125
  59. package/dist/plugins/moment.js +0 -43
  60. package/dist/plugins/nodeAddons.js +0 -74
  61. package/dist/plugins/output.js +0 -63
  62. package/dist/plugins/performance.js +0 -56
  63. package/dist/plugins/resourceHints.js +0 -86
  64. package/dist/plugins/rsdoctor.js +0 -81
  65. package/dist/plugins/sass.js +0 -154
  66. package/dist/plugins/server.js +0 -59
  67. package/dist/plugins/splitChunks.js +0 -236
  68. package/dist/plugins/startUrl.js +0 -146
  69. package/dist/plugins/target.js +0 -54
  70. package/dist/plugins/wasm.js +0 -51
  71. package/dist/provider/build.js +0 -84
  72. package/dist/provider/createCompiler.js +0 -143
  73. package/dist/provider/initConfigs.js +0 -92
  74. package/dist/provider/inspectConfig.js +0 -85
  75. package/dist/provider/plugins/minimize.d.ts +0 -2
  76. package/dist/provider/plugins/minimize.js +0 -49
  77. package/dist/provider/plugins/progress.js +0 -49
  78. package/dist/provider/plugins/resolve.js +0 -42
  79. package/dist/provider/plugins/rspackProfile.js +0 -112
  80. package/dist/provider/plugins/swc.js +0 -152
  81. package/dist/provider/plugins/transition.d.ts +0 -5
  82. package/dist/provider/plugins/transition.js +0 -35
  83. package/dist/provider/provider.js +0 -158
  84. package/dist/provider/rspackConfig.js +0 -144
  85. package/dist/provider/shared.d.ts +0 -16
  86. package/dist/provider/shared.js +0 -215
  87. package/dist/rspack/HtmlAppIconPlugin.js +0 -98
  88. package/dist/rspack/HtmlBasicPlugin.js +0 -229
  89. package/dist/rspack/InlineChunkHtmlPlugin.js +0 -196
  90. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +0 -173
  91. package/dist/rspack/preload/helpers/determineAsValue.js +0 -83
  92. package/dist/rspack/preload/helpers/doesChunkBelongToHtml.js +0 -77
  93. package/dist/rspack/preload/helpers/extractChunks.js +0 -83
  94. package/dist/rspack/preload/helpers/index.js +0 -28
  95. package/dist/rspack/preload/helpers/type.js +0 -16
  96. package/dist/server/compilerDevMiddleware.js +0 -129
  97. package/dist/server/devMiddleware.d.ts +0 -3
  98. package/dist/server/devMiddleware.js +0 -74
  99. package/dist/server/devServer.js +0 -195
  100. package/dist/server/getDevMiddlewares.js +0 -177
  101. package/dist/server/helper.js +0 -237
  102. package/dist/server/httpServer.js +0 -45
  103. package/dist/server/index.js +0 -31
  104. package/dist/server/middlewares.js +0 -162
  105. package/dist/server/prodServer.js +0 -196
  106. package/dist/server/proxy.js +0 -93
  107. package/dist/server/restart.js +0 -66
  108. package/dist/server/socketServer.js +0 -178
  109. package/dist/server/watchFiles.js +0 -90
  110. package/dist/types.js +0 -16
  111. /package/{dist → dist-types}/cli/commands.d.ts +0 -0
  112. /package/{dist → dist-types}/cli/init.d.ts +0 -0
  113. /package/{dist → dist-types}/cli/prepare.d.ts +0 -0
  114. /package/{dist → dist-types}/client/format.d.ts +0 -0
  115. /package/{dist → dist-types}/client/hmr.d.ts +0 -0
  116. /package/{dist → dist-types}/client/overlay.d.ts +0 -0
  117. /package/{dist → dist-types}/config.d.ts +0 -0
  118. /package/{dist → dist-types}/createContext.d.ts +0 -0
  119. /package/{dist → dist-types}/createRsbuild.d.ts +0 -0
  120. /package/{dist → dist-types}/initHooks.d.ts +0 -0
  121. /package/{dist → dist-types}/initPlugins.d.ts +0 -0
  122. /package/{dist → dist-types}/loadEnv.d.ts +0 -0
  123. /package/{dist/rspack → dist-types/loader}/ignoreCssLoader.d.ts +0 -0
  124. /package/{dist/rspack → dist-types/loader}/transformLoader.d.ts +0 -0
  125. /package/{dist/rspack → dist-types/loader}/transformRawLoader.d.ts +0 -0
  126. /package/{dist → dist-types}/mergeConfig.d.ts +0 -0
  127. /package/{dist → dist-types}/pluginHelper.d.ts +0 -0
  128. /package/{dist → dist-types}/pluginManager.d.ts +0 -0
  129. /package/{dist → dist-types}/plugins/asset.d.ts +0 -0
  130. /package/{dist → dist-types}/plugins/basic.d.ts +0 -0
  131. /package/{dist → dist-types}/plugins/bundleAnalyzer.d.ts +0 -0
  132. /package/{dist → dist-types}/plugins/cache.d.ts +0 -0
  133. /package/{dist → dist-types}/plugins/cleanOutput.d.ts +0 -0
  134. /package/{dist → dist-types}/plugins/css.d.ts +0 -0
  135. /package/{dist → dist-types}/plugins/define.d.ts +0 -0
  136. /package/{dist → dist-types}/plugins/entry.d.ts +0 -0
  137. /package/{dist → dist-types}/plugins/externals.d.ts +0 -0
  138. /package/{dist → dist-types}/plugins/fileSize.d.ts +0 -0
  139. /package/{dist → dist-types}/plugins/inlineChunk.d.ts +0 -0
  140. /package/{dist → dist-types}/plugins/less.d.ts +0 -0
  141. /package/{dist → dist-types}/plugins/manifest.d.ts +0 -0
  142. /package/{dist → dist-types}/plugins/moduleFederation.d.ts +0 -0
  143. /package/{dist → dist-types}/plugins/moment.d.ts +0 -0
  144. /package/{dist → dist-types}/plugins/nodeAddons.d.ts +0 -0
  145. /package/{dist → dist-types}/plugins/output.d.ts +0 -0
  146. /package/{dist → dist-types}/plugins/performance.d.ts +0 -0
  147. /package/{dist → dist-types}/plugins/resourceHints.d.ts +0 -0
  148. /package/{dist → dist-types}/plugins/rsdoctor.d.ts +0 -0
  149. /package/{dist → dist-types}/plugins/sass.d.ts +0 -0
  150. /package/{dist → dist-types}/plugins/server.d.ts +0 -0
  151. /package/{dist → dist-types}/plugins/splitChunks.d.ts +0 -0
  152. /package/{dist → dist-types}/plugins/startUrl.d.ts +0 -0
  153. /package/{dist → dist-types}/plugins/target.d.ts +0 -0
  154. /package/{dist → dist-types}/plugins/wasm.d.ts +0 -0
  155. /package/{dist → dist-types}/provider/build.d.ts +0 -0
  156. /package/{dist → dist-types}/provider/createCompiler.d.ts +0 -0
  157. /package/{dist → dist-types}/provider/initConfigs.d.ts +0 -0
  158. /package/{dist → dist-types}/provider/inspectConfig.d.ts +0 -0
  159. /package/{dist → dist-types}/provider/provider.d.ts +0 -0
  160. /package/{dist → dist-types}/provider/rspackConfig.d.ts +0 -0
  161. /package/{dist → dist-types}/rspack/HtmlAppIconPlugin.d.ts +0 -0
  162. /package/{dist → dist-types}/rspack/HtmlBasicPlugin.d.ts +0 -0
  163. /package/{dist → dist-types}/rspack/InlineChunkHtmlPlugin.d.ts +0 -0
  164. /package/{dist → dist-types}/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +0 -0
  165. /package/{dist → dist-types}/rspack/preload/helpers/determineAsValue.d.ts +0 -0
  166. /package/{dist → dist-types}/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +0 -0
  167. /package/{dist → dist-types}/rspack/preload/helpers/extractChunks.d.ts +0 -0
  168. /package/{dist → dist-types}/rspack/preload/helpers/index.d.ts +0 -0
  169. /package/{dist → dist-types}/rspack/preload/helpers/type.d.ts +0 -0
  170. /package/{dist → dist-types}/server/compilerDevMiddleware.d.ts +0 -0
  171. /package/{dist → dist-types}/server/devServer.d.ts +0 -0
  172. /package/{dist → dist-types}/server/getDevMiddlewares.d.ts +0 -0
  173. /package/{dist → dist-types}/server/httpServer.d.ts +0 -0
  174. /package/{dist → dist-types}/server/index.d.ts +0 -0
  175. /package/{dist → dist-types}/server/middlewares.d.ts +0 -0
  176. /package/{dist → dist-types}/server/prodServer.d.ts +0 -0
  177. /package/{dist → dist-types}/server/proxy.d.ts +0 -0
  178. /package/{dist → dist-types}/server/restart.d.ts +0 -0
  179. /package/{dist → dist-types}/server/socketServer.d.ts +0 -0
  180. /package/{dist → dist-types}/server/watchFiles.d.ts +0 -0
  181. /package/{dist → dist-types}/types.d.ts +0 -0
@@ -16,6 +16,8 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/loader/transformLoader.ts
19
21
  var transformLoader_exports = {};
20
22
  __export(transformLoader_exports, {
21
23
  default: () => transform
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,24 +15,50 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/loader/transformRawLoader.ts
29
21
  var transformRawLoader_exports = {};
30
22
  __export(transformRawLoader_exports, {
31
23
  default: () => transformRawLoader_default,
32
24
  raw: () => raw
33
25
  });
34
26
  module.exports = __toCommonJS(transformRawLoader_exports);
35
- var import_transformLoader = __toESM(require("./transformLoader"));
36
- var transformRawLoader_default = import_transformLoader.default;
37
- const raw = true;
27
+
28
+ // src/loader/transformLoader.ts
29
+ async function transform(source, map) {
30
+ const callback = this.async();
31
+ const bypass = () => callback(null, source, map);
32
+ const transformId = this.getOptions().id;
33
+ if (!transformId) {
34
+ return bypass();
35
+ }
36
+ const transform2 = this._compiler?.__rsbuildTransformer?.[transformId];
37
+ if (!transform2) {
38
+ return bypass();
39
+ }
40
+ const result = await transform2({
41
+ code: source,
42
+ resource: this.resource,
43
+ resourcePath: this.resourcePath,
44
+ resourceQuery: this.resourceQuery,
45
+ addDependency: this.addDependency,
46
+ emitFile: this.emitFile
47
+ });
48
+ if (result === null || result === void 0) {
49
+ return bypass();
50
+ }
51
+ if (typeof result === "string") {
52
+ return callback(null, result, map);
53
+ }
54
+ const useMap = map !== void 0 && map !== null;
55
+ const finalMap = result.map ?? map;
56
+ callback(null, result.code, useMap ? finalMap : void 0);
57
+ }
58
+
59
+ // src/loader/transformRawLoader.ts
60
+ var transformRawLoader_default = transform;
61
+ var raw = true;
38
62
  // Annotate the CommonJS export names for ESM import in node:
39
63
  0 && (module.exports = {
40
64
  raw
@@ -3,3 +3,6 @@ export declare const PLUGIN_CSS_NAME = "rsbuild:css";
3
3
  export declare const PLUGIN_LESS_NAME = "rsbuild:less";
4
4
  export declare const PLUGIN_SASS_NAME = "rsbuild:sass";
5
5
  export declare const PLUGIN_STYLUS_NAME = "rsbuild:stylus";
6
+ export declare const LOADER_PATH: string;
7
+ export declare const STATIC_PATH: string;
8
+ export declare const COMPILED_PATH: string;
@@ -0,0 +1,32 @@
1
+ import { type BundlerChain, type MultiStats, type Stats, type StatsError, isMultiCompiler } from '@rsbuild/shared';
2
+ import type { StatsCompilation, StatsValue } from '@rspack/core';
3
+ export declare const rspackMinVersion = "0.6.2";
4
+ export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
5
+ export declare const getCompiledPath: (packageName: string) => string;
6
+ export declare const getAllStatsErrors: (statsData: StatsCompilation) => StatsError[] | undefined;
7
+ export declare const getAllStatsWarnings: (statsData: StatsCompilation) => StatsError[] | undefined;
8
+ export declare function getStatsOptions(compiler: Parameters<typeof isMultiCompiler>[0]): StatsValue | undefined;
9
+ export declare function formatStats(stats: Stats | MultiStats, options?: StatsValue): {
10
+ message: string;
11
+ level: string;
12
+ } | {
13
+ message?: undefined;
14
+ level?: undefined;
15
+ };
16
+ export declare const formatPublicPath: (publicPath: string, withSlash?: boolean) => string;
17
+ export declare const getPublicPathFromChain: (chain: BundlerChain, withSlash?: boolean) => string;
18
+ /**
19
+ * ensure absolute file path.
20
+ * @param base - Base path to resolve relative from.
21
+ * @param filePath - Absolute or relative file path.
22
+ * @returns Resolved absolute file path.
23
+ */
24
+ export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
25
+ export declare const isFileSync: (filePath: string) => boolean | undefined;
26
+ /**
27
+ * Find first already exists file.
28
+ * @param files - Absolute file paths with extension.
29
+ * @returns The file path if exists, or false if no file exists.
30
+ */
31
+ export declare const findExists: (files: string[]) => string | false;
32
+ export declare function isFileExists(file: string): Promise<boolean>;
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { rspack } from '@rspack/core';
6
6
  import type * as Rspack from '@rspack/core';
7
+ import * as __internalHelper from './internal';
7
8
  export { loadEnv } from './loadEnv';
8
9
  export { createRsbuild } from './createRsbuild';
9
10
  export { loadConfig, defineConfig } from './config';
@@ -15,3 +16,8 @@ export { mergeRsbuildConfig } from './mergeConfig';
15
16
  export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, PLUGIN_SASS_NAME, PLUGIN_LESS_NAME, PLUGIN_STYLUS_NAME, } from './constants';
16
17
  export type { RsbuildConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, ServerConfig, OutputConfig, SecurityConfig, PerformanceConfig, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedServerConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig, NormalizedModuleFederationConfig, RsbuildPlugin, RsbuildPlugins, RsbuildPluginAPI, } from './types';
17
18
  export type { RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildContext, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnCloseDevServerFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyRsbuildConfigFn, TransformFn, TransformHandler, } from '@rsbuild/shared';
19
+ export {
20
+ /**
21
+ * @private
22
+ */
23
+ __internalHelper, };
@@ -3,6 +3,8 @@
3
3
  * Some internal methods of Rsbuild.
4
4
  * Please do not use them in your Rsbuild project or plugins.
5
5
  */
6
+ export { runCli } from './cli/commands';
7
+ export { prepareCli } from './cli/prepare';
6
8
  export { rspackProvider } from './provider/provider';
7
9
  export { createContext, createPublicContext } from './createContext';
8
10
  export { initPlugins, createPluginManager } from './pluginManager';
@@ -12,9 +14,10 @@ export { applyCSSRule } from './plugins/css';
12
14
  export { getPluginAPI } from './initPlugins';
13
15
  export type { InternalContext } from './types';
14
16
  export { setHTMLPlugin, getHTMLPlugin, setCssExtractPlugin, } from './pluginHelper';
15
- export { formatStats, getStatsOptions } from './provider/shared';
17
+ export { formatStats, getStatsOptions } from './helpers';
16
18
  export { getChainUtils } from './provider/rspackConfig';
17
- export { applySwcDecoratorConfig } from './provider/plugins/swc';
19
+ export { applySwcDecoratorConfig } from './plugins/swc';
20
+ export { getSwcMinimizerOptions, parseMinifyOptions } from './plugins/minimize';
18
21
  export { getDevMiddleware } from './server/devMiddleware';
19
22
  export { createDevServer, startProdServer } from './server';
20
23
  export { plugins } from './plugins';
@@ -0,0 +1 @@
1
+ {"//":"This file is for making TypeScript work with moduleResolution node16+.","version":"1.0.0"}
@@ -1,5 +1,6 @@
1
1
  import type { HtmlConfig, ModifyHTMLTagsFn, NormalizedConfig } from '@rsbuild/shared';
2
2
  import type { RsbuildPlugin } from '../types';
3
+ export declare function getHtmlMinifyOptions(isProd: boolean, config: NormalizedConfig): Promise<any>;
3
4
  export declare function getTitle(entryName: string, config: NormalizedConfig): string;
4
5
  export declare function getInject(entryName: string, config: NormalizedConfig): import("@rsbuild/shared").ScriptInject;
5
6
  export declare function getTemplate(entryName: string, config: NormalizedConfig, rootPath: string): Promise<{
@@ -12,4 +13,4 @@ export declare function getFavicon(entryName: string, config: {
12
13
  export declare function getMetaTags(entryName: string, config: {
13
14
  html: HtmlConfig;
14
15
  }, templateContent?: string): import("@rsbuild/shared").MetaOptions;
15
- export declare const pluginHtml: (modifyTagsFn: ModifyHTMLTagsFn) => RsbuildPlugin;
16
+ export declare const pluginHtml: (modifyTagsFn?: ModifyHTMLTagsFn) => RsbuildPlugin;
@@ -3,6 +3,7 @@ export declare const plugins: {
3
3
  basic: () => Promise<import("@rsbuild/shared").RsbuildPlugin>;
4
4
  html: (modifyTagsFn: ModifyHTMLTagsFn) => Promise<import("@rsbuild/shared").RsbuildPlugin>;
5
5
  output: () => Promise<import("@rsbuild/shared").RsbuildPlugin>;
6
+ resolve: () => Promise<import("@rsbuild/shared").RsbuildPlugin>;
6
7
  cleanOutput: () => Promise<import("@rsbuild/shared").RsbuildPlugin>;
7
8
  startUrl: () => Promise<import("@rsbuild/shared").RsbuildPlugin>;
8
9
  fileSize: () => Promise<import("@rsbuild/shared").RsbuildPlugin>;
@@ -0,0 +1,12 @@
1
+ import { type HTMLPluginOptions, type NormalizedConfig } from '@rsbuild/shared';
2
+ import type { SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
3
+ import type { RsbuildPlugin } from '../types';
4
+ export declare const getSwcMinimizerOptions: (config: NormalizedConfig) => SwcJsMinimizerRspackPluginOptions;
5
+ export declare const parseMinifyOptions: (config: NormalizedConfig, isProd?: boolean) => {
6
+ minifyJs: boolean;
7
+ minifyCss: boolean;
8
+ minifyHtml: boolean;
9
+ jsOptions?: SwcJsMinimizerRspackPluginOptions;
10
+ htmlOptions?: HTMLPluginOptions['minify'];
11
+ };
12
+ 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 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,5 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import inspector from 'node:inspector';
3
- import type { RsbuildPlugin } from '../../types';
3
+ import type { RsbuildPlugin } from '../types';
4
4
  export declare const stopProfiler: (output: string, profileSession?: inspector.Session) => void;
5
5
  export declare const pluginRspackProfile: () => RsbuildPlugin;
@@ -1,5 +1,5 @@
1
1
  import type { SwcLoaderOptions } from '@rspack/core';
2
- import type { NormalizedConfig, RsbuildPlugin } from '../../types';
2
+ import type { NormalizedConfig, RsbuildPlugin } from '../types';
3
3
  /**
4
4
  * Provide some swc configs of rspack
5
5
  */
@@ -0,0 +1,18 @@
1
+ import { type CompilerTapFn, type DevMiddleware } from '@rsbuild/shared';
2
+ import type { Compiler, MultiCompiler } from '@rspack/core';
3
+ type ServerCallbacks = {
4
+ onInvalid: () => void;
5
+ onDone: (stats: any) => void;
6
+ };
7
+ export declare const setupServerHooks: (compiler: {
8
+ options: {
9
+ target?: Compiler['options']['target'];
10
+ };
11
+ hooks: {
12
+ compile: CompilerTapFn<ServerCallbacks['onInvalid']>;
13
+ invalid: CompilerTapFn<ServerCallbacks['onInvalid']>;
14
+ done: CompilerTapFn<ServerCallbacks['onDone']>;
15
+ };
16
+ }, hookCallbacks: ServerCallbacks) => void;
17
+ export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => NonNullable<DevMiddleware>;
18
+ export {};
@@ -52,3 +52,14 @@ export declare const getDevOptions: ({ rsbuildConfig, getPortSilently, }: {
52
52
  https: boolean;
53
53
  liveReload: any;
54
54
  }>;
55
+ export declare const getUrlLabel: (url: string) => "Local: " | "Network: ";
56
+ type AddressUrl = {
57
+ label: string;
58
+ url: string;
59
+ };
60
+ export declare const getAddressUrls: ({ protocol, port, host, }: {
61
+ protocol?: string;
62
+ port: number;
63
+ host?: string;
64
+ }) => AddressUrl[];
65
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.7.0-beta.2",
3
+ "version": "0.7.0-beta.4",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -12,48 +12,46 @@
12
12
  "directory": "packages/core"
13
13
  },
14
14
  "license": "MIT",
15
- "type": "commonjs",
15
+ "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/index.d.ts",
19
- "default": "./dist/index.js"
18
+ "types": "./dist-types/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
20
21
  },
21
22
  "./client/hmr": {
22
- "types": "./dist/client/hmr/index.d.ts",
23
- "default": "./dist/client/hmr.mjs"
23
+ "types": "./dist-types/client/hmr/index.d.ts",
24
+ "default": "./dist/client/hmr.js"
24
25
  },
25
26
  "./client/overlay": {
26
- "types": "./dist/client/overlay.d.ts",
27
- "default": "./dist/client/overlay.mjs"
28
- },
29
- "./internal": {
30
- "types": "./dist/internal.d.ts",
31
- "default": "./dist/internal.js"
27
+ "types": "./dist-types/client/overlay.d.ts",
28
+ "default": "./dist/client/overlay.js"
32
29
  },
33
30
  "./types": {
34
31
  "types": "./types.d.ts"
35
32
  },
36
33
  "./package.json": "./package.json"
37
34
  },
38
- "main": "./dist/index.js",
39
- "types": "./dist/index.d.ts",
35
+ "main": "./dist/index.cjs",
36
+ "types": "./dist-types/index.d.ts",
40
37
  "bin": {
41
38
  "rsbuild": "./bin/rsbuild.js"
42
39
  },
43
40
  "files": [
44
41
  "bin",
45
42
  "dist",
43
+ "dist-types",
46
44
  "static",
47
45
  "compiled",
48
46
  "types.d.ts"
49
47
  ],
50
48
  "dependencies": {
51
- "@rspack/core": "0.6.5-canary-2456d69-20240515093621",
49
+ "@rspack/core": "0.7.0-beta.0",
52
50
  "@swc/helpers": "0.5.3",
53
51
  "core-js": "~3.36.0",
54
52
  "html-webpack-plugin": "npm:html-rspack-plugin@5.7.2",
55
53
  "postcss": "^8.4.38",
56
- "@rsbuild/shared": "0.7.0-beta.2"
54
+ "@rsbuild/shared": "0.7.0-beta.4"
57
55
  },
58
56
  "devDependencies": {
59
57
  "@types/fs-extra": "^11.0.4",
@@ -1,110 +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 __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var commands_exports = {};
20
- __export(commands_exports, {
21
- runCli: () => runCli
22
- });
23
- module.exports = __toCommonJS(commands_exports);
24
- var import_node_fs = require("node:fs");
25
- var import_node_path = require("node:path");
26
- var import_shared = require("@rsbuild/shared");
27
- var import_commander = require("../../compiled/commander/index.js");
28
- var import_init = require("./init");
29
- const applyCommonOptions = (command) => {
30
- command.option(
31
- "-c --config <config>",
32
- "specify the configuration file, can be a relative or absolute path"
33
- ).option(
34
- "--env-mode <mode>",
35
- "specify the env mode to load the `.env.[mode]` file"
36
- );
37
- };
38
- const applyServerOptions = (command) => {
39
- command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
40
- };
41
- function runCli() {
42
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.0-beta.2");
43
- const devCommand = import_commander.program.command("dev");
44
- const buildCommand = import_commander.program.command("build");
45
- const previewCommand = import_commander.program.command("preview");
46
- const inspectCommand = import_commander.program.command("inspect");
47
- [devCommand, buildCommand, previewCommand, inspectCommand].forEach(
48
- applyCommonOptions
49
- );
50
- [devCommand, previewCommand].forEach(applyServerOptions);
51
- devCommand.description("starting the dev server").action(async (options) => {
52
- try {
53
- const rsbuild = await (0, import_init.init)({ cliOptions: options });
54
- await rsbuild?.startDevServer();
55
- } catch (err) {
56
- import_shared.logger.error("Failed to start dev server.");
57
- import_shared.logger.error(err);
58
- process.exit(1);
59
- }
60
- });
61
- buildCommand.option("-w --watch", "turn on watch mode, watch for changes and rebuild").description("build the app for production").action(async (options) => {
62
- try {
63
- const rsbuild = await (0, import_init.init)({ cliOptions: options });
64
- await rsbuild?.build({
65
- watch: options.watch
66
- });
67
- } catch (err) {
68
- import_shared.logger.error("Failed to build.");
69
- import_shared.logger.error(err);
70
- process.exit(1);
71
- }
72
- });
73
- previewCommand.description("preview the production build locally").action(async (options) => {
74
- try {
75
- const rsbuild = await (0, import_init.init)({ cliOptions: options });
76
- if (rsbuild && !(0, import_node_fs.existsSync)(rsbuild.context.distPath)) {
77
- throw new Error(
78
- `The output directory ${import_shared.color.yellow(
79
- rsbuild.context.distPath
80
- )} does not exist, please build the project before previewing.`
81
- );
82
- }
83
- await rsbuild?.preview();
84
- } catch (err) {
85
- import_shared.logger.error("Failed to start preview server.");
86
- import_shared.logger.error(err);
87
- process.exit(1);
88
- }
89
- });
90
- inspectCommand.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) => {
91
- try {
92
- const rsbuild = await (0, import_init.init)({ cliOptions: options });
93
- await rsbuild?.inspectConfig({
94
- env: options.env,
95
- verbose: options.verbose,
96
- outputPath: (0, import_node_path.join)(rsbuild.context.distPath, options.output),
97
- writeToDisk: true
98
- });
99
- } catch (err) {
100
- import_shared.logger.error("Failed to inspect config.");
101
- import_shared.logger.error(err);
102
- process.exit(1);
103
- }
104
- });
105
- import_commander.program.parse();
106
- }
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
109
- runCli
110
- });
package/dist/cli/init.js DELETED
@@ -1,101 +0,0 @@
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 init_exports = {};
30
- __export(init_exports, {
31
- init: () => init
32
- });
33
- module.exports = __toCommonJS(init_exports);
34
- var import_shared = require("@rsbuild/shared");
35
- var import_config = require("../config");
36
- var import_loadEnv = require("../loadEnv");
37
- var import_restart = require("../server/restart");
38
- let commonOpts = {};
39
- async function init({
40
- cliOptions,
41
- isRestart
42
- }) {
43
- if (cliOptions) {
44
- commonOpts = cliOptions;
45
- }
46
- try {
47
- const root = process.cwd();
48
- const envs = (0, import_loadEnv.loadEnv)({
49
- cwd: root,
50
- mode: cliOptions?.envMode
51
- });
52
- if ((0, import_shared.isDev)()) {
53
- (0, import_restart.onBeforeRestartServer)(envs.cleanup);
54
- }
55
- const { content: config, filePath: configFilePath } = await (0, import_config.loadConfig)({
56
- cwd: root,
57
- path: commonOpts.config,
58
- envMode: commonOpts.envMode
59
- });
60
- const command = process.argv[2];
61
- if (command === "dev") {
62
- const files = [...envs.filePaths];
63
- if (configFilePath) {
64
- files.push(configFilePath);
65
- }
66
- (0, import_config.watchFiles)(files);
67
- }
68
- const { createRsbuild } = await Promise.resolve().then(() => __toESM(require("../createRsbuild")));
69
- config.source || (config.source = {});
70
- config.source.define = {
71
- ...envs.publicVars,
72
- ...config.source.define
73
- };
74
- if (commonOpts.open && !config.dev?.startUrl) {
75
- config.dev || (config.dev = {});
76
- config.dev.startUrl = commonOpts.open;
77
- }
78
- if (commonOpts.host) {
79
- config.server || (config.server = {});
80
- config.server.host = commonOpts.host;
81
- }
82
- if (commonOpts.port) {
83
- config.server || (config.server = {});
84
- config.server.port = commonOpts.port;
85
- }
86
- return createRsbuild({
87
- cwd: root,
88
- rsbuildConfig: config
89
- });
90
- } catch (err) {
91
- if (isRestart) {
92
- import_shared.logger.error(err);
93
- } else {
94
- throw err;
95
- }
96
- }
97
- }
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {
100
- init
101
- });
@@ -1,43 +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 __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var prepare_exports = {};
20
- __export(prepare_exports, {
21
- prepareCli: () => prepareCli
22
- });
23
- module.exports = __toCommonJS(prepare_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- function initNodeEnv() {
26
- if (!process.env.NODE_ENV) {
27
- const command = process.argv[2];
28
- process.env.NODE_ENV = ["build", "preview"].includes(command) ? "production" : "development";
29
- }
30
- }
31
- function prepareCli() {
32
- initNodeEnv();
33
- const { npm_execpath } = process.env;
34
- if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
35
- console.log();
36
- }
37
- import_shared.logger.greet(` ${`Rsbuild v${"0.7.0-beta.2"}`}
38
- `);
39
- }
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- prepareCli
43
- });
@@ -1,72 +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 __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var format_exports = {};
20
- __export(format_exports, {
21
- formatStatsMessages: () => formatStatsMessages
22
- });
23
- module.exports = __toCommonJS(format_exports);
24
- function resolveFileName(stats) {
25
- if (stats.moduleIdentifier) {
26
- const regex = /(?:\!|^)([^!]+)$/;
27
- const matched = stats.moduleIdentifier.match(regex);
28
- if (matched) {
29
- const fileName = matched.pop();
30
- if (fileName) {
31
- return `File: ${fileName}:1:1
32
- `;
33
- }
34
- }
35
- }
36
- return `File: ${stats.moduleName}
37
- `;
38
- }
39
- function formatMessage(stats) {
40
- let lines = [];
41
- let message;
42
- if (typeof stats === "object") {
43
- const fileName = resolveFileName(stats);
44
- const mainMessage = stats.message;
45
- const details = stats.details ? `
46
- Details: ${stats.details}
47
- ` : "";
48
- const stack = stats.stack ? `
49
- ${stats.stack}` : "";
50
- message = `${fileName}${mainMessage}${details}${stack}`;
51
- } else {
52
- message = stats;
53
- }
54
- lines = message.split("\n");
55
- lines = lines.filter(
56
- (line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
57
- );
58
- message = lines.join("\n");
59
- return message.trim();
60
- }
61
- function formatStatsMessages(stats) {
62
- const formattedErrors = stats.errors?.map(formatMessage) || [];
63
- const formattedWarnings = stats.warnings?.map(formatMessage) || [];
64
- return {
65
- errors: formattedErrors,
66
- warnings: formattedWarnings
67
- };
68
- }
69
- // Annotate the CommonJS export names for ESM import in node:
70
- 0 && (module.exports = {
71
- formatStatsMessages
72
- });