@winner-fed/bundler-rsbuild 0.10.1-alpha.0 → 0.10.2-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/build.d.ts +8 -14
- package/dist/build.js +13 -19
- package/dist/config/config.js +23 -8
- package/dist/config/outConfig.js +5 -1
- package/dist/dev.d.ts +13 -8
- package/dist/dev.js +1 -1
- package/dist/server/server.js +10 -12
- package/package.json +4 -3
package/dist/build.d.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
+
import { MultiStats, Stats } from '@rsbuild/core/dist-types/types';
|
|
1
2
|
import { IConfig } from './types';
|
|
2
3
|
type IOpts = {
|
|
3
4
|
cwd: string;
|
|
4
5
|
rootDir?: string;
|
|
5
6
|
entry: Record<string, string>;
|
|
6
7
|
config: IConfig;
|
|
7
|
-
onBuildComplete?:
|
|
8
|
+
onBuildComplete?: (opts: {
|
|
9
|
+
err?: Error | null;
|
|
10
|
+
stats?: Stats | MultiStats | any;
|
|
11
|
+
isFirstCompile?: boolean;
|
|
12
|
+
time?: number;
|
|
13
|
+
}) => Promise<void>;
|
|
8
14
|
clean?: boolean;
|
|
9
15
|
watch?: boolean;
|
|
10
16
|
};
|
|
11
|
-
export declare function build(opts: IOpts): Promise<
|
|
12
|
-
compilation: {
|
|
13
|
-
assets: any;
|
|
14
|
-
constructor?: Function | undefined;
|
|
15
|
-
toString?: (() => string) | undefined;
|
|
16
|
-
toLocaleString?: (() => string) | undefined;
|
|
17
|
-
valueOf?: (() => Object) | undefined;
|
|
18
|
-
hasOwnProperty?: ((v: PropertyKey) => boolean) | undefined;
|
|
19
|
-
isPrototypeOf?: ((v: Object) => boolean) | undefined;
|
|
20
|
-
propertyIsEnumerable?: ((v: PropertyKey) => boolean) | undefined;
|
|
21
|
-
};
|
|
22
|
-
hasErrors: () => boolean;
|
|
23
|
-
}>;
|
|
17
|
+
export declare function build(opts: IOpts): Promise<any>;
|
|
24
18
|
export {};
|
package/dist/build.js
CHANGED
|
@@ -41,14 +41,6 @@ var configModule = (0, import_utils.importLazy)(
|
|
|
41
41
|
require.resolve("./config/config")
|
|
42
42
|
);
|
|
43
43
|
var statsJson = {};
|
|
44
|
-
var onBuildCompileDone = () => ({
|
|
45
|
-
name: "build-done",
|
|
46
|
-
setup(api) {
|
|
47
|
-
api.onAfterBuild(({ stats }) => {
|
|
48
|
-
statsJson = stats == null ? void 0 : stats.toJson();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
44
|
async function build(opts) {
|
|
53
45
|
var _a;
|
|
54
46
|
(0, import_assert.default)(opts, "opts should be supplied");
|
|
@@ -59,27 +51,27 @@ async function build(opts) {
|
|
|
59
51
|
env: import_types.Env.production,
|
|
60
52
|
...opts
|
|
61
53
|
});
|
|
62
|
-
rsbuildConfig.plugins || (rsbuildConfig.plugins = []);
|
|
63
|
-
rsbuildConfig.plugins.push(onBuildCompileDone());
|
|
64
54
|
const rsbuild = await (0, import_core.createRsbuild)({
|
|
65
55
|
cwd,
|
|
66
56
|
rsbuildConfig
|
|
67
57
|
});
|
|
68
58
|
try {
|
|
59
|
+
rsbuild.onAfterBuild((params) => {
|
|
60
|
+
var _a2, _b, _c;
|
|
61
|
+
const s = ((_a2 = params.stats) == null ? void 0 : _a2.stats) ? (_c = (_b = params.stats) == null ? void 0 : _b.stats) == null ? void 0 : _c[0] : params.stats;
|
|
62
|
+
statsJson = s == null ? void 0 : s.toJson();
|
|
63
|
+
});
|
|
69
64
|
await rsbuild.build({
|
|
70
|
-
mode: import_types.Env.production,
|
|
71
65
|
watch: false
|
|
72
66
|
});
|
|
73
67
|
} catch (e) {
|
|
74
68
|
console.error(e == null ? void 0 : e.message);
|
|
75
|
-
|
|
76
|
-
err.stack = null;
|
|
77
|
-
throw err;
|
|
69
|
+
throw new Error("Build with rsbuild failed.");
|
|
78
70
|
}
|
|
79
71
|
const { inspectConfig } = config;
|
|
80
72
|
if (inspectConfig) {
|
|
81
73
|
await rsbuild.inspectConfig({
|
|
82
|
-
|
|
74
|
+
mode: import_types.Env.production,
|
|
83
75
|
verbose: inspectConfig.verbose || false,
|
|
84
76
|
outputPath: inspectConfig.outputPath,
|
|
85
77
|
writeToDisk: true
|
|
@@ -99,10 +91,12 @@ async function build(opts) {
|
|
|
99
91
|
},
|
|
100
92
|
hasErrors: () => false
|
|
101
93
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
if (onBuildComplete) {
|
|
95
|
+
await onBuildComplete({
|
|
96
|
+
err: null,
|
|
97
|
+
stats
|
|
98
|
+
});
|
|
99
|
+
}
|
|
106
100
|
return stats;
|
|
107
101
|
}
|
|
108
102
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/config/config.js
CHANGED
|
@@ -36,6 +36,7 @@ var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
|
36
36
|
var import_plugin_less = require("@rsbuild/plugin-less");
|
|
37
37
|
var import_plugin_node_polyfill = require("@rsbuild/plugin-node-polyfill");
|
|
38
38
|
var import_plugin_sass = require("@rsbuild/plugin-sass");
|
|
39
|
+
var import_plugin_stylus = require("@rsbuild/plugin-stylus");
|
|
39
40
|
var import_plugin_type_check = require("@rsbuild/plugin-type-check");
|
|
40
41
|
var import_types = require("../types");
|
|
41
42
|
var import_devConfig = require("./devConfig");
|
|
@@ -66,21 +67,35 @@ async function getRsbuildConfig(opts) {
|
|
|
66
67
|
plugins: [
|
|
67
68
|
(0, import_plugin_node_polyfill.pluginNodePolyfill)(),
|
|
68
69
|
(0, import_plugin_less.pluginLess)({
|
|
69
|
-
lessLoaderOptions
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
...
|
|
74
|
-
|
|
70
|
+
lessLoaderOptions(options) {
|
|
71
|
+
var _a2, _b2;
|
|
72
|
+
const lessLoaderOptions = (userConfig == null ? void 0 : userConfig.lessLoader) || {};
|
|
73
|
+
return {
|
|
74
|
+
...options,
|
|
75
|
+
...lessLoaderOptions,
|
|
76
|
+
lessOptions: {
|
|
77
|
+
...options.lessOptions || {},
|
|
78
|
+
...(lessLoaderOptions == null ? void 0 : lessLoaderOptions.lessOptions) || {},
|
|
79
|
+
javascriptEnabled: true,
|
|
80
|
+
modifyVars: {
|
|
81
|
+
...((_a2 = options.lessOptions) == null ? void 0 : _a2.modifyVars) || {},
|
|
82
|
+
...((_b2 = lessLoaderOptions == null ? void 0 : lessLoaderOptions.lessOptions) == null ? void 0 : _b2.modifyVars) || {},
|
|
83
|
+
...(userConfig == null ? void 0 : userConfig.theme) || {}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
75
87
|
}
|
|
76
88
|
}),
|
|
77
89
|
(0, import_plugin_sass.pluginSass)({
|
|
78
|
-
|
|
90
|
+
sassLoaderOptions: (userConfig == null ? void 0 : userConfig.sassLoader) || {}
|
|
91
|
+
}),
|
|
92
|
+
(0, import_plugin_stylus.pluginStylus)({
|
|
93
|
+
stylusOptions: (userConfig == null ? void 0 : userConfig.stylusLoader) || {}
|
|
79
94
|
}),
|
|
80
95
|
(0, import_plugin_babel.pluginBabel)({
|
|
81
96
|
include: /\.(?:jsx|tsx|js)$/,
|
|
82
97
|
exclude: /[\\/]node_modules[\\/]/,
|
|
83
|
-
babelLoaderOptions: (
|
|
98
|
+
babelLoaderOptions: ({}, { addPlugins, addPresets }) => {
|
|
84
99
|
addPlugins([...(userConfig == null ? void 0 : userConfig.extraBabelPlugins) || []]);
|
|
85
100
|
addPresets([...(userConfig == null ? void 0 : userConfig.extraBabelPresets) || []]);
|
|
86
101
|
}
|
package/dist/config/outConfig.js
CHANGED
|
@@ -27,6 +27,7 @@ var import_constants = require("../constants");
|
|
|
27
27
|
var import_types = require("../types");
|
|
28
28
|
var import_getBrowsersList = require("../utils/getBrowsersList");
|
|
29
29
|
function getOutConfig(opts) {
|
|
30
|
+
var _a;
|
|
30
31
|
const { userConfig } = opts;
|
|
31
32
|
const isDev = opts.env === import_types.Env.development;
|
|
32
33
|
const inlineLimit = parseInt(userConfig.inlineLimit || "10000", 10);
|
|
@@ -79,7 +80,10 @@ function getOutConfig(opts) {
|
|
|
79
80
|
// 默认生产开启
|
|
80
81
|
cleanDistPath: isDev ? false : clean,
|
|
81
82
|
copy,
|
|
82
|
-
cssModules:
|
|
83
|
+
cssModules: {
|
|
84
|
+
...cssLoaderModules,
|
|
85
|
+
auto: userConfig.autoCSSModules ? () => true : ((_a = userConfig == null ? void 0 : userConfig.cssLoaderModules) == null ? void 0 : _a.auto) ?? true
|
|
86
|
+
},
|
|
83
87
|
dataUriLimit: inlineLimit,
|
|
84
88
|
injectStyles: isDev,
|
|
85
89
|
distPath: {
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { MaybePromise, MultiStats, Stats } from '@rsbuild/core/dist-types/types';
|
|
2
|
+
import { Express, RequestHandler } from '@winner-fed/bundler-utils/compiled/express';
|
|
3
|
+
import { IBabelPlugin, IConfig } from './types';
|
|
3
4
|
type IOpts = {
|
|
4
|
-
beforeBabelPlugins?:
|
|
5
|
-
beforeBabelPresets?:
|
|
6
|
-
afterMiddlewares?:
|
|
7
|
-
beforeMiddlewares?:
|
|
8
|
-
onDevCompileDone?:
|
|
5
|
+
beforeBabelPlugins?: IBabelPlugin[];
|
|
6
|
+
beforeBabelPresets?: IBabelPlugin[];
|
|
7
|
+
afterMiddlewares?: RequestHandler[];
|
|
8
|
+
beforeMiddlewares?: RequestHandler[];
|
|
9
|
+
onDevCompileDone?: (opts: {
|
|
10
|
+
isFirstCompile: boolean;
|
|
11
|
+
stats?: Stats | MultiStats;
|
|
12
|
+
time?: number;
|
|
13
|
+
}) => MaybePromise<void>;
|
|
9
14
|
port?: number;
|
|
10
15
|
host?: string;
|
|
11
16
|
ip?: string;
|
|
@@ -15,7 +20,7 @@ type IOpts = {
|
|
|
15
20
|
entry: Record<string, string>;
|
|
16
21
|
extraBabelPlugins?: IBabelPlugin[];
|
|
17
22
|
extraBabelPresets?: IBabelPlugin[];
|
|
18
|
-
onBeforeMiddleware?:
|
|
23
|
+
onBeforeMiddleware?: (app: Express) => MaybePromise<void>;
|
|
19
24
|
};
|
|
20
25
|
export declare function dev(opts: IOpts): Promise<void>;
|
|
21
26
|
export {};
|
package/dist/dev.js
CHANGED
package/dist/server/server.js
CHANGED
|
@@ -43,6 +43,9 @@ async function createServer(opts) {
|
|
|
43
43
|
cwd: opts.cwd,
|
|
44
44
|
rsbuildConfig
|
|
45
45
|
});
|
|
46
|
+
try {
|
|
47
|
+
} catch (e) {
|
|
48
|
+
}
|
|
46
49
|
const app = (0, import_express.default)();
|
|
47
50
|
const rsbuildServer = await rsbuild.createDevServer();
|
|
48
51
|
if (opts.onBeforeMiddleware) {
|
|
@@ -74,19 +77,14 @@ async function createServer(opts) {
|
|
|
74
77
|
writeToDisk: true
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
|
-
rsbuild.onDevCompileDone((
|
|
78
|
-
var _a;
|
|
80
|
+
rsbuild.onDevCompileDone((params) => {
|
|
81
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
79
82
|
if (opts.onDevCompileDone) {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
time: endTime - startTime,
|
|
86
|
-
stats: {
|
|
87
|
-
startTime,
|
|
88
|
-
endTime
|
|
89
|
-
}
|
|
83
|
+
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;
|
|
84
|
+
(_h = opts.onDevCompileDone) == null ? void 0 : _h.call(opts, {
|
|
85
|
+
isFirstCompile: params.isFirstCompile,
|
|
86
|
+
stats: params.stats,
|
|
87
|
+
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
|
|
90
88
|
});
|
|
91
89
|
}
|
|
92
90
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/bundler-rsbuild",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2-alpha.0",
|
|
4
4
|
"description": "@winner-fed/bundler-rsbuild",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"@rsbuild/plugin-less": "1.0.1-beta.14",
|
|
15
15
|
"@rsbuild/plugin-node-polyfill": "1.0.4",
|
|
16
16
|
"@rsbuild/plugin-sass": "1.0.1-beta.14",
|
|
17
|
+
"@rsbuild/plugin-stylus": "1.0.1-beta.14",
|
|
17
18
|
"@rsbuild/plugin-type-check": "1.0.1-beta.14",
|
|
18
|
-
"@winner-fed/
|
|
19
|
-
"@winner-fed/utils": "0.10.
|
|
19
|
+
"@winner-fed/utils": "0.10.2-alpha.0",
|
|
20
|
+
"@winner-fed/bundler-utils": "0.10.2-alpha.0"
|
|
20
21
|
},
|
|
21
22
|
"publishConfig": {
|
|
22
23
|
"access": "public"
|