@winner-fed/bundler-rsbuild2 0.19.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @winner-fed/bundler-rsbuild2
2
+
3
+ 基于 [Rsbuild 2.x](https://rsbuild.rs)(Rspack 2.x)的 WinJS 构建/开发 bundler。
4
+
5
+ 与 `@winner-fed/bundler-rsbuild`(Rsbuild 1.x)相互独立、互不影响:
6
+ 本包**不内置**于 `@winner-fed/preset-win` 的依赖中,属于外置(热插拔)bundler,
7
+ 需要在业务项目中显式安装。
8
+
9
+ ## 环境要求
10
+
11
+ - Node.js `>=20.19`(Rsbuild 2.x 的硬性要求,`@rsbuild/core` 2.x 为纯 ESM 包,
12
+ 本包通过 Node 的 require(esm) 能力在 CJS 产物中加载它)
13
+
14
+ ## 使用
15
+
16
+ ```bash
17
+ pnpm add -D @winner-fed/bundler-rsbuild2
18
+ ```
19
+
20
+ ```ts
21
+ // .winrc.ts
22
+ export default defineConfig({
23
+ rsbuild2: {
24
+ removeConsole: true,
25
+ },
26
+ });
27
+ ```
28
+
29
+ 未安装本包且未配置 `rsbuild2` 的项目完全不受影响;卸载本包并移除 `rsbuild2`
30
+ 配置即可回退到其他 bundler。
31
+
32
+ ## 与 bundler-rsbuild(Rsbuild 1.x)的行为差异
33
+
34
+ | 项目 | bundler-rsbuild | bundler-rsbuild2 |
35
+ | ---- | --------------- | ---------------- |
36
+ | `analyze` 配置 / `ANALYZE` 环境变量 | `performance.bundleAnalyze` | Rsbuild 2.x 已移除该配置,输出警告并建议使用 [Rsdoctor](https://rsdoctor.dev) |
37
+ | moment locale 忽略 | `performance.removeMomentLocale` | 改由 `tools.rspack` 中的 `IgnorePlugin` 实现(默认行为一致) |
38
+ | `server.host` 默认值 | `0.0.0.0` | 显式透传 host,不受 Rsbuild 2.x 默认值(`localhost`)影响 |
39
+ | proxy `changeOrigin` 默认值 | false(http-proxy-middleware v2) | 显式补 `false`,不受 http-proxy-middleware v4 默认值(true)影响 |
40
+ | `resolve.alias` | `resolve.alias` | `resolve.alias`(v2 中 `source.alias` 已移除) |
41
+
42
+ ## 用户侧升级注意事项(Rsbuild 1.x → 2.x)
43
+
44
+ - 在 `modifyBundlerChain` 中往 `CHAIN_ID.RULE.JS` / `RULE.CSS` 挂 loader 的代码,
45
+ 需改用 `CHAIN_ID.ONE_OF.JS_MAIN` / `CSS_MAIN`(v2 的 JS/CSS 规则改用 oneOf 分支)。
46
+ - 浏览器默认目标升级(如 Chrome 87 → 107),如需旧行为请显式配置 `targets`。
47
+ - `core-js` 从默认依赖改为可选 peer 依赖,使用 `output.polyfill` 时需自行安装。
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/cli');
@@ -0,0 +1,17 @@
1
+ import { IConfig, MultiStats, Stats } from './types';
2
+ type IOpts = {
3
+ cwd: string;
4
+ rootDir?: string;
5
+ entry: Record<string, string>;
6
+ config: IConfig;
7
+ onBuildComplete?: (opts: {
8
+ err?: Error | null;
9
+ stats?: Stats | MultiStats | any;
10
+ isFirstCompile?: boolean;
11
+ time?: number;
12
+ }) => Promise<void>;
13
+ clean?: boolean;
14
+ watch?: boolean;
15
+ };
16
+ export declare function build(opts: IOpts): Promise<any>;
17
+ export {};
package/dist/build.js ADDED
@@ -0,0 +1,107 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/build.ts
30
+ var build_exports = {};
31
+ __export(build_exports, {
32
+ build: () => build
33
+ });
34
+ module.exports = __toCommonJS(build_exports);
35
+ var import_core = require("@rsbuild/core");
36
+ var import_utils = require("@winner-fed/utils");
37
+ var import_assert = __toESM(require("assert"));
38
+ var import_types = require("./types");
39
+ var import_checkConfig = require("./utils/checkConfig");
40
+ var configModule = (0, import_utils.importLazy)(
41
+ require.resolve("./config/config")
42
+ );
43
+ var statsJson = {};
44
+ async function build(opts) {
45
+ var _a, _b, _c;
46
+ (0, import_assert.default)(opts, "opts should be supplied");
47
+ (0, import_checkConfig.checkConfig)(opts);
48
+ const { cwd, onBuildComplete, config } = opts;
49
+ const rsbuildConfig = await configModule.getRsbuild2Config({
50
+ userConfig: opts.config,
51
+ env: import_types.Env.production,
52
+ extraBabelIncludes: (_a = opts.config) == null ? void 0 : _a.extraBabelIncludes,
53
+ extraBabelExcludes: (_b = opts.config) == null ? void 0 : _b.extraBabelExcludes,
54
+ ...opts
55
+ });
56
+ const rsbuild = await (0, import_core.createRsbuild)({
57
+ cwd,
58
+ rsbuildConfig
59
+ });
60
+ try {
61
+ rsbuild.onAfterBuild((params) => {
62
+ var _a2, _b2, _c2;
63
+ const s = ((_a2 = params.stats) == null ? void 0 : _a2.stats) ? (_c2 = (_b2 = params.stats) == null ? void 0 : _b2.stats) == null ? void 0 : _c2[0] : params.stats;
64
+ statsJson = s == null ? void 0 : s.toJson({ all: true, assets: true });
65
+ });
66
+ await rsbuild.build({
67
+ watch: false
68
+ });
69
+ } catch (e) {
70
+ console.error(e == null ? void 0 : e.message);
71
+ throw new Error("Build with rsbuild2 failed.");
72
+ }
73
+ const { inspectConfig } = config;
74
+ if (inspectConfig) {
75
+ await rsbuild.inspectConfig({
76
+ mode: import_types.Env.production,
77
+ verbose: inspectConfig.verbose || false,
78
+ outputPath: inspectConfig.outputPath,
79
+ writeToDisk: true
80
+ });
81
+ }
82
+ const stats = {
83
+ compilation: {
84
+ ...statsJson,
85
+ // convert assets to [key: value] for compilation data
86
+ assets: (_c = statsJson == null ? void 0 : statsJson.assets) == null ? void 0 : _c.reduce(
87
+ (acc, asset) => ({
88
+ ...acc,
89
+ [asset.name]: { size: asset.size }
90
+ }),
91
+ {}
92
+ )
93
+ },
94
+ hasErrors: () => false
95
+ };
96
+ if (onBuildComplete) {
97
+ await onBuildComplete({
98
+ err: null,
99
+ stats
100
+ });
101
+ }
102
+ return stats;
103
+ }
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ build
107
+ });
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,92 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+
24
+ // src/cli.ts
25
+ var import_esbuild = __toESM(require("@winner-fed/bundler-utils/compiled/esbuild"));
26
+ var import_utils = require("@winner-fed/utils");
27
+ var import_assert = __toESM(require("assert"));
28
+ var import_fs = require("fs");
29
+ var import_path = require("path");
30
+ var import_build = require("./build");
31
+ var import_dev = require("./dev");
32
+ var args = (0, import_utils.yParser)(process.argv.slice(2), {});
33
+ var command = args._[0];
34
+ var cwd = process.cwd();
35
+ var entry = (0, import_utils.tryPaths)([
36
+ (0, import_path.join)(cwd, "src/index.tsx"),
37
+ (0, import_path.join)(cwd, "src/index.ts"),
38
+ (0, import_path.join)(cwd, "index.tsx"),
39
+ (0, import_path.join)(cwd, "index.ts")
40
+ ]);
41
+ var config = {};
42
+ var configFile = (0, import_path.join)(cwd, args.config || "config.ts");
43
+ import_utils.register.register({
44
+ implementor: import_esbuild.default
45
+ });
46
+ import_utils.register.clearFiles();
47
+ if ((0, import_fs.existsSync)(configFile)) {
48
+ config = require(configFile).default;
49
+ }
50
+ Object.assign(config, args);
51
+ if (command === "build") {
52
+ (async () => {
53
+ process.env.NODE_ENV = "production";
54
+ (0, import_assert.default)(entry, `Build failed: entry not found.`);
55
+ try {
56
+ await (0, import_build.build)({
57
+ config,
58
+ cwd,
59
+ entry: {
60
+ [getEntryKey(entry)]: entry
61
+ }
62
+ });
63
+ } catch (e) {
64
+ console.error(e);
65
+ }
66
+ })();
67
+ } else if (command === "dev") {
68
+ (async () => {
69
+ process.env.NODE_ENV = "development";
70
+ try {
71
+ (0, import_assert.default)(entry, `Build failed: entry not found.`);
72
+ await (0, import_dev.dev)({
73
+ config,
74
+ cwd,
75
+ port: process.env.PORT,
76
+ entry: {
77
+ [getEntryKey(entry)]: entry
78
+ }
79
+ });
80
+ } catch (e) {
81
+ console.error(e);
82
+ }
83
+ })();
84
+ } else {
85
+ error(`Unsupported command ${command}.`);
86
+ }
87
+ function error(msg) {
88
+ console.error(import_utils.chalk.red(msg));
89
+ }
90
+ function getEntryKey(path) {
91
+ return (0, import_path.basename)(path, (0, import_path.extname)(path));
92
+ }
@@ -0,0 +1,19 @@
1
+ import { RsbuildConfig, rspack } from '@rsbuild/core';
2
+ import { Env, IBabelPlugin, IConfig } from '../types';
3
+ export interface IOpts {
4
+ cwd?: string;
5
+ env?: Env;
6
+ entry?: Record<string, string>;
7
+ modifyRsbuildConfig?: {
8
+ (memo: RsbuildConfig, args: {
9
+ env: Env;
10
+ rspack: typeof rspack;
11
+ }): RsbuildConfig | Promise<RsbuildConfig>;
12
+ };
13
+ userConfig?: IConfig;
14
+ extraBabelPlugins?: IBabelPlugin[];
15
+ extraBabelIncludes?: Array<string | RegExp>;
16
+ extraBabelExcludes?: Array<string | RegExp>;
17
+ extraBabelPresets?: IBabelPlugin[];
18
+ }
19
+ export declare function getRsbuild2Config(opts: IOpts): Promise<RsbuildConfig>;
@@ -0,0 +1,148 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/config/config.ts
30
+ var config_exports = {};
31
+ __export(config_exports, {
32
+ getRsbuild2Config: () => getRsbuild2Config
33
+ });
34
+ module.exports = __toCommonJS(config_exports);
35
+ var import_core = require("@rsbuild/core");
36
+ var import_plugin_babel = require("@rsbuild/plugin-babel");
37
+ var import_plugin_less = require("@rsbuild/plugin-less");
38
+ var import_plugin_node_polyfill = require("@rsbuild/plugin-node-polyfill");
39
+ var import_plugin_sass = require("@rsbuild/plugin-sass");
40
+ var import_plugin_stylus = require("@rsbuild/plugin-stylus");
41
+ var import_plugin_type_check = require("@rsbuild/plugin-type-check");
42
+ var import_types = require("../types");
43
+ var import_devConfig = require("./devConfig");
44
+ var import_outConfig = require("./outConfig");
45
+ var import_performanceConfig = require("./performanceConfig");
46
+ var import_resolveConfig = require("./resolveConfig");
47
+ var import_serverConfig = require("./serverConfig");
48
+ var import_sourceConfig = require("./sourceConfig");
49
+ var import_toolsConfig = require("./toolsConfig");
50
+ async function getRsbuild2Config(opts) {
51
+ var _a, _b, _c;
52
+ const { userConfig = {} } = opts;
53
+ const isDev = opts.env === import_types.Env.development;
54
+ const sourceConfig = (0, import_sourceConfig.getSourceConfig)(opts);
55
+ const resolveConfig = (0, import_resolveConfig.getResolveConfig)(opts);
56
+ const outConfig = (0, import_outConfig.getOutConfig)(opts);
57
+ const htmlConfig = {};
58
+ const devConfig = (0, import_devConfig.getDevConfig)(opts);
59
+ const serverConfig = (0, import_serverConfig.getServerConfig)(opts);
60
+ const toolsConfig = (0, import_toolsConfig.getToolsConfig)(opts);
61
+ const performanceConfig = (0, import_performanceConfig.getPerformanceConfig)(opts);
62
+ const babelIncludePatterns = [
63
+ /\.(?:jsx|tsx|js)$/,
64
+ ...sourceConfig.include || []
65
+ ];
66
+ const babelExcludePatterns = [
67
+ /[\\/]node_modules[\\/]/,
68
+ ...sourceConfig.exclude || []
69
+ ];
70
+ let rsbuildConfig = {
71
+ source: sourceConfig,
72
+ resolve: resolveConfig,
73
+ output: outConfig,
74
+ html: htmlConfig,
75
+ tools: toolsConfig,
76
+ dev: devConfig,
77
+ server: serverConfig,
78
+ performance: performanceConfig,
79
+ plugins: [
80
+ (0, import_plugin_node_polyfill.pluginNodePolyfill)(),
81
+ (0, import_plugin_less.pluginLess)({
82
+ lessLoaderOptions(options) {
83
+ var _a2;
84
+ const lessOptions = (userConfig == null ? void 0 : userConfig.lessLoader) || {};
85
+ return {
86
+ ...options,
87
+ lessOptions: {
88
+ ...options.lessOptions || {},
89
+ ...lessOptions || {},
90
+ javascriptEnabled: true,
91
+ modifyVars: {
92
+ ...((_a2 = options.lessOptions) == null ? void 0 : _a2.modifyVars) || {},
93
+ ...(lessOptions == null ? void 0 : lessOptions.modifyVars) || {},
94
+ ...(userConfig == null ? void 0 : userConfig.theme) || {}
95
+ }
96
+ }
97
+ };
98
+ }
99
+ }),
100
+ (0, import_plugin_sass.pluginSass)({
101
+ sassLoaderOptions: (userConfig == null ? void 0 : userConfig.sassLoader) || {}
102
+ }),
103
+ (0, import_plugin_stylus.pluginStylus)({
104
+ stylusOptions: (userConfig == null ? void 0 : userConfig.stylusLoader) || {}
105
+ }),
106
+ (0, import_plugin_babel.pluginBabel)({
107
+ include: babelIncludePatterns,
108
+ exclude: babelExcludePatterns,
109
+ babelLoaderOptions: ({}, { addPlugins, addPresets }) => {
110
+ addPlugins([...(userConfig == null ? void 0 : userConfig.extraBabelPlugins) || []]);
111
+ addPresets([...(userConfig == null ? void 0 : userConfig.extraBabelPresets) || []]);
112
+ }
113
+ })
114
+ ]
115
+ };
116
+ if (userConfig == null ? void 0 : userConfig.forkTSChecker) {
117
+ if ((_a = userConfig == null ? void 0 : userConfig.forkTSChecker.typescript) == null ? void 0 : _a.enable) {
118
+ userConfig.forkTSChecker.typescript.typescriptPath = require.resolve("typescript");
119
+ }
120
+ rsbuildConfig.plugins || (rsbuildConfig.plugins = []);
121
+ rsbuildConfig.plugins.push(
122
+ (0, import_plugin_type_check.pluginTypeCheck)({
123
+ // 只在开发环境生效
124
+ enable: ((_b = userConfig == null ? void 0 : userConfig.forkTSChecker.typescript) == null ? void 0 : _b.enable) && isDev,
125
+ forkTsCheckerOptions: {
126
+ typescript: {
127
+ typescriptPath: userConfig.forkTSChecker.typescript.typescriptPath
128
+ }
129
+ }
130
+ })
131
+ );
132
+ }
133
+ if (opts.modifyRsbuildConfig) {
134
+ await opts.modifyRsbuildConfig(rsbuildConfig, {
135
+ env: opts.env || import_types.Env.development,
136
+ rspack: import_core.rspack
137
+ });
138
+ }
139
+ const extraRsbuildConfig = (_c = userConfig == null ? void 0 : userConfig.rsbuild2) == null ? void 0 : _c.config;
140
+ if (extraRsbuildConfig && Object.keys(extraRsbuildConfig).length) {
141
+ return (0, import_core.mergeRsbuildConfig)(rsbuildConfig, extraRsbuildConfig);
142
+ }
143
+ return rsbuildConfig;
144
+ }
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ getRsbuild2Config
148
+ });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * devConfig
3
+ * @Author: liwb (lwbhtml@163.com)
4
+ * @Date: 2026-09-18 16:36
5
+ * @LastEditTime: 2026-09-18 16:36
6
+ * @Description: devConfig
7
+ */
8
+ import { DevConfig } from '@rsbuild/core';
9
+ import { IConfig } from '../types';
10
+ interface IOpts {
11
+ userConfig: IConfig;
12
+ }
13
+ export declare function getDevConfig(opts: IOpts): DevConfig;
14
+ export {};
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/devConfig.ts
20
+ var devConfig_exports = {};
21
+ __export(devConfig_exports, {
22
+ getDevConfig: () => getDevConfig
23
+ });
24
+ module.exports = __toCommonJS(devConfig_exports);
25
+ function getDevConfig(opts) {
26
+ const { userConfig } = opts;
27
+ return {
28
+ assetPrefix: userConfig.publicPath,
29
+ writeToDisk: userConfig.writeToDisk,
30
+ hmr: process.env.HMR !== "none"
31
+ };
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ getDevConfig
36
+ });
@@ -0,0 +1,10 @@
1
+ import { OutputConfig } from '@rsbuild/core';
2
+ import { Env, IConfig } from '../types';
3
+ interface IOpts {
4
+ cwd: string;
5
+ userConfig: IConfig;
6
+ env: Env;
7
+ hash?: boolean;
8
+ }
9
+ export declare function getOutConfig(opts: IOpts): OutputConfig;
10
+ export {};
@@ -0,0 +1,108 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/outConfig.ts
20
+ var outConfig_exports = {};
21
+ __export(outConfig_exports, {
22
+ getOutConfig: () => getOutConfig
23
+ });
24
+ module.exports = __toCommonJS(outConfig_exports);
25
+ var import_path = require("path");
26
+ var import_constants = require("../constants");
27
+ var import_types = require("../types");
28
+ var import_getBrowsersList = require("../utils/getBrowsersList");
29
+ function getOutConfig(opts) {
30
+ const { userConfig } = opts;
31
+ const isDev = opts.env === import_types.Env.development;
32
+ const inlineLimit = parseInt(userConfig.inlineLimit || "10000", 10);
33
+ const useHash = !!(opts.hash || userConfig.hash && !isDev);
34
+ const devtool = isDev ? userConfig.devtool === false ? false : userConfig.devtool || import_constants.DEFAULT_DEVTOOL : userConfig.devtool;
35
+ const outputPath = (0, import_path.resolve)(
36
+ opts.cwd,
37
+ userConfig.outputPath || import_constants.DEFAULT_OUTPUT_PATH
38
+ );
39
+ const {
40
+ publicPath,
41
+ manifest,
42
+ externals = [],
43
+ copy = [],
44
+ cssLoaderModules = {},
45
+ clean = true
46
+ } = userConfig;
47
+ const disableCompress = process.env.COMPRESS === "none";
48
+ const jsMinifier = userConfig.jsMinifier || import_types.JSMinifier.swc;
49
+ const cssMinifier = userConfig.cssMinifier || import_types.CSSMinifier.parcelCSS;
50
+ let minify = !(isDev || disableCompress || jsMinifier === import_types.JSMinifier.none && cssMinifier === import_types.CSSMinifier.none);
51
+ if (!minify) {
52
+ let tempJsMinifier = {
53
+ js: true,
54
+ jsOptions: {
55
+ ...userConfig.jsMinifierOptions
56
+ }
57
+ };
58
+ if (jsMinifier === import_types.JSMinifier.none) {
59
+ tempJsMinifier.js = false;
60
+ }
61
+ let tempCssMinifier = {
62
+ css: true,
63
+ cssOptions: {
64
+ ...userConfig.cssMinifierOptions
65
+ }
66
+ };
67
+ if (cssMinifier === import_types.CSSMinifier.none) {
68
+ tempCssMinifier.css = false;
69
+ }
70
+ minify = {
71
+ ...tempJsMinifier,
72
+ ...tempCssMinifier
73
+ };
74
+ }
75
+ const legalComments = "none";
76
+ userConfig.targets || (userConfig.targets = import_constants.DEFAULT_BROWSER_TARGETS);
77
+ return {
78
+ assetPrefix: publicPath,
79
+ // 默认生产开启
80
+ cleanDistPath: isDev ? false : clean,
81
+ copy,
82
+ cssModules: cssLoaderModules,
83
+ dataUriLimit: inlineLimit,
84
+ injectStyles: isDev,
85
+ distPath: {
86
+ root: outputPath,
87
+ js: "",
88
+ jsAsync: "",
89
+ css: "",
90
+ cssAsync: ""
91
+ },
92
+ externals,
93
+ filenameHash: useHash,
94
+ manifest,
95
+ minify,
96
+ overrideBrowserslist: (0, import_getBrowsersList.getBrowsersList)({
97
+ targets: userConfig.targets
98
+ }),
99
+ sourceMap: {
100
+ js: devtool
101
+ },
102
+ legalComments
103
+ };
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ getOutConfig
108
+ });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * performanceConfig
3
+ * @Author: liwb (lwbhtml@163.com)
4
+ * @Date: 2026-09-18 17:03
5
+ * @LastEditTime: 2026-09-18 17:03
6
+ * @Description: performanceConfig(Rsbuild 2.x 已移除 performance.bundleAnalyze 与 performance.removeMomentLocale)
7
+ */
8
+ import { PerformanceConfig } from '@rsbuild/core';
9
+ import { Env, IConfig } from '../types';
10
+ interface IOpts {
11
+ cwd: string;
12
+ port?: number;
13
+ host?: string;
14
+ ip?: string;
15
+ userConfig: IConfig;
16
+ env: Env;
17
+ }
18
+ export declare function getPerformanceConfig(opts: IOpts): PerformanceConfig;
19
+ export {};
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/config/performanceConfig.ts
20
+ var performanceConfig_exports = {};
21
+ __export(performanceConfig_exports, {
22
+ getPerformanceConfig: () => getPerformanceConfig
23
+ });
24
+ module.exports = __toCommonJS(performanceConfig_exports);
25
+ var import_utils = require("@winner-fed/utils");
26
+ var import_types = require("../types");
27
+ function getPerformanceConfig(opts) {
28
+ const { userConfig } = opts;
29
+ const isDev = opts.env === import_types.Env.development;
30
+ if (userConfig.analyze || process.env.ANALYZE) {
31
+ import_utils.logger.warn(
32
+ "Rsbuild 2.x 不再支持 performance.bundleAnalyze(analyze 配置),请使用 Rsdoctor 进行构建分析:https://rsdoctor.dev"
33
+ );
34
+ }
35
+ return {
36
+ printFileSize: !isDev
37
+ };
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ getPerformanceConfig
42
+ });