@rsbuild/core 0.3.8 → 0.3.10
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/cli/commands.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/cleanOutput.js +23 -2
- package/dist/plugins/define.js +1 -3
- package/dist/plugins/html.js +1 -3
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/rsdoctor.d.ts +2 -0
- package/dist/plugins/rsdoctor.js +81 -0
- package/dist/plugins/splitChunks.d.ts +1 -1
- package/dist/plugins/splitChunks.js +53 -55
- package/dist/provider/core/createContext.js +1 -1
- package/dist/provider/plugins/transition.js +2 -0
- package/dist/provider/shared.js +1 -0
- package/package.json +3 -3
package/dist/cli/commands.js
CHANGED
|
@@ -112,7 +112,7 @@ const applyServerOptions = (command) => {
|
|
|
112
112
|
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");
|
|
113
113
|
};
|
|
114
114
|
function runCli() {
|
|
115
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.
|
|
115
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.10");
|
|
116
116
|
const devCommand = import_commander.program.command("dev");
|
|
117
117
|
const buildCommand = import_commander.program.command("build");
|
|
118
118
|
const previewCommand = import_commander.program.command("preview");
|
package/dist/cli/prepare.js
CHANGED
|
@@ -34,7 +34,7 @@ function prepareCli() {
|
|
|
34
34
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js")) {
|
|
35
35
|
console.log();
|
|
36
36
|
}
|
|
37
|
-
import_rslog.logger.greet(` ${`Rsbuild v${"0.3.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.3.10"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var import_createRsbuild = require("./createRsbuild");
|
|
|
38
38
|
var import_config = require("./cli/config");
|
|
39
39
|
var import_shared = require("@rsbuild/shared");
|
|
40
40
|
var import_constants = require("./constants");
|
|
41
|
-
const version = "0.3.
|
|
41
|
+
const version = "0.3.10";
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
PLUGIN_BABEL_NAME,
|
|
@@ -21,19 +21,40 @@ __export(cleanOutput_exports, {
|
|
|
21
21
|
pluginCleanOutput: () => pluginCleanOutput
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cleanOutput_exports);
|
|
24
|
+
var import_node_path = require("node:path");
|
|
24
25
|
var import_shared = require("@rsbuild/shared");
|
|
25
26
|
const emptyDir = async (dir) => {
|
|
26
27
|
if (await import_shared.fse.pathExists(dir)) {
|
|
27
28
|
await import_shared.fse.emptyDir(dir);
|
|
28
29
|
}
|
|
29
30
|
};
|
|
31
|
+
const addTrailingSep = (dir) => dir.endsWith(import_node_path.sep) ? dir : dir + import_node_path.sep;
|
|
32
|
+
const isStrictSubdir = (parent, child) => {
|
|
33
|
+
const parentDir = addTrailingSep(parent);
|
|
34
|
+
const childDir = addTrailingSep(child);
|
|
35
|
+
return parentDir !== childDir && childDir.startsWith(parentDir);
|
|
36
|
+
};
|
|
30
37
|
const pluginCleanOutput = () => ({
|
|
31
38
|
name: "rsbuild:clean-output",
|
|
32
39
|
setup(api) {
|
|
33
40
|
const clean = async () => {
|
|
41
|
+
const { distPath, rootPath } = api.context;
|
|
34
42
|
const config = api.getNormalizedConfig();
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
let { cleanDistPath } = config.output;
|
|
44
|
+
if (cleanDistPath === void 0) {
|
|
45
|
+
cleanDistPath = isStrictSubdir(rootPath, distPath);
|
|
46
|
+
if (!cleanDistPath) {
|
|
47
|
+
import_shared.logger.warn(
|
|
48
|
+
"The dist path is not a subdir of root path, Rsbuild will not empty it."
|
|
49
|
+
);
|
|
50
|
+
import_shared.logger.warn(
|
|
51
|
+
`Please set ${import_shared.color.yellow("`output.cleanDistPath`")} config manually.`
|
|
52
|
+
);
|
|
53
|
+
import_shared.logger.warn(`Current root path: ${import_shared.color.dim(rootPath)}`);
|
|
54
|
+
import_shared.logger.warn(`Current dist path: ${import_shared.color.dim(distPath)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (cleanDistPath) {
|
|
37
58
|
await emptyDir(distPath);
|
|
38
59
|
}
|
|
39
60
|
};
|
package/dist/plugins/define.js
CHANGED
|
@@ -27,12 +27,10 @@ const pluginDefine = () => ({
|
|
|
27
27
|
setup(api) {
|
|
28
28
|
api.modifyBundlerChain((chain, { CHAIN_ID, bundler }) => {
|
|
29
29
|
const config = api.getNormalizedConfig();
|
|
30
|
-
const publicPath = chain.output.get("publicPath");
|
|
31
|
-
const assetPrefix = publicPath && typeof publicPath === "string" ? publicPath : config.output.assetPrefix;
|
|
32
30
|
const builtinVars = {
|
|
33
31
|
"process.env.NODE_ENV": JSON.stringify((0, import_shared.getNodeEnv)()),
|
|
34
32
|
"process.env.ASSET_PREFIX": JSON.stringify(
|
|
35
|
-
(0, import_shared.
|
|
33
|
+
(0, import_shared.getPublicPathFromChain)(chain, false)
|
|
36
34
|
)
|
|
37
35
|
};
|
|
38
36
|
chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [
|
package/dist/plugins/html.js
CHANGED
|
@@ -188,9 +188,7 @@ const pluginHtml = () => ({
|
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
const minify = await (0, import_shared.getMinify)(isProd, config);
|
|
191
|
-
const assetPrefix = (0, import_shared.
|
|
192
|
-
chain.output.get("publicPath") || ""
|
|
193
|
-
);
|
|
191
|
+
const assetPrefix = (0, import_shared.getPublicPathFromChain)(chain, false);
|
|
194
192
|
const entries = chain.entryPoints.entries() || {};
|
|
195
193
|
const entryNames = Object.keys(entries);
|
|
196
194
|
const htmlPaths = api.getHTMLPaths();
|
package/dist/plugins/index.js
CHANGED
|
@@ -43,6 +43,7 @@ const plugins = {
|
|
|
43
43
|
splitChunks: () => Promise.resolve().then(() => __toESM(require("./splitChunks"))).then((m) => m.pluginSplitChunks()),
|
|
44
44
|
inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.pluginInlineChunk()),
|
|
45
45
|
bundleAnalyzer: () => Promise.resolve().then(() => __toESM(require("./bundleAnalyzer"))).then((m) => m.pluginBundleAnalyzer()),
|
|
46
|
+
rsdoctor: () => Promise.resolve().then(() => __toESM(require("./rsdoctor"))).then((m) => m.pluginRsdoctor()),
|
|
46
47
|
asset: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset()),
|
|
47
48
|
wasm: () => Promise.resolve().then(() => __toESM(require("./wasm"))).then((m) => m.pluginWasm()),
|
|
48
49
|
moment: () => Promise.resolve().then(() => __toESM(require("./moment"))).then((m) => m.pluginMoment()),
|
|
@@ -0,0 +1,81 @@
|
|
|
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 rsdoctor_exports = {};
|
|
30
|
+
__export(rsdoctor_exports, {
|
|
31
|
+
pluginRsdoctor: () => pluginRsdoctor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(rsdoctor_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
const pluginRsdoctor = () => ({
|
|
36
|
+
name: "rsbuild:rsdoctor",
|
|
37
|
+
setup(api) {
|
|
38
|
+
api.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {
|
|
39
|
+
if (process.env.RSDOCTOR !== "true") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const isRspack = api.context.bundlerType === "rspack";
|
|
43
|
+
const packageName = isRspack ? "@rsdoctor/rspack-plugin" : "@rsdoctor/webpack-plugin";
|
|
44
|
+
let module2;
|
|
45
|
+
try {
|
|
46
|
+
const path = require.resolve(packageName, {
|
|
47
|
+
paths: [api.context.rootPath]
|
|
48
|
+
});
|
|
49
|
+
module2 = await Promise.resolve().then(() => __toESM(require(path)));
|
|
50
|
+
} catch (err) {
|
|
51
|
+
import_shared.logger.warn(
|
|
52
|
+
`\`process.env.RSDOCTOR\` enabled, please install ${import_shared.color.bold(import_shared.color.yellow(packageName))} package.`
|
|
53
|
+
);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const pluginName = isRspack ? "RsdoctorRspackPlugin" : "RsdoctorWebpackPlugin";
|
|
57
|
+
if (!module2 || !module2[pluginName]) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let isAutoRegister = false;
|
|
61
|
+
bundlerConfigs.forEach((config) => {
|
|
62
|
+
const registered = config.plugins?.some(
|
|
63
|
+
(plugin) => plugin?.constructor?.name === pluginName
|
|
64
|
+
);
|
|
65
|
+
if (registered) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
config.plugins || (config.plugins = []);
|
|
69
|
+
config.plugins.push(new module2[pluginName]());
|
|
70
|
+
isAutoRegister = true;
|
|
71
|
+
});
|
|
72
|
+
if (isAutoRegister) {
|
|
73
|
+
import_shared.logger.info(`${import_shared.color.bold(import_shared.color.yellow(packageName))} enabled.`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
pluginRsdoctor
|
|
81
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RsbuildPlugin } from '../types';
|
|
2
2
|
export declare const MODULE_PATH_REGEX: RegExp;
|
|
3
3
|
export declare function getPackageNameFromModulePath(modulePath: string): string | undefined;
|
|
4
|
-
export declare
|
|
4
|
+
export declare const pluginSplitChunks: () => RsbuildPlugin;
|
|
@@ -119,12 +119,12 @@ function splitByModule(ctx) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
function splitBySize(ctx) {
|
|
122
|
-
const { override, userDefinedCacheGroups, defaultConfig,
|
|
123
|
-
(0, import_node_assert.default)(
|
|
122
|
+
const { override, userDefinedCacheGroups, defaultConfig, userConfig } = ctx;
|
|
123
|
+
(0, import_node_assert.default)(userConfig.strategy === "split-by-size");
|
|
124
124
|
return {
|
|
125
125
|
...defaultConfig,
|
|
126
|
-
minSize:
|
|
127
|
-
maxSize:
|
|
126
|
+
minSize: userConfig.minSize ?? 0,
|
|
127
|
+
maxSize: userConfig.maxSize ?? Infinity,
|
|
128
128
|
...override,
|
|
129
129
|
cacheGroups: {
|
|
130
130
|
...defaultConfig.cacheGroups,
|
|
@@ -179,60 +179,58 @@ const SPLIT_STRATEGY_DISPATCHER = {
|
|
|
179
179
|
"all-in-one": allInOne,
|
|
180
180
|
"single-vendor": singleVendor
|
|
181
181
|
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
const config = api.getNormalizedConfig();
|
|
200
|
-
const defaultConfig = {
|
|
201
|
-
// Optimize both `initial` and `async` chunks
|
|
202
|
-
chunks: "all",
|
|
203
|
-
// When chunk size >= 50000 bytes, split it into separate chunk
|
|
204
|
-
// @ts-expect-error Rspack type missing
|
|
205
|
-
enforceSizeThreshold: 5e4,
|
|
206
|
-
cacheGroups: {}
|
|
207
|
-
};
|
|
208
|
-
const { chunkSplit } = config.performance;
|
|
209
|
-
let userDefinedCacheGroups = {};
|
|
210
|
-
if (chunkSplit.forceSplitting) {
|
|
211
|
-
userDefinedCacheGroups = getUserDefinedCacheGroups(
|
|
212
|
-
chunkSplit.forceSplitting
|
|
213
|
-
);
|
|
182
|
+
const pluginSplitChunks = () => ({
|
|
183
|
+
name: "rsbuild:split-chunks",
|
|
184
|
+
setup(api) {
|
|
185
|
+
api.modifyBundlerChain(
|
|
186
|
+
async (chain, { isServer, isWebWorker, isServiceWorker }) => {
|
|
187
|
+
if (isServer || isWebWorker || isServiceWorker) {
|
|
188
|
+
chain.optimization.splitChunks(false);
|
|
189
|
+
if (isWebWorker || isServiceWorker) {
|
|
190
|
+
chain.module.parser.merge({
|
|
191
|
+
javascript: {
|
|
192
|
+
dynamicImportMode: "eager"
|
|
193
|
+
}
|
|
194
|
+
});
|
|
214
195
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const config = api.getNormalizedConfig();
|
|
199
|
+
const defaultConfig = {
|
|
200
|
+
// Optimize both `initial` and `async` chunks
|
|
201
|
+
chunks: "all",
|
|
202
|
+
// When chunk size >= 50000 bytes, split it into separate chunk
|
|
203
|
+
// @ts-expect-error Rspack type missing
|
|
204
|
+
enforceSizeThreshold: 5e4,
|
|
205
|
+
cacheGroups: {}
|
|
206
|
+
};
|
|
207
|
+
const { chunkSplit } = config.performance;
|
|
208
|
+
let userDefinedCacheGroups = {};
|
|
209
|
+
if (chunkSplit.forceSplitting) {
|
|
210
|
+
userDefinedCacheGroups = getUserDefinedCacheGroups(
|
|
211
|
+
chunkSplit.forceSplitting
|
|
230
212
|
);
|
|
231
213
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
214
|
+
const override = chunkSplit.strategy === "custom" ? (
|
|
215
|
+
// `chunkSplit.splitChunks` compat for Eden
|
|
216
|
+
chunkSplit.splitChunks ?? chunkSplit.override
|
|
217
|
+
) : chunkSplit.override;
|
|
218
|
+
const splitChunksOptions = await SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy || "split-by-experience"]({
|
|
219
|
+
defaultConfig,
|
|
220
|
+
override: override || {},
|
|
221
|
+
userDefinedCacheGroups,
|
|
222
|
+
userConfig: chunkSplit,
|
|
223
|
+
rootPath: api.context.rootPath,
|
|
224
|
+
polyfill: config.output.polyfill
|
|
225
|
+
});
|
|
226
|
+
chain.optimization.splitChunks(
|
|
227
|
+
// @ts-expect-error splitChunks type mismatch
|
|
228
|
+
splitChunksOptions
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
236
234
|
// Annotate the CommonJS export names for ESM import in node:
|
|
237
235
|
0 && (module.exports = {
|
|
238
236
|
MODULE_PATH_REGEX,
|
|
@@ -24,7 +24,9 @@ module.exports = __toCommonJS(transition_exports);
|
|
|
24
24
|
const pluginTransition = () => ({
|
|
25
25
|
name: "rsbuild:transition",
|
|
26
26
|
setup() {
|
|
27
|
+
var _a;
|
|
27
28
|
process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
|
|
29
|
+
(_a = process.env).WATCHPACK_WATCHER_LIMIT || (_a.WATCHPACK_WATCHER_LIMIT = "20");
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/provider/shared.js
CHANGED
|
@@ -69,6 +69,7 @@ const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
|
|
|
69
69
|
plugins.startUrl(),
|
|
70
70
|
plugins.inlineChunk(),
|
|
71
71
|
plugins.bundleAnalyzer(),
|
|
72
|
+
plugins.rsdoctor(),
|
|
72
73
|
plugins.networkPerformance(),
|
|
73
74
|
plugins.preloadOrPrefetch(),
|
|
74
75
|
plugins.performance(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"types.d.ts"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@rspack/core": "0.5.
|
|
55
|
+
"@rspack/core": "0.5.3",
|
|
56
56
|
"@swc/helpers": "0.5.3",
|
|
57
57
|
"core-js": "~3.32.2",
|
|
58
58
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"@rsbuild/shared": "0.3.
|
|
60
|
+
"@rsbuild/shared": "0.3.10"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|