@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/dist/schema.js ADDED
@@ -0,0 +1,198 @@
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/schema.ts
20
+ var schema_exports = {};
21
+ __export(schema_exports, {
22
+ getSchemas: () => getSchemas
23
+ });
24
+ module.exports = __toCommonJS(schema_exports);
25
+ var import_types = require("./types");
26
+ var devTool = [
27
+ "cheap-source-map",
28
+ "cheap-module-source-map",
29
+ "eval",
30
+ "eval-source-map",
31
+ "eval-cheap-source-map",
32
+ "eval-cheap-module-source-map",
33
+ "eval-nosources-cheap-source-map",
34
+ "eval-nosources-cheap-module-source-map",
35
+ "eval-nosources-source-map",
36
+ "source-map",
37
+ "hidden-source-map",
38
+ "hidden-nosources-cheap-source-map",
39
+ "hidden-nosources-cheap-module-source-map",
40
+ "hidden-nosources-source-map",
41
+ "hidden-cheap-source-map",
42
+ "hidden-cheap-module-source-map",
43
+ "inline-source-map",
44
+ "inline-cheap-source-map",
45
+ "inline-cheap-module-source-map",
46
+ "inline-nosources-cheap-source-map",
47
+ "inline-nosources-cheap-module-source-map",
48
+ "inline-nosources-source-map",
49
+ "nosources-source-map",
50
+ "nosources-cheap-source-map",
51
+ "nosources-cheap-module-source-map"
52
+ ];
53
+ function getSchemas() {
54
+ return {
55
+ alias: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
56
+ '路径别名配置,用于简化模块导入路径。key 为别名,value 为实际路径。例如:{"@": "./src", "components": "./src/components"},可以使用 "@/utils" 代替 "./src/utils"'
57
+ ),
58
+ autoCSSModules: ({ zod }) => zod.boolean().describe(
59
+ "是否自动开启 CSS Modules,当设置为 true 时,所有 .css 文件都会被当作 CSS Modules 处理,无需通过 .module.css 命名"
60
+ ),
61
+ autoprefixer: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
62
+ "Autoprefixer 插件配置,用于自动添加 CSS 浏览器前缀。可配置目标浏览器、网格布局支持等选项,确保 CSS 在不同浏览器中的兼容性"
63
+ ),
64
+ copy: ({ zod }) => zod.array(
65
+ zod.union([
66
+ zod.object({
67
+ from: zod.string().describe("源文件或目录的路径,支持 glob 模式匹配"),
68
+ to: zod.string().describe("目标文件或目录的路径,相对于输出目录")
69
+ }).describe("文件复制配置对象,指定源路径和目标路径"),
70
+ zod.string().describe(
71
+ "简化的文件复制配置,直接指定源路径,目标路径为输出目录"
72
+ )
73
+ ])
74
+ ).describe(
75
+ "文件复制配置数组,用于将静态资源从源目录复制到构建输出目录。支持 glob 模式和目录复制"
76
+ ),
77
+ cssLoader: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
78
+ "css-loader 的配置选项,用于处理 CSS 文件的导入和解析。可配置 modules、sourceMap、importLoaders 等选项"
79
+ ),
80
+ cssLoaderModules: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
81
+ "CSS Modules 模式下 css-loader 的特定配置选项,如类名生成模式、本地标识符命名等"
82
+ ),
83
+ cssMinifier: ({ zod }) => zod.enum([import_types.CSSMinifier.parcelCSS, import_types.CSSMinifier.none]).describe(
84
+ "CSS 压缩器选择,Rsbuild 支持 parcelCSS(现代高性能压缩器)或 none(不压缩)。parcelCSS 基于 Rust 实现,提供极速的 CSS 压缩和转换"
85
+ ),
86
+ cssMinifierOptions: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
87
+ "CSS 压缩器的详细配置选项,根据选择的压缩器类型传递相应的配置参数"
88
+ ),
89
+ define: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
90
+ '全局常量定义,在编译时替换代码中的变量。例如:{"process.env.NODE_ENV": "production"},常用于环境变量注入'
91
+ ),
92
+ devtool: ({ zod }) => zod.union([zod.enum(devTool), zod.boolean()]).describe(
93
+ "Source Map 生成配置,控制调试信息的生成方式。可选择不同的 source map 类型或 boolean 值控制是否生成"
94
+ ),
95
+ externals: ({ zod }) => zod.union([
96
+ zod.record(zod.string(), zod.any()).describe("外部依赖映射对象,key 为模块名,value 为全局变量名"),
97
+ zod.string().describe("单个外部依赖的模块名"),
98
+ zod.function().describe("动态判断外部依赖的函数,接收模块请求并返回外部化配置")
99
+ ]).describe(
100
+ "外部依赖配置,指定哪些模块不打包到 bundle 中,而是在运行时从外部获取(如 CDN)"
101
+ ),
102
+ extraBabelExcludes: ({ zod }) => zod.array(zod.union([zod.string(), zod.instanceof(RegExp)])).describe(
103
+ "额外的 Babel 编译排除规则,用于指定不需要 Babel 处理的文件或目录,支持字符串和正则表达式"
104
+ ),
105
+ extraBabelIncludes: ({ zod }) => zod.array(zod.union([zod.string(), zod.instanceof(RegExp)])).describe(
106
+ "额外的 Babel 编译包含规则,用于指定需要强制使用 Babel 处理的文件,通常用于处理 node_modules 中的特定包"
107
+ ),
108
+ extraBabelPlugins: ({ zod }) => zod.array(zod.union([zod.string(), zod.array(zod.any())])).describe(
109
+ "额外的 Babel 插件配置,可以是插件名称字符串或包含插件名和选项的数组。用于扩展 Babel 编译功能"
110
+ ),
111
+ extraBabelPresets: ({ zod }) => zod.array(zod.union([zod.string(), zod.array(zod.any())])).describe(
112
+ "额外的 Babel 预设配置,可以是预设名称字符串或包含预设名和选项的数组。预设包含一组相关的插件"
113
+ ),
114
+ extraPostCSSPlugins: ({ zod }) => zod.array(zod.any()).describe(
115
+ "额外的 PostCSS 插件配置数组,用于扩展 CSS 处理功能。可添加自定义的 PostCSS 插件实例或配置"
116
+ ),
117
+ forkTSChecker: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
118
+ "fork-ts-checker-webpack-plugin 配置,用于在独立进程中进行 TypeScript 类型检查,避免阻塞主构建流程"
119
+ ),
120
+ ftpOptions: ({ zod }) => zod.object({}).describe(
121
+ "FTP 部署选项配置,用于配置自动部署到 FTP 服务器的相关参数,如服务器地址、认证信息、上传路径等"
122
+ ),
123
+ hash: ({ zod }) => zod.boolean().describe(
124
+ "是否在生成的文件名中添加哈希值,用于缓存控制。启用后文件名会包含内容哈希,文件变更时哈希也会变更"
125
+ ),
126
+ https: ({ zod }) => zod.object({
127
+ cert: zod.string().describe("SSL 证书文件路径,用于 HTTPS 服务"),
128
+ hosts: zod.array(zod.string()).describe("允许访问的主机名列表,用于多域名支持"),
129
+ http2: zod.boolean().describe("是否启用 HTTP/2 协议支持"),
130
+ key: zod.string().describe("SSL 私钥文件路径,与证书配对使用")
131
+ }).deepPartial().describe(
132
+ "HTTPS 开发服务器配置,用于启用 SSL/TLS 加密连接的本地开发环境"
133
+ ),
134
+ ignoreMomentLocale: ({ zod }) => zod.boolean().describe(
135
+ "是否忽略 Moment.js 的本地化文件,启用后可显著减少包体积。如需要本地化功能,应手动导入所需的 locale 文件"
136
+ ),
137
+ inlineLimit: ({ zod }) => zod.number().describe(
138
+ "资源内联大小限制(字节),小于此大小的图片、字体等资源会被转为 base64 内联到代码中,减少 HTTP 请求"
139
+ ),
140
+ jsMinifier: ({ zod }) => zod.enum([import_types.JSMinifier.swc, import_types.JSMinifier.none]).describe(
141
+ "JavaScript 压缩器选择,Rsbuild 支持 SWC(基于 Rust 的高性能压缩器)或 none(不压缩)。SWC 提供比传统工具更快的压缩速度"
142
+ ),
143
+ jsMinifierOptions: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
144
+ "JavaScript 压缩器的详细配置选项,根据选择的压缩器类型传递相应的配置参数"
145
+ ),
146
+ lessLoader: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
147
+ "Less 预处理器配置选项,用于编译 .less 文件。可配置变量、函数、导入路径等"
148
+ ),
149
+ manifest: ({ zod }) => zod.union([
150
+ zod.boolean().describe(
151
+ "是否生成资源清单文件,true 为生成默认清单,false 为不生成"
152
+ ),
153
+ zod.string().describe("自定义资源清单文件的名称或路径")
154
+ ]).describe(
155
+ "资源清单文件生成配置,记录所有打包后的资源文件路径映射,用于服务端渲染或资源加载"
156
+ ),
157
+ outputPath: ({ zod }) => zod.string().describe(
158
+ "构建输出目录路径,所有编译后的文件将存放在此目录中。可以是相对路径或绝对路径"
159
+ ),
160
+ postcssLoader: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
161
+ "PostCSS 加载器配置,用于处理 CSS 的后处理。可配置插件、解析器选项等"
162
+ ),
163
+ proxy: ({ zod }) => zod.union([
164
+ zod.record(zod.string(), zod.any()).describe("代理配置对象,key 为路径模式,value 为代理目标配置"),
165
+ zod.array(zod.any()).describe("代理配置数组,包含多个代理规则配置对象")
166
+ ]).describe(
167
+ "开发服务器代理配置,用于将 API 请求代理到后端服务器,解决开发环境的跨域问题"
168
+ ),
169
+ publicPath: ({ zod }) => zod.string().describe(
170
+ "资源的公共路径前缀,用于指定静态资源的访问路径。可以是相对路径、绝对路径或 CDN 地址"
171
+ ),
172
+ rsbuildConfig: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
173
+ "Rsbuild 原生配置对象,直接传递给 Rsbuild 的配置选项。用于设置 Rsbuild 特有的高级配置和优化选项"
174
+ ),
175
+ sassLoader: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
176
+ "Sass/SCSS 预处理器配置选项,用于编译 .sass 和 .scss 文件。可配置变量、函数、导入路径等"
177
+ ),
178
+ styleLoader: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
179
+ "style-loader 配置选项,用于将 CSS 注入到页面的 <style> 标签中。可配置注入位置、属性等"
180
+ ),
181
+ targets: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
182
+ '目标浏览器配置,用于确定代码编译的兼容性目标。支持 browserslist 查询语法,如 "last 2 versions"'
183
+ ),
184
+ theme: ({ zod }) => zod.record(zod.string(), zod.any()).describe(
185
+ "主题变量配置,用于自定义 UI 组件库的主题样式。通常与 antd、element-ui 等组件库配合使用"
186
+ ),
187
+ writeToDisk: ({ zod }) => zod.boolean().describe(
188
+ "是否将开发模式下的文件写入磁盘,默认为 false(仅内存中)。启用后可以在文件系统中查看构建结果"
189
+ ),
190
+ zipOptions: ({ zod }) => zod.object({}).describe(
191
+ "ZIP 压缩配置选项,用于将构建产物打包成 ZIP 文件,便于部署和分发。可配置压缩级别、包含文件等"
192
+ )
193
+ };
194
+ }
195
+ // Annotate the CommonJS export names for ESM import in node:
196
+ 0 && (module.exports = {
197
+ getSchemas
198
+ });
@@ -0,0 +1,16 @@
1
+ import { RsbuildConfig } from '@rsbuild/core';
2
+ import { IConfig } from '../types';
3
+ interface IOpts {
4
+ cwd: string;
5
+ port?: number;
6
+ host?: string;
7
+ ip?: string;
8
+ userConfig: IConfig;
9
+ rsbuildConfig: RsbuildConfig;
10
+ beforeMiddlewares?: any[];
11
+ afterMiddlewares?: any[];
12
+ onDevCompileDone?: Function;
13
+ onBeforeMiddleware?: Function;
14
+ }
15
+ export declare function createServer(opts: IOpts): Promise<any>;
16
+ export {};
@@ -0,0 +1,100 @@
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/server/server.ts
30
+ var server_exports = {};
31
+ __export(server_exports, {
32
+ createServer: () => createServer
33
+ });
34
+ module.exports = __toCommonJS(server_exports);
35
+ var import_core = require("@rsbuild/core");
36
+ var import_bundler_utils = require("@winner-fed/bundler-utils");
37
+ var import_express = __toESM(require("@winner-fed/bundler-utils/compiled/express"));
38
+ var import_utils = require("@winner-fed/utils");
39
+ var import_types = require("../types");
40
+ async function createServer(opts) {
41
+ const { userConfig, rsbuildConfig } = opts;
42
+ const rsbuild = await (0, import_core.createRsbuild)({
43
+ cwd: opts.cwd,
44
+ rsbuildConfig
45
+ });
46
+ const app = (0, import_express.default)();
47
+ const rsbuildServer = await rsbuild.createDevServer();
48
+ if (opts.onBeforeMiddleware) {
49
+ opts.onBeforeMiddleware(app);
50
+ }
51
+ (opts.beforeMiddlewares || []).forEach((m) => app.use(m));
52
+ app.use(rsbuildServer.middlewares);
53
+ if (userConfig.proxy) {
54
+ (0, import_bundler_utils.createProxy)(userConfig.proxy, app);
55
+ }
56
+ (opts.afterMiddlewares || []).forEach((m) => {
57
+ app.use(m.toString().includes("{ compiler }") ? m({}) : m);
58
+ });
59
+ const httpServer = app.listen(rsbuildServer.port, async () => {
60
+ await rsbuildServer.afterListen();
61
+ const protocol = userConfig.https ? "https:" : "http:";
62
+ const banner = (0, import_utils.getDevBanner)(protocol, opts.host, rsbuildServer.port);
63
+ console.log(banner.before);
64
+ import_utils.logger.ready(banner.main);
65
+ console.log(banner.after);
66
+ });
67
+ rsbuildServer.connectWebSocket({ server: httpServer });
68
+ const { inspectConfig } = userConfig;
69
+ if (inspectConfig) {
70
+ await rsbuild.inspectConfig({
71
+ mode: import_types.Env.development,
72
+ verbose: inspectConfig.verbose || false,
73
+ outputPath: inspectConfig.outputPath,
74
+ writeToDisk: true
75
+ });
76
+ }
77
+ rsbuild.onAfterDevCompile((params) => {
78
+ var _a, _b, _c, _d, _e, _f, _g, _h;
79
+ if (opts.onDevCompileDone) {
80
+ const s = ((_a = params.stats) == null ? void 0 : _a.stats) ? (_c = (_b = params.stats) == null ? void 0 : _b.stats) == null ? void 0 : _c[0] : params.stats;
81
+ (_h = opts.onDevCompileDone) == null ? void 0 : _h.call(opts, {
82
+ isFirstCompile: params.isFirstCompile,
83
+ stats: params.stats,
84
+ time: ((_d = s.compilation) == null ? void 0 : _d.endTime) && ((_e = s.compilation) == null ? void 0 : _e.startTime) ? ((_f = s.compilation) == null ? void 0 : _f.endTime) - ((_g = s.compilation) == null ? void 0 : _g.startTime) : void 0
85
+ });
86
+ }
87
+ });
88
+ import_utils.logger.info(`Building with rsbuild2 for ${process.env.NODE_ENV}...
89
+ `);
90
+ return {
91
+ close: async () => {
92
+ await rsbuildServer.close();
93
+ httpServer.close();
94
+ }
95
+ };
96
+ }
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ createServer
100
+ });
@@ -0,0 +1,96 @@
1
+ /**
2
+ * types
3
+ * @Author: liwb (lwbhtml@163.com)
4
+ * @Date: 2026-09-18 09:15
5
+ * @LastEditTime: 2026-09-18 09:15
6
+ * @Description: types(bundler-rsbuild2,基于 Rsbuild 2.x)
7
+ */
8
+ import { RsbuildConfig, Rspack, rspack } from '@rsbuild/core';
9
+ import type { HttpsServerOptions, ProxyOptions } from '@winner-fed/bundler-utils';
10
+ export declare enum Env {
11
+ development = "development",
12
+ production = "production"
13
+ }
14
+ export type MultiStats = Rspack.MultiStats;
15
+ export type Stats = Rspack.Stats;
16
+ export type StatsCompilation = Rspack.StatsCompilation;
17
+ export declare enum JSMinifier {
18
+ swc = "swc",
19
+ none = "none"
20
+ }
21
+ export declare enum CSSMinifier {
22
+ parcelCSS = "parcelCSS",
23
+ none = "none"
24
+ }
25
+ export interface ICopy {
26
+ from: string;
27
+ to: string;
28
+ }
29
+ export type IBabelPlugin = Function | string | [string, {
30
+ [key: string]: any;
31
+ }] | [string, {
32
+ [key: string]: any;
33
+ }, string];
34
+ export interface IConfig {
35
+ alias?: Record<string, string>;
36
+ autoCSSModules?: boolean;
37
+ autoprefixer?: any;
38
+ copy?: ICopy[] | string[];
39
+ define?: {
40
+ [key: string]: any;
41
+ };
42
+ modifyRsbuildConfig?: {
43
+ (memo: RsbuildConfig, args: {
44
+ env: Env;
45
+ rspack: typeof rspack;
46
+ }): RsbuildConfig | Promise<RsbuildConfig>;
47
+ };
48
+ rsbuildConfig?: RsbuildConfig;
49
+ modifyRspackConfig?: Function;
50
+ modifyBundlerChain?: Function;
51
+ externals?: Record<string, string>;
52
+ extraBabelPlugins?: IBabelPlugin[];
53
+ extraBabelPresets?: IBabelPlugin[];
54
+ extraBabelIncludes?: Array<string | RegExp>;
55
+ extraBabelExcludes?: Array<string | RegExp>;
56
+ extraPostCSSPlugins?: any[];
57
+ hash?: boolean;
58
+ manifest?: boolean;
59
+ jsMinifier?: JSMinifier | boolean;
60
+ jsMinifierOptions?: {
61
+ [key: string]: any;
62
+ };
63
+ lessLoader?: {
64
+ [key: string]: any;
65
+ };
66
+ sassLoader?: {
67
+ [key: string]: any;
68
+ };
69
+ legacy?: {
70
+ [key: string]: any;
71
+ } | boolean;
72
+ outputPath?: string;
73
+ polyfill?: {
74
+ imports: string[];
75
+ };
76
+ postcssLoader?: {
77
+ [key: string]: any;
78
+ };
79
+ proxy?: {
80
+ [key: string]: ProxyOptions;
81
+ };
82
+ publicPath?: string;
83
+ targets?: {
84
+ [key: string]: any;
85
+ };
86
+ https?: HttpsServerOptions;
87
+ writeToDisk?: boolean;
88
+ /** rsbuild2 feature 配置(对应 .winrc 中 rsbuild2 字段) */
89
+ rsbuild2?: {
90
+ removeConsole?: boolean | string[];
91
+ lightningcssLoader?: boolean | Record<string, any> | ((config: any) => Record<string, any> | undefined);
92
+ /** 透传原生 Rsbuild 2.x 配置 */
93
+ config?: RsbuildConfig;
94
+ };
95
+ [key: string]: any;
96
+ }
package/dist/types.js ADDED
@@ -0,0 +1,47 @@
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/types.ts
20
+ var types_exports = {};
21
+ __export(types_exports, {
22
+ CSSMinifier: () => CSSMinifier,
23
+ Env: () => Env,
24
+ JSMinifier: () => JSMinifier
25
+ });
26
+ module.exports = __toCommonJS(types_exports);
27
+ var Env = /* @__PURE__ */ ((Env2) => {
28
+ Env2["development"] = "development";
29
+ Env2["production"] = "production";
30
+ return Env2;
31
+ })(Env || {});
32
+ var JSMinifier = /* @__PURE__ */ ((JSMinifier2) => {
33
+ JSMinifier2["swc"] = "swc";
34
+ JSMinifier2["none"] = "none";
35
+ return JSMinifier2;
36
+ })(JSMinifier || {});
37
+ var CSSMinifier = /* @__PURE__ */ ((CSSMinifier2) => {
38
+ CSSMinifier2["parcelCSS"] = "parcelCSS";
39
+ CSSMinifier2["none"] = "none";
40
+ return CSSMinifier2;
41
+ })(CSSMinifier || {});
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ CSSMinifier,
45
+ Env,
46
+ JSMinifier
47
+ });
@@ -0,0 +1 @@
1
+ export declare function checkConfig(opts: any): void;
@@ -0,0 +1,66 @@
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/utils/checkConfig.ts
30
+ var checkConfig_exports = {};
31
+ __export(checkConfig_exports, {
32
+ checkConfig: () => checkConfig
33
+ });
34
+ module.exports = __toCommonJS(checkConfig_exports);
35
+ var import_utils = require("@winner-fed/utils");
36
+ var import_assert = __toESM(require("assert"));
37
+ function checkConfig(opts) {
38
+ const unsupportedKeys = [
39
+ // 不支持 MFSU
40
+ "mfsu",
41
+ // 暂不支持多 entry
42
+ "mpa"
43
+ ];
44
+ unsupportedKeys.forEach((key) => {
45
+ (0, import_assert.default)(!opts.config[key], `${key} is not supported in Rsbuild2 bundler`);
46
+ });
47
+ const warningKeys = [];
48
+ if (opts.config.mdx && Object.keys(opts.config.mdx).length) {
49
+ warningKeys.push("mdx");
50
+ }
51
+ if (warningKeys.length) {
52
+ console.warn(
53
+ import_utils.chalk.yellow(
54
+ `
55
+ Rsbuild2 bundler does not support the following options:
56
+ - ${warningKeys.join("\n - ")}
57
+
58
+ `
59
+ )
60
+ );
61
+ }
62
+ }
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ checkConfig
66
+ });
@@ -0,0 +1,6 @@
1
+ interface IOpts {
2
+ targets: Record<string, any>;
3
+ }
4
+ export declare function getBrowsersList({ targets }: IOpts): any;
5
+ export declare function getBrowserlist(targets: Record<string, string | boolean>): string | string[];
6
+ export {};
@@ -0,0 +1,40 @@
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/utils/getBrowsersList.ts
20
+ var getBrowsersList_exports = {};
21
+ __export(getBrowsersList_exports, {
22
+ getBrowserlist: () => getBrowserlist,
23
+ getBrowsersList: () => getBrowsersList
24
+ });
25
+ module.exports = __toCommonJS(getBrowsersList_exports);
26
+ function getBrowsersList({ targets = {} }) {
27
+ return (targets == null ? void 0 : targets.browsers) || Object.keys(targets).map((key) => {
28
+ return `${key} >= ${targets[key] === true ? "0" : targets[key]}`;
29
+ });
30
+ }
31
+ function getBrowserlist(targets) {
32
+ return typeof targets.browsers === "string" ? targets.browser : Object.keys(targets).map(
33
+ (key) => `${key} >= ${targets[key] === true ? "0" : targets[key]}`
34
+ );
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ getBrowserlist,
39
+ getBrowsersList
40
+ });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@winner-fed/bundler-rsbuild2",
3
+ "version": "0.19.0-alpha.0",
4
+ "description": "@winner-fed/bundler-rsbuild2, based on Rsbuild 2.x (Rspack 2.x). External bundler for winjs, not a dependency of preset-win.",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "bundler-rsbuild2": "bin/bundler-rsbuild2.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "bin"
14
+ ],
15
+ "dependencies": {
16
+ "@rsbuild/core": "2.2.8",
17
+ "@rsbuild/plugin-babel": "2.1.0",
18
+ "@rsbuild/plugin-less": "2.0.1",
19
+ "@rsbuild/plugin-node-polyfill": "1.4.6",
20
+ "@rsbuild/plugin-sass": "2.0.1",
21
+ "@rsbuild/plugin-stylus": "2.0.1",
22
+ "@rsbuild/plugin-type-check": "1.6.0",
23
+ "@winner-fed/bundler-utils": "0.19.0-alpha.0",
24
+ "@winner-fed/utils": "0.19.0-alpha.0"
25
+ },
26
+ "engines": {
27
+ "node": ">=20.19"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "win-scripts father build",
34
+ "build:deps": "win-scripts bundleDeps",
35
+ "dev": "win-scripts father dev"
36
+ }
37
+ }