@winner-fed/bundler-rsbuild 0.9.2-alpha.4 → 0.9.3
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/config/config.d.ts +5 -3
- package/dist/config/config.js +20 -3
- package/dist/config/outConfig.d.ts +2 -1
- package/dist/config/outConfig.js +2 -0
- package/dist/config/performanceConfig.d.ts +0 -1
- package/dist/config/toolsConfig.d.ts +6 -5
- package/dist/config/toolsConfig.js +7 -2
- package/dist/constants.d.ts +0 -8
- package/dist/constants.js +2 -13
- package/dist/dev.d.ts +5 -0
- package/dist/dev.js +8 -0
- package/dist/index.d.ts +2 -1
- package/package.json +4 -3
package/dist/config/config.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { RsbuildConfig } from '@rsbuild/core';
|
|
2
|
-
import { Env, IConfig } from '../types';
|
|
1
|
+
import { ModifyRsbuildConfigFn, RsbuildConfig } from '@rsbuild/core';
|
|
2
|
+
import { Env, IBabelPlugin, IConfig } from '../types';
|
|
3
3
|
export interface IOpts {
|
|
4
4
|
cwd?: string;
|
|
5
5
|
env?: Env;
|
|
6
6
|
entry?: Record<string, string>;
|
|
7
|
-
modifyRsbuildConfig?:
|
|
7
|
+
modifyRsbuildConfig?: ModifyRsbuildConfigFn;
|
|
8
8
|
userConfig?: IConfig;
|
|
9
|
+
extraBabelPlugins?: IBabelPlugin[];
|
|
10
|
+
extraBabelPresets?: IBabelPlugin[];
|
|
9
11
|
}
|
|
10
12
|
export declare function getRsbuildConfig(opts: IOpts): Promise<RsbuildConfig>;
|
package/dist/config/config.js
CHANGED
|
@@ -32,10 +32,12 @@ __export(config_exports, {
|
|
|
32
32
|
getRsbuildConfig: () => getRsbuildConfig
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(config_exports);
|
|
35
|
+
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
35
36
|
var import_plugin_less = require("@rsbuild/plugin-less");
|
|
36
37
|
var import_plugin_node_polyfill = require("@rsbuild/plugin-node-polyfill");
|
|
37
38
|
var import_plugin_sass = require("@rsbuild/plugin-sass");
|
|
38
39
|
var import_plugin_type_check = require("@rsbuild/plugin-type-check");
|
|
40
|
+
var import_types = require("../types");
|
|
39
41
|
var import_devConfig = require("./devConfig");
|
|
40
42
|
var import_outConfig = require("./outConfig");
|
|
41
43
|
var import_performanceConfig = require("./performanceConfig");
|
|
@@ -43,8 +45,9 @@ var import_serverConfig = require("./serverConfig");
|
|
|
43
45
|
var import_sourceConfig = require("./sourceConfig");
|
|
44
46
|
var import_toolsConfig = require("./toolsConfig");
|
|
45
47
|
async function getRsbuildConfig(opts) {
|
|
46
|
-
var _a;
|
|
48
|
+
var _a, _b;
|
|
47
49
|
const { userConfig } = opts;
|
|
50
|
+
const isDev = opts.env === import_types.Env.development;
|
|
48
51
|
const sourceConfig = (0, import_sourceConfig.getSourceConfig)(opts);
|
|
49
52
|
const outConfig = (0, import_outConfig.getOutConfig)(opts);
|
|
50
53
|
const htmlConfig = {};
|
|
@@ -73,6 +76,14 @@ async function getRsbuildConfig(opts) {
|
|
|
73
76
|
}),
|
|
74
77
|
(0, import_plugin_sass.pluginSass)({
|
|
75
78
|
...userConfig == null ? void 0 : userConfig.sassLoader
|
|
79
|
+
}),
|
|
80
|
+
(0, import_plugin_babel.pluginBabel)({
|
|
81
|
+
include: /\.(?:jsx|tsx|js)$/,
|
|
82
|
+
exclude: /[\\/]node_modules[\\/]/,
|
|
83
|
+
babelLoaderOptions: (config, { addPlugins, addPresets }) => {
|
|
84
|
+
addPlugins([...(userConfig == null ? void 0 : userConfig.extraBabelPlugins) || []]);
|
|
85
|
+
addPresets([...(userConfig == null ? void 0 : userConfig.extraBabelPresets) || []]);
|
|
86
|
+
}
|
|
76
87
|
})
|
|
77
88
|
]
|
|
78
89
|
};
|
|
@@ -83,12 +94,18 @@ async function getRsbuildConfig(opts) {
|
|
|
83
94
|
rsbuildConfig.plugins || (rsbuildConfig.plugins = []);
|
|
84
95
|
rsbuildConfig.plugins.push(
|
|
85
96
|
(0, import_plugin_type_check.pluginTypeCheck)({
|
|
86
|
-
|
|
97
|
+
// 只在开发环境生效
|
|
98
|
+
enable: ((_b = userConfig == null ? void 0 : userConfig.forkTSChecker.typescript) == null ? void 0 : _b.enable) && isDev,
|
|
99
|
+
forkTsCheckerOptions: {
|
|
100
|
+
typescript: {
|
|
101
|
+
typescriptPath: userConfig.forkTSChecker.typescript.typescriptPath
|
|
102
|
+
}
|
|
103
|
+
}
|
|
87
104
|
})
|
|
88
105
|
);
|
|
89
106
|
}
|
|
90
107
|
if (opts.modifyRsbuildConfig) {
|
|
91
|
-
|
|
108
|
+
await opts.modifyRsbuildConfig(rsbuildConfig, {
|
|
92
109
|
env: opts.env
|
|
93
110
|
});
|
|
94
111
|
}
|
|
@@ -11,12 +11,13 @@ export declare function getOutConfig(opts: IOpts): {
|
|
|
11
11
|
copy: string[] | import("../types").ICopy[];
|
|
12
12
|
cssModules: any;
|
|
13
13
|
dataUriLimit: number;
|
|
14
|
+
injectStyles: boolean;
|
|
14
15
|
distPath: {
|
|
15
16
|
root: string;
|
|
16
17
|
js: string;
|
|
17
18
|
css: string;
|
|
18
19
|
};
|
|
19
|
-
externals:
|
|
20
|
+
externals: Record<string, string> | never[];
|
|
20
21
|
filenameHash: boolean;
|
|
21
22
|
manifest: boolean | undefined;
|
|
22
23
|
minify: boolean;
|
package/dist/config/outConfig.js
CHANGED
|
@@ -47,6 +47,7 @@ function getOutConfig(opts) {
|
|
|
47
47
|
const disableCompress = process.env.COMPRESS === "none";
|
|
48
48
|
const minify = !(isDev || disableCompress);
|
|
49
49
|
const legalComments = "none";
|
|
50
|
+
userConfig.targets || (userConfig.targets = import_constants.DEFAULT_BROWSER_TARGETS);
|
|
50
51
|
if (typeof externals === "string") {
|
|
51
52
|
throw new Error("externals string is not supported");
|
|
52
53
|
}
|
|
@@ -56,6 +57,7 @@ function getOutConfig(opts) {
|
|
|
56
57
|
copy,
|
|
57
58
|
cssModules: cssLoaderModules,
|
|
58
59
|
dataUriLimit: inlineLimit,
|
|
60
|
+
injectStyles: isDev,
|
|
59
61
|
distPath: {
|
|
60
62
|
root: outputPath,
|
|
61
63
|
js: "",
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* @LastEditTime: 2024-07-22 16:57
|
|
6
6
|
* @Description: toolsConfig
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import type { ModifyBundlerChainUtils, ModifyRspackConfigUtils, RspackChain } from '@rsbuild/core';
|
|
9
|
+
import { RspackConfig } from '@rsbuild/core/dist-types/types';
|
|
10
|
+
import { Env, IConfig } from '../types';
|
|
10
11
|
interface IOpts {
|
|
11
12
|
cwd: string;
|
|
12
13
|
port?: number;
|
|
@@ -15,12 +16,12 @@ interface IOpts {
|
|
|
15
16
|
userConfig: IConfig;
|
|
16
17
|
env: Env;
|
|
17
18
|
modifyRspackConfig?: Function;
|
|
19
|
+
modifyBundlerChain?: Function;
|
|
18
20
|
}
|
|
19
21
|
export declare function getToolsConfig(opts: IOpts): {
|
|
20
22
|
autoprefixer: any;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}) => Promise<any>;
|
|
23
|
+
bundlerChain: (chain: RspackChain, utils: ModifyBundlerChainUtils) => Promise<void>;
|
|
24
|
+
rspack: (config: RspackConfig, utils: ModifyRspackConfigUtils) => Promise<RspackConfig>;
|
|
24
25
|
cssLoader: any;
|
|
25
26
|
postcss: () => {
|
|
26
27
|
postcssOptions: any;
|
|
@@ -26,9 +26,14 @@ function getToolsConfig(opts) {
|
|
|
26
26
|
const { userConfig } = opts;
|
|
27
27
|
return {
|
|
28
28
|
autoprefixer: userConfig.autoprefixer || {},
|
|
29
|
-
|
|
29
|
+
bundlerChain: async (chain, utils) => {
|
|
30
|
+
if (opts.modifyBundlerChain) {
|
|
31
|
+
await opts.modifyBundlerChain(chain, utils);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
rspack: async (config, utils) => {
|
|
30
35
|
if (opts.modifyRspackConfig) {
|
|
31
|
-
config = await opts.modifyRspackConfig(config,
|
|
36
|
+
config = await opts.modifyRspackConfig(config, utils);
|
|
32
37
|
}
|
|
33
38
|
return config;
|
|
34
39
|
},
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
export declare const DEFAULT_DEVTOOL = "cheap-module-source-map";
|
|
2
2
|
export declare const DEFAULT_OUTPUT_PATH = "dist";
|
|
3
|
-
export declare enum MESSAGE_TYPE {
|
|
4
|
-
ok = "ok",
|
|
5
|
-
warnings = "warnings",
|
|
6
|
-
errors = "errors",
|
|
7
|
-
hash = "hash",
|
|
8
|
-
stillOk = "still-ok",
|
|
9
|
-
invalid = "invalid"
|
|
10
|
-
}
|
|
11
3
|
export declare const DEFAULT_BROWSER_TARGETS: {
|
|
12
4
|
chrome: number;
|
|
13
5
|
};
|
package/dist/constants.js
CHANGED
|
@@ -22,21 +22,11 @@ __export(constants_exports, {
|
|
|
22
22
|
DEFAULT_BROWSER_TARGETS: () => DEFAULT_BROWSER_TARGETS,
|
|
23
23
|
DEFAULT_DEVTOOL: () => DEFAULT_DEVTOOL,
|
|
24
24
|
DEFAULT_ESBUILD_TARGET_KEYS: () => DEFAULT_ESBUILD_TARGET_KEYS,
|
|
25
|
-
DEFAULT_OUTPUT_PATH: () => DEFAULT_OUTPUT_PATH
|
|
26
|
-
MESSAGE_TYPE: () => MESSAGE_TYPE
|
|
25
|
+
DEFAULT_OUTPUT_PATH: () => DEFAULT_OUTPUT_PATH
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(constants_exports);
|
|
29
28
|
var DEFAULT_DEVTOOL = "cheap-module-source-map";
|
|
30
29
|
var DEFAULT_OUTPUT_PATH = "dist";
|
|
31
|
-
var MESSAGE_TYPE = /* @__PURE__ */ ((MESSAGE_TYPE2) => {
|
|
32
|
-
MESSAGE_TYPE2["ok"] = "ok";
|
|
33
|
-
MESSAGE_TYPE2["warnings"] = "warnings";
|
|
34
|
-
MESSAGE_TYPE2["errors"] = "errors";
|
|
35
|
-
MESSAGE_TYPE2["hash"] = "hash";
|
|
36
|
-
MESSAGE_TYPE2["stillOk"] = "still-ok";
|
|
37
|
-
MESSAGE_TYPE2["invalid"] = "invalid";
|
|
38
|
-
return MESSAGE_TYPE2;
|
|
39
|
-
})(MESSAGE_TYPE || {});
|
|
40
30
|
var DEFAULT_BROWSER_TARGETS = {
|
|
41
31
|
chrome: 80
|
|
42
32
|
};
|
|
@@ -51,6 +41,5 @@ var DEFAULT_ESBUILD_TARGET_KEYS = [
|
|
|
51
41
|
DEFAULT_BROWSER_TARGETS,
|
|
52
42
|
DEFAULT_DEVTOOL,
|
|
53
43
|
DEFAULT_ESBUILD_TARGET_KEYS,
|
|
54
|
-
DEFAULT_OUTPUT_PATH
|
|
55
|
-
MESSAGE_TYPE
|
|
44
|
+
DEFAULT_OUTPUT_PATH
|
|
56
45
|
});
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { IBabelPlugin } from '@winner-fed/bundler-vite/dist/types';
|
|
1
2
|
import { IConfig } from './types';
|
|
2
3
|
type IOpts = {
|
|
4
|
+
beforeBabelPlugins?: any[];
|
|
5
|
+
beforeBabelPresets?: any[];
|
|
3
6
|
afterMiddlewares?: any[];
|
|
4
7
|
beforeMiddlewares?: any[];
|
|
5
8
|
onDevCompileDone?: Function;
|
|
@@ -10,6 +13,8 @@ type IOpts = {
|
|
|
10
13
|
rootDir?: string;
|
|
11
14
|
config: IConfig;
|
|
12
15
|
entry: Record<string, string>;
|
|
16
|
+
extraBabelPlugins?: IBabelPlugin[];
|
|
17
|
+
extraBabelPresets?: IBabelPlugin[];
|
|
13
18
|
onBeforeMiddleware?: Function;
|
|
14
19
|
};
|
|
15
20
|
export declare function dev(opts: IOpts): Promise<void>;
|
package/dist/dev.js
CHANGED
|
@@ -46,6 +46,14 @@ async function dev(opts) {
|
|
|
46
46
|
const rsbuildConfig = await configModule.getRsbuildConfig({
|
|
47
47
|
userConfig: opts.config,
|
|
48
48
|
env: import_types.Env.development,
|
|
49
|
+
extraBabelPlugins: [
|
|
50
|
+
...opts.beforeBabelPlugins || [],
|
|
51
|
+
...opts.extraBabelPlugins || []
|
|
52
|
+
],
|
|
53
|
+
extraBabelPresets: [
|
|
54
|
+
...opts.beforeBabelPresets || [],
|
|
55
|
+
...opts.extraBabelPresets || []
|
|
56
|
+
],
|
|
49
57
|
...opts
|
|
50
58
|
});
|
|
51
59
|
await (0, import_server.createServer)({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { ConsoleType, RsbuildConfig, Rspack } from '@rsbuild/core';
|
|
1
|
+
export type { ConsoleType, ModifyBundlerChainUtils, ModifyRspackConfigUtils, RsbuildConfig, Rspack, RspackChain, } from '@rsbuild/core';
|
|
2
|
+
export type { ModifyRsbuildConfigUtils } from '@rsbuild/core/dist-types/types';
|
|
2
3
|
export * from './build';
|
|
3
4
|
export * from './config/config';
|
|
4
5
|
export * from './constants';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/bundler-rsbuild",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "@winner-fed/bundler-rsbuild",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@rsbuild/core": "1.0.1-beta.4",
|
|
13
|
+
"@rsbuild/plugin-babel": "1.0.1-beta.4",
|
|
13
14
|
"@rsbuild/plugin-less": "1.0.1-beta.4",
|
|
14
15
|
"@rsbuild/plugin-node-polyfill": "1.0.3",
|
|
15
16
|
"@rsbuild/plugin-sass": "1.0.1-beta.4",
|
|
16
17
|
"@rsbuild/plugin-type-check": "1.0.1-beta.4",
|
|
17
|
-
"@winner-fed/bundler-utils": "0.9.
|
|
18
|
-
"@winner-fed/utils": "0.9.
|
|
18
|
+
"@winner-fed/bundler-utils": "0.9.3",
|
|
19
|
+
"@winner-fed/utils": "0.9.3"
|
|
19
20
|
},
|
|
20
21
|
"publishConfig": {
|
|
21
22
|
"access": "public"
|