@rsbuild/core 0.0.13 → 0.0.14
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/plugins/fileSize.js +9 -11
- package/dist/plugins/moment.d.ts +1 -1
- package/dist/plugins/moment.js +27 -2
- package/dist/plugins/nodeAddons.js +1 -2
- package/dist/plugins/splitChunks.js +2 -10
- package/dist/rspack-provider/core/rspackConfig.js +1 -3
- package/dist/rspack-provider/plugins/fallback.js +0 -2
- package/dist/rspack-provider/provider.js +1 -2
- package/dist/rspack-provider/shared/plugin.js +0 -1
- package/package.json +4 -5
- package/dist/rspack-provider/plugins/manifest.d.ts +0 -2
- package/dist/rspack-provider/plugins/manifest.js +0 -58
package/dist/plugins/fileSize.js
CHANGED
|
@@ -33,7 +33,6 @@ __export(fileSize_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(fileSize_exports);
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_chalk = require("@rsbuild/shared/chalk");
|
|
37
36
|
var import_fs_extra = require("@rsbuild/shared/fs-extra");
|
|
38
37
|
var import_shared = require("@rsbuild/shared");
|
|
39
38
|
var import_filesize = __toESM(require("filesize"));
|
|
@@ -41,12 +40,12 @@ var import_gzip_size = __toESM(require("gzip-size"));
|
|
|
41
40
|
const filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
|
|
42
41
|
const getAssetColor = (size) => {
|
|
43
42
|
if (size > 300 * 1e3) {
|
|
44
|
-
return
|
|
43
|
+
return import_shared.color.red;
|
|
45
44
|
}
|
|
46
45
|
if (size > 100 * 1e3) {
|
|
47
|
-
return
|
|
46
|
+
return import_shared.color.yellow;
|
|
48
47
|
}
|
|
49
|
-
return
|
|
48
|
+
return import_shared.color.green;
|
|
50
49
|
};
|
|
51
50
|
async function printHeader(longestFileLength, longestLabelLength) {
|
|
52
51
|
const longestLengths = [longestFileLength, longestLabelLength];
|
|
@@ -58,7 +57,7 @@ async function printHeader(longestFileLength, longestLabelLength) {
|
|
|
58
57
|
}
|
|
59
58
|
return `${prev + curLabel} `;
|
|
60
59
|
}, " ");
|
|
61
|
-
import_shared.logger.log(
|
|
60
|
+
import_shared.logger.log(import_shared.color.bold(import_shared.color.blue(headerRow)));
|
|
62
61
|
}
|
|
63
62
|
async function printFileSizes(stats, distPath) {
|
|
64
63
|
const formatAsset = (asset) => {
|
|
@@ -117,21 +116,20 @@ async function printFileSizes(stats, distPath) {
|
|
|
117
116
|
const rightPadding = " ".repeat(longestLabelLength - sizeLength);
|
|
118
117
|
sizeLabel += rightPadding;
|
|
119
118
|
}
|
|
120
|
-
let fileNameLabel =
|
|
119
|
+
let fileNameLabel = import_shared.color.dim(asset.folder + import_path.default.sep) + import_shared.color.cyan(asset.name);
|
|
121
120
|
if (fileNameLength < longestFileLength) {
|
|
122
121
|
const rightPadding = " ".repeat(longestFileLength - fileNameLength);
|
|
123
122
|
fileNameLabel += rightPadding;
|
|
124
123
|
}
|
|
125
124
|
import_shared.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
|
|
126
125
|
});
|
|
127
|
-
const totalSizeLabel = `${
|
|
126
|
+
const totalSizeLabel = `${import_shared.color.bold(import_shared.color.blue("Total size:"))} ${(0, import_filesize.default)(
|
|
128
127
|
totalSize,
|
|
129
128
|
{ round: 1 }
|
|
130
129
|
)}`;
|
|
131
|
-
const gzippedSizeLabel = `${
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
)}`;
|
|
130
|
+
const gzippedSizeLabel = `${import_shared.color.bold(
|
|
131
|
+
import_shared.color.blue("Gzipped size:")
|
|
132
|
+
)} ${(0, import_filesize.default)(totalGzipSize, { round: 1 })}`;
|
|
135
133
|
import_shared.logger.log(`
|
|
136
134
|
${totalSizeLabel}
|
|
137
135
|
${gzippedSizeLabel}
|
package/dist/plugins/moment.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DefaultRsbuildPlugin } from '@rsbuild/shared';
|
|
1
|
+
import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
|
|
2
2
|
export declare const pluginMoment: () => DefaultRsbuildPlugin;
|
package/dist/plugins/moment.js
CHANGED
|
@@ -21,13 +21,38 @@ __export(moment_exports, {
|
|
|
21
21
|
pluginMoment: () => pluginMoment
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(moment_exports);
|
|
24
|
+
class IgnorePlugin {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.options = options;
|
|
27
|
+
this.checkIgnore = this.checkIgnore.bind(this);
|
|
28
|
+
}
|
|
29
|
+
checkIgnore(resolveData) {
|
|
30
|
+
if ("resourceRegExp" in this.options && this.options.resourceRegExp && this.options.resourceRegExp.test(resolveData.request)) {
|
|
31
|
+
if ("contextRegExp" in this.options && this.options.contextRegExp) {
|
|
32
|
+
if (this.options.contextRegExp.test(resolveData.context)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
apply(compiler) {
|
|
41
|
+
compiler.hooks.normalModuleFactory.tap("IgnorePlugin", (nmf) => {
|
|
42
|
+
nmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
|
|
43
|
+
});
|
|
44
|
+
compiler.hooks.contextModuleFactory.tap("IgnorePlugin", (cmf) => {
|
|
45
|
+
cmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
24
49
|
const pluginMoment = () => ({
|
|
25
50
|
name: "plugin-moment",
|
|
26
51
|
setup(api) {
|
|
27
|
-
api.modifyBundlerChain(async (chain
|
|
52
|
+
api.modifyBundlerChain(async (chain) => {
|
|
28
53
|
const config = api.getNormalizedConfig();
|
|
29
54
|
if (config.performance.removeMomentLocale) {
|
|
30
|
-
chain.plugin("remove-moment-locale").use(
|
|
55
|
+
chain.plugin("remove-moment-locale").use(IgnorePlugin, [
|
|
31
56
|
{
|
|
32
57
|
resourceRegExp: /^\.\/locale$/,
|
|
33
58
|
contextRegExp: /moment$/
|
|
@@ -32,7 +32,6 @@ __export(nodeAddons_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(nodeAddons_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_chalk = require("@rsbuild/shared/chalk");
|
|
36
35
|
const pluginNodeAddons = () => ({
|
|
37
36
|
name: "plugin-node-addons",
|
|
38
37
|
setup(api) {
|
|
@@ -46,7 +45,7 @@ const pluginNodeAddons = () => ({
|
|
|
46
45
|
const pkgJSON = pkgUp.sync({ cwd: resource });
|
|
47
46
|
if (!pkgJSON) {
|
|
48
47
|
throw new Error(
|
|
49
|
-
`Failed to compile Node.js addons, couldn't find the package.json of ${
|
|
48
|
+
`Failed to compile Node.js addons, couldn't find the package.json of ${import_shared.color.yellow(
|
|
50
49
|
resource
|
|
51
50
|
)}.`
|
|
52
51
|
);
|
|
@@ -82,8 +82,6 @@ function splitByExperience(ctx) {
|
|
|
82
82
|
reuseExistingChunk: true
|
|
83
83
|
};
|
|
84
84
|
});
|
|
85
|
-
(0, import_assert.default)(defaultConfig !== false);
|
|
86
|
-
(0, import_assert.default)(override !== false);
|
|
87
85
|
return {
|
|
88
86
|
...defaultConfig,
|
|
89
87
|
...override,
|
|
@@ -97,8 +95,6 @@ function splitByExperience(ctx) {
|
|
|
97
95
|
}
|
|
98
96
|
function splitByModule(ctx) {
|
|
99
97
|
const { override, userDefinedCacheGroups, defaultConfig } = ctx;
|
|
100
|
-
(0, import_assert.default)(defaultConfig !== false);
|
|
101
|
-
(0, import_assert.default)(override !== false);
|
|
102
98
|
return {
|
|
103
99
|
...defaultConfig,
|
|
104
100
|
minSize: 0,
|
|
@@ -112,6 +108,7 @@ function splitByModule(ctx) {
|
|
|
112
108
|
priority: -10,
|
|
113
109
|
test: import_shared.NODE_MODULES_REGEX,
|
|
114
110
|
// todo: not support in rspack
|
|
111
|
+
// @ts-expect-error
|
|
115
112
|
name(module2) {
|
|
116
113
|
return (0, import_shared.getPackageNameFromModulePath)(module2.context);
|
|
117
114
|
}
|
|
@@ -123,8 +120,6 @@ function splitByModule(ctx) {
|
|
|
123
120
|
function splitBySize(ctx) {
|
|
124
121
|
var _a, _b;
|
|
125
122
|
const { override, userDefinedCacheGroups, defaultConfig, rsbuildConfig } = ctx;
|
|
126
|
-
(0, import_assert.default)(defaultConfig !== false);
|
|
127
|
-
(0, import_assert.default)(override !== false);
|
|
128
123
|
(0, import_assert.default)(rsbuildConfig.strategy === "split-by-size");
|
|
129
124
|
return {
|
|
130
125
|
...defaultConfig,
|
|
@@ -140,8 +135,6 @@ function splitBySize(ctx) {
|
|
|
140
135
|
}
|
|
141
136
|
function splitCustom(ctx) {
|
|
142
137
|
const { override, userDefinedCacheGroups, defaultConfig } = ctx;
|
|
143
|
-
(0, import_assert.default)(defaultConfig !== false);
|
|
144
|
-
(0, import_assert.default)(override !== false);
|
|
145
138
|
return {
|
|
146
139
|
...defaultConfig,
|
|
147
140
|
...override,
|
|
@@ -157,8 +150,6 @@ function allInOne(_ctx) {
|
|
|
157
150
|
}
|
|
158
151
|
function singleVendor(ctx) {
|
|
159
152
|
const { override, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
160
|
-
(0, import_assert.default)(defaultConfig !== false);
|
|
161
|
-
(0, import_assert.default)(override !== false);
|
|
162
153
|
const singleVendorCacheGroup = {
|
|
163
154
|
singleVendor: {
|
|
164
155
|
test: import_shared.NODE_MODULES_REGEX,
|
|
@@ -211,6 +202,7 @@ function pluginSplitChunks() {
|
|
|
211
202
|
// Optimize both `initial` and `async` chunks
|
|
212
203
|
chunks: "all",
|
|
213
204
|
// When chunk size >= 50000 bytes, split it into separate chunk
|
|
205
|
+
// @ts-expect-error Rspack type missing
|
|
214
206
|
enforceSizeThreshold: 5e4,
|
|
215
207
|
cacheGroups: {}
|
|
216
208
|
};
|
|
@@ -92,7 +92,6 @@ async function getConfigUtils(config, chainUtils) {
|
|
|
92
92
|
async function getChainUtils(target) {
|
|
93
93
|
const nodeEnv = process.env.NODE_ENV;
|
|
94
94
|
const { default: HtmlPlugin } = await Promise.resolve().then(() => __toESM(require("html-webpack-plugin")));
|
|
95
|
-
const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
|
|
96
95
|
return {
|
|
97
96
|
env: nodeEnv,
|
|
98
97
|
target,
|
|
@@ -102,8 +101,7 @@ async function getChainUtils(target) {
|
|
|
102
101
|
isWebWorker: target === "web-worker",
|
|
103
102
|
getCompiledPath: import_shared2.getCompiledPath,
|
|
104
103
|
CHAIN_ID: import_shared.CHAIN_ID,
|
|
105
|
-
HtmlPlugin
|
|
106
|
-
webpack
|
|
104
|
+
HtmlPlugin
|
|
107
105
|
};
|
|
108
106
|
}
|
|
109
107
|
const convertToRspackConfig = (config) => {
|
|
@@ -41,8 +41,6 @@ const pluginFallback = () => ({
|
|
|
41
41
|
(0, import_shared.setConfig)(
|
|
42
42
|
config,
|
|
43
43
|
"module.rules",
|
|
44
|
-
// Rspack RuleSetRule is not exactly aligned with webpack. But it doesn't matter in resourceRuleFallback.
|
|
45
|
-
// @ts-expect-error
|
|
46
44
|
(0, import_shared.resourceRuleFallback)((_a = config.module) == null ? void 0 : _a.rules)
|
|
47
45
|
);
|
|
48
46
|
});
|
|
@@ -32,7 +32,6 @@ __export(provider_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(provider_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_chalk = require("@rsbuild/shared/chalk");
|
|
36
35
|
var import_createContext = require("./core/createContext");
|
|
37
36
|
var import_initConfigs = require("./core/initConfigs");
|
|
38
37
|
var import_initPlugins = require("./core/initPlugins");
|
|
@@ -45,7 +44,7 @@ function rspackProvider({
|
|
|
45
44
|
return async ({ pluginStore, rsbuildOptions, plugins }) => {
|
|
46
45
|
if (!await (0, import_rspackVersion.isSatisfyRspackMinimumVersion)()) {
|
|
47
46
|
throw new Error(
|
|
48
|
-
`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${
|
|
47
|
+
`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${import_shared.color.green(
|
|
49
48
|
import_rspackVersion.supportedRspackMinimumVersion
|
|
50
49
|
)}`
|
|
51
50
|
);
|
|
@@ -57,7 +57,6 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
|
|
|
57
57
|
Promise.resolve().then(() => __toESM(require("../plugins/less"))).then((m) => m.pluginLess()),
|
|
58
58
|
Promise.resolve().then(() => __toESM(require("../plugins/sass"))).then((m) => m.pluginSass()),
|
|
59
59
|
Promise.resolve().then(() => __toESM(require("../plugins/minimize"))).then((m) => m.pluginMinimize()),
|
|
60
|
-
Promise.resolve().then(() => __toESM(require("../plugins/manifest"))).then((m) => m.pluginManifest()),
|
|
61
60
|
plugins.rem(),
|
|
62
61
|
Promise.resolve().then(() => __toESM(require("../plugins/hmr"))).then((m) => m.pluginHMR()),
|
|
63
62
|
Promise.resolve().then(() => __toESM(require("../plugins/progress"))).then((m) => m.pluginProgress()),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Unleash the power of Rspack with the out-of-the-box build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -61,9 +61,10 @@
|
|
|
61
61
|
"static"
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@modern-js/server": "
|
|
64
|
+
"@modern-js/server": "0.0.0-next-20231103131234",
|
|
65
65
|
"@rspack/core": "0.3.10",
|
|
66
66
|
"commander": "^10.0.1",
|
|
67
|
+
"core-js": "~3.32.2",
|
|
67
68
|
"filesize": "^8.0.7",
|
|
68
69
|
"gzip-size": "^6.0.0",
|
|
69
70
|
"html-webpack-plugin": "5.5.3",
|
|
@@ -72,10 +73,8 @@
|
|
|
72
73
|
"open": "^8.4.0",
|
|
73
74
|
"pkg-up": "^3.1.0",
|
|
74
75
|
"postcss": "8.4.31",
|
|
75
|
-
"rspack-manifest-plugin": "5.0.0-alpha0",
|
|
76
76
|
"semver": "^7.5.4",
|
|
77
|
-
"
|
|
78
|
-
"@rsbuild/shared": "0.0.13"
|
|
77
|
+
"@rsbuild/shared": "0.0.14"
|
|
79
78
|
},
|
|
80
79
|
"devDependencies": {
|
|
81
80
|
"@types/lodash": "^4.14.200",
|
|
@@ -1,58 +0,0 @@
|
|
|
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 manifest_exports = {};
|
|
30
|
-
__export(manifest_exports, {
|
|
31
|
-
pluginManifest: () => pluginManifest
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(manifest_exports);
|
|
34
|
-
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
const pluginManifest = () => ({
|
|
36
|
-
name: "plugin-manifest",
|
|
37
|
-
setup(api) {
|
|
38
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
39
|
-
const config = api.getNormalizedConfig();
|
|
40
|
-
if (!config.output.enableAssetManifest) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const { WebpackManifestPlugin } = await Promise.resolve().then(() => __toESM(require("rspack-manifest-plugin")));
|
|
44
|
-
const publicPath = chain.output.get("publicPath");
|
|
45
|
-
chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(WebpackManifestPlugin, [
|
|
46
|
-
{
|
|
47
|
-
fileName: "asset-manifest.json",
|
|
48
|
-
publicPath,
|
|
49
|
-
generate: import_shared.generateManifest
|
|
50
|
-
}
|
|
51
|
-
]);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
pluginManifest
|
|
58
|
-
});
|