@rsbuild/core 0.2.17 → 0.3.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/README.md +1 -1
- package/dist/cli/commands.js +9 -7
- package/dist/cli/prepare.js +1 -1
- package/dist/index.js +1 -1
- package/dist/loadEnv.d.ts +1 -0
- package/dist/loadEnv.js +12 -10
- package/dist/plugins/asset.js +1 -1
- package/dist/plugins/basic.js +27 -21
- package/dist/plugins/entry.js +2 -2
- package/dist/plugins/fileSize.js +1 -2
- package/dist/plugins/html.js +6 -4
- package/dist/plugins/index.js +0 -2
- package/dist/plugins/networkPerformance.js +1 -1
- package/dist/plugins/preloadOrPrefetch.js +1 -1
- package/dist/plugins/server.js +1 -1
- package/dist/plugins/toml.d.ts +0 -2
- package/dist/plugins/toml.js +0 -35
- package/dist/plugins/yaml.d.ts +0 -2
- package/dist/plugins/yaml.js +0 -35
- package/dist/provider/core/build.d.ts +2 -14
- package/dist/provider/core/build.js +20 -25
- package/dist/provider/core/createCompiler.js +3 -3
- package/dist/provider/core/createContext.js +1 -1
- package/dist/provider/core/initConfigs.js +3 -3
- package/dist/provider/core/initHooks.d.ts +15 -15
- package/dist/provider/core/initHooks.js +15 -15
- package/dist/provider/core/initPlugins.js +16 -16
- package/dist/provider/core/rspackConfig.js +1 -1
- package/dist/provider/css-modules-typescript-pre-loader/index.js +1 -1
- package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.js +0 -1
- package/dist/provider/plugins/swc.js +6 -0
- package/dist/provider/plugins/transition.js +1 -14
- package/dist/provider/provider.js +15 -18
- package/dist/provider/shared.d.ts +2 -2
- package/dist/provider/shared.js +3 -5
- package/dist/rspack/HtmlCrossOriginPlugin.js +6 -6
- package/dist/rspack/HtmlNoncePlugin.js +3 -1
- package/dist/rspack/HtmlTagsPlugin.js +9 -3
- package/dist/rspack/preload/helpers/extractChunks.js +2 -1
- package/dist/server/devServer.d.ts +1 -1
- package/dist/server/devServer.js +10 -24
- package/dist/server/getDevMiddlewares.js +1 -1
- package/dist/server/helper.d.ts +3 -4
- package/dist/server/helper.js +3 -3
- package/dist/server/middlewares.js +4 -5
- package/dist/server/prodServer.d.ts +1 -1
- package/dist/server/prodServer.js +5 -5
- package/package.json +5 -4
- package/compiled/toml-loader/index.d.ts +0 -1
- package/compiled/toml-loader/index.js +0 -1
- package/compiled/toml-loader/license +0 -22
- package/compiled/toml-loader/package.json +0 -1
- package/dist/provider/plugins/hmr.d.ts +0 -2
- package/dist/provider/plugins/hmr.js +0 -38
package/README.md
CHANGED
package/dist/cli/commands.js
CHANGED
|
@@ -38,6 +38,7 @@ var import_shared = require("@rsbuild/shared");
|
|
|
38
38
|
var import_commander = require("@rsbuild/shared/commander");
|
|
39
39
|
var import_loadEnv = require("../loadEnv");
|
|
40
40
|
var import_config = require("./config");
|
|
41
|
+
var import_restart = require("../server/restart");
|
|
41
42
|
let commonOpts = {};
|
|
42
43
|
async function init({
|
|
43
44
|
cliOptions,
|
|
@@ -48,7 +49,8 @@ async function init({
|
|
|
48
49
|
}
|
|
49
50
|
try {
|
|
50
51
|
const root = process.cwd();
|
|
51
|
-
const
|
|
52
|
+
const envs = (0, import_loadEnv.loadEnv)({ cwd: root });
|
|
53
|
+
(0, import_shared.isDev)() && (0, import_restart.onBeforeRestartServer)(envs.cleanup);
|
|
52
54
|
const config = await (0, import_config.loadConfig)({
|
|
53
55
|
cwd: root,
|
|
54
56
|
path: commonOpts.config
|
|
@@ -56,7 +58,7 @@ async function init({
|
|
|
56
58
|
const { createRsbuild } = await Promise.resolve().then(() => __toESM(require("../createRsbuild")));
|
|
57
59
|
config.source || (config.source = {});
|
|
58
60
|
config.source.define = {
|
|
59
|
-
...publicVars,
|
|
61
|
+
...envs.publicVars,
|
|
60
62
|
...config.source.define
|
|
61
63
|
};
|
|
62
64
|
if (commonOpts.open && !config.dev?.startUrl) {
|
|
@@ -84,8 +86,8 @@ async function init({
|
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
function runCli() {
|
|
87
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.
|
|
88
|
-
import_commander.program.command("dev").option("--open [url]", "open the page in browser on startup").option(
|
|
89
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.0");
|
|
90
|
+
import_commander.program.command("dev").option("-o --open [url]", "open the page in browser on startup").option(
|
|
89
91
|
"--port <port>",
|
|
90
92
|
"specify a port number for Rsbuild Server to listen"
|
|
91
93
|
).option(
|
|
@@ -104,7 +106,7 @@ function runCli() {
|
|
|
104
106
|
process.exit(1);
|
|
105
107
|
}
|
|
106
108
|
});
|
|
107
|
-
import_commander.program.command("build").option(
|
|
109
|
+
import_commander.program.command("build").option("-w --watch", "turn on watch mode, watch for changes and rebuild").option(
|
|
108
110
|
"-c --config <config>",
|
|
109
111
|
"specify the configuration file, can be a relative or absolute path"
|
|
110
112
|
).description("build the app for production").action(async (options) => {
|
|
@@ -119,7 +121,7 @@ function runCli() {
|
|
|
119
121
|
process.exit(1);
|
|
120
122
|
}
|
|
121
123
|
});
|
|
122
|
-
import_commander.program.command("preview").option("--open [url]", "open the page in browser on startup").option(
|
|
124
|
+
import_commander.program.command("preview").option("-o --open [url]", "open the page in browser on startup").option(
|
|
123
125
|
"--port <port>",
|
|
124
126
|
"specify a port number for Rsbuild Server to listen"
|
|
125
127
|
).option(
|
|
@@ -145,7 +147,7 @@ function runCli() {
|
|
|
145
147
|
process.exit(1);
|
|
146
148
|
}
|
|
147
149
|
});
|
|
148
|
-
import_commander.program.command("inspect").description("inspect the Rspack and Rsbuild configs").option(
|
|
150
|
+
import_commander.program.command("inspect").description("inspect the Rspack and Rsbuild configs").option("--env <env>", "specify env mode", "development").option("--output <output>", "specify inspect content output path", "/").option("--verbose", "show full function definitions in output").option(
|
|
149
151
|
"-c --config <config>",
|
|
150
152
|
"specify the configuration file, can be a relative or absolute path"
|
|
151
153
|
).action(async (options) => {
|
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.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.3.0"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var import_loadEnv = require("./loadEnv");
|
|
|
31
31
|
var import_createRsbuild = require("./createRsbuild");
|
|
32
32
|
var import_config = require("./cli/config");
|
|
33
33
|
var import_shared = require("@rsbuild/shared");
|
|
34
|
-
const version = "0.
|
|
34
|
+
const version = "0.3.0";
|
|
35
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
36
|
0 && (module.exports = {
|
|
37
37
|
createRsbuild,
|
package/dist/loadEnv.d.ts
CHANGED
package/dist/loadEnv.js
CHANGED
|
@@ -35,7 +35,6 @@ module.exports = __toCommonJS(loadEnv_exports);
|
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_path = require("path");
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
|
-
var import_restart = require("./server/restart");
|
|
39
38
|
var import_dotenv = require("../compiled/dotenv");
|
|
40
39
|
var import_dotenv_expand = require("../compiled/dotenv-expand");
|
|
41
40
|
const getEnvFiles = () => {
|
|
@@ -59,18 +58,21 @@ function loadEnv({
|
|
|
59
58
|
publicVars[`process.env.${key}`] = JSON.stringify(val);
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
let cleaned = false;
|
|
62
|
+
const cleanup = () => {
|
|
63
|
+
if (cleaned)
|
|
64
|
+
return;
|
|
65
|
+
Object.keys(parsed).forEach((key) => {
|
|
66
|
+
if (process.env[key] === parsed[key]) {
|
|
67
|
+
delete process.env[key];
|
|
68
|
+
}
|
|
69
69
|
});
|
|
70
|
-
|
|
70
|
+
cleaned = true;
|
|
71
|
+
};
|
|
71
72
|
return {
|
|
72
73
|
parsed,
|
|
73
|
-
publicVars
|
|
74
|
+
publicVars,
|
|
75
|
+
cleanup
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
78
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/plugins/asset.js
CHANGED
|
@@ -37,7 +37,7 @@ var import_shared = require("@rsbuild/shared");
|
|
|
37
37
|
function getRegExpForExts(exts) {
|
|
38
38
|
const matcher = exts.map((ext) => ext.trim()).map((ext) => ext.startsWith(".") ? ext.slice(1) : ext).join("|");
|
|
39
39
|
return new RegExp(
|
|
40
|
-
exts.length === 1 ? `\\.${matcher}$` : `\\.(
|
|
40
|
+
exts.length === 1 ? `\\.${matcher}$` : `\\.(?:${matcher})$`,
|
|
41
41
|
"i"
|
|
42
42
|
);
|
|
43
43
|
}
|
package/dist/plugins/basic.js
CHANGED
|
@@ -36,30 +36,36 @@ var import_shared = require("@rsbuild/shared");
|
|
|
36
36
|
const pluginBasic = () => ({
|
|
37
37
|
name: "rsbuild:basic",
|
|
38
38
|
setup(api) {
|
|
39
|
-
api.modifyBundlerChain(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
api.modifyBundlerChain(
|
|
40
|
+
(chain, { env, isProd, target, bundler, CHAIN_ID }) => {
|
|
41
|
+
const config = api.getNormalizedConfig();
|
|
42
|
+
chain.name(import_shared.TARGET_ID_MAP[target]);
|
|
43
|
+
chain.devtool((0, import_shared.getJsSourceMap)(config));
|
|
44
|
+
chain.context(api.context.rootPath);
|
|
45
|
+
chain.mode(isProd ? "production" : "development");
|
|
46
|
+
chain.merge({
|
|
47
|
+
infrastructureLogging: {
|
|
48
|
+
// Using `error` level to avoid `cache.PackFileCacheStrategy` logs
|
|
49
|
+
level: "error"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
chain.performance.hints(false);
|
|
53
|
+
chain.module.parser.merge({
|
|
54
|
+
javascript: {
|
|
55
|
+
exportsPresence: "error"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const usingHMR = (0, import_shared.isUsingHMR)(config, { target, isProd });
|
|
59
|
+
if (usingHMR) {
|
|
60
|
+
chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin);
|
|
49
61
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
exportsPresence: "error"
|
|
62
|
+
if (env === "development") {
|
|
63
|
+
chain.output.devtoolModuleFilenameTemplate(
|
|
64
|
+
(info) => import_path.default.resolve(info.absoluteResourcePath).replace(/\\/g, "/")
|
|
65
|
+
);
|
|
55
66
|
}
|
|
56
|
-
});
|
|
57
|
-
if (env === "development") {
|
|
58
|
-
chain.output.devtoolModuleFilenameTemplate(
|
|
59
|
-
(info) => import_path.default.resolve(info.absoluteResourcePath).replace(/\\/g, "/")
|
|
60
|
-
);
|
|
61
67
|
}
|
|
62
|
-
|
|
68
|
+
);
|
|
63
69
|
}
|
|
64
70
|
});
|
|
65
71
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/plugins/entry.js
CHANGED
|
@@ -46,9 +46,9 @@ const pluginEntry = () => ({
|
|
|
46
46
|
if (bundlerConfigs.every((config) => !config.entry)) {
|
|
47
47
|
throw new Error(
|
|
48
48
|
`Could not find any entry module, please make sure that ${import_shared.color.cyan(
|
|
49
|
-
|
|
49
|
+
"src/index.(ts|js|tsx|jsx|mjs|cjs)"
|
|
50
50
|
)} exists, or customize entry through the ${import_shared.color.cyan(
|
|
51
|
-
|
|
51
|
+
"source.entry"
|
|
52
52
|
)} configuration.`
|
|
53
53
|
);
|
|
54
54
|
}
|
package/dist/plugins/fileSize.js
CHANGED
|
@@ -101,8 +101,7 @@ async function printFileSizes(config, stats, distPath) {
|
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
assets.sort((a, b) => a.size - b.size);
|
|
104
|
-
import_shared2.logger.info(
|
|
105
|
-
`);
|
|
104
|
+
import_shared2.logger.info("Production file sizes:\n");
|
|
106
105
|
const longestLabelLength = Math.max(...assets.map((a) => a.sizeLabel.length));
|
|
107
106
|
const longestFileLength = Math.max(
|
|
108
107
|
...assets.map((a) => (a.folder + import_path.default.sep + a.name).length)
|
package/dist/plugins/html.js
CHANGED
|
@@ -149,9 +149,9 @@ const applyInjectTags = (api) => {
|
|
|
149
149
|
const config = api.getNormalizedConfig();
|
|
150
150
|
const tags = (0, import_shared.castArray)(config.html.tags).filter(Boolean);
|
|
151
151
|
const tagsByEntries = config.html.tagsByEntries || {};
|
|
152
|
-
Object.keys(tagsByEntries).forEach(
|
|
153
|
-
|
|
154
|
-
);
|
|
152
|
+
Object.keys(tagsByEntries).forEach((key) => {
|
|
153
|
+
tagsByEntries[key] = (0, import_shared.castArray)(tagsByEntries[key]).filter(Boolean);
|
|
154
|
+
});
|
|
155
155
|
const shouldByEntries = Object.values(tagsByEntries).some(
|
|
156
156
|
(entry) => Array.isArray(entry) && entry.length > 0
|
|
157
157
|
);
|
|
@@ -171,7 +171,9 @@ const applyInjectTags = (api) => {
|
|
|
171
171
|
}
|
|
172
172
|
for (const [entry, filename] of Object.entries(api.getHTMLPaths())) {
|
|
173
173
|
const opts = { ...sharedOptions, includes: [filename] };
|
|
174
|
-
entry in tagsByEntries
|
|
174
|
+
if (entry in tagsByEntries) {
|
|
175
|
+
opts.tags = tagsByEntries[entry];
|
|
176
|
+
}
|
|
175
177
|
chain.plugin(`${CHAIN_ID.PLUGIN.HTML_TAGS}#${entry}`).use(HtmlTagsPlugin, [opts]);
|
|
176
178
|
}
|
|
177
179
|
});
|
package/dist/plugins/index.js
CHANGED
|
@@ -40,8 +40,6 @@ const plugins = {
|
|
|
40
40
|
target: () => Promise.resolve().then(() => __toESM(require("./target"))).then((m) => m.pluginTarget()),
|
|
41
41
|
entry: () => Promise.resolve().then(() => __toESM(require("./entry"))).then((m) => m.pluginEntry()),
|
|
42
42
|
cache: () => Promise.resolve().then(() => __toESM(require("./cache"))).then((m) => m.pluginCache()),
|
|
43
|
-
yaml: () => Promise.resolve().then(() => __toESM(require("./yaml"))).then((m) => m.pluginYaml()),
|
|
44
|
-
toml: () => Promise.resolve().then(() => __toESM(require("./toml"))).then((m) => m.pluginToml()),
|
|
45
43
|
splitChunks: () => Promise.resolve().then(() => __toESM(require("./splitChunks"))).then((m) => m.pluginSplitChunks()),
|
|
46
44
|
inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.pluginInlineChunk()),
|
|
47
45
|
bundleAnalyzer: () => Promise.resolve().then(() => __toESM(require("./bundleAnalyzer"))).then((m) => m.pluginBundleAnalyzer()),
|
|
@@ -32,7 +32,7 @@ __export(networkPerformance_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(networkPerformance_exports);
|
|
34
34
|
const pluginNetworkPerformance = () => ({
|
|
35
|
-
name:
|
|
35
|
+
name: "plugin-network-performance",
|
|
36
36
|
setup(api) {
|
|
37
37
|
api.modifyBundlerChain(
|
|
38
38
|
async (chain, { CHAIN_ID, isServer, isWebWorker, isServiceWorker }) => {
|
|
@@ -32,7 +32,7 @@ __export(preloadOrPrefetch_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(preloadOrPrefetch_exports);
|
|
34
34
|
const pluginPreloadOrPrefetch = () => ({
|
|
35
|
-
name:
|
|
35
|
+
name: "plugin-preload-or-prefetch",
|
|
36
36
|
setup(api) {
|
|
37
37
|
api.modifyBundlerChain(
|
|
38
38
|
async (chain, { CHAIN_ID, isServer, isWebWorker, isServiceWorker }) => {
|
package/dist/plugins/server.js
CHANGED
|
@@ -29,7 +29,7 @@ const pluginServer = () => ({
|
|
|
29
29
|
api.onBeforeBuild(async () => {
|
|
30
30
|
const config = api.getNormalizedConfig();
|
|
31
31
|
if (config.server?.publicDir) {
|
|
32
|
-
const { name, copyOnBuild } = config.server
|
|
32
|
+
const { name, copyOnBuild } = config.server.publicDir;
|
|
33
33
|
if (!copyOnBuild || !name) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
package/dist/plugins/toml.d.ts
CHANGED
package/dist/plugins/toml.js
CHANGED
|
@@ -1,36 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var toml_exports = {};
|
|
20
|
-
__export(toml_exports, {
|
|
21
|
-
pluginToml: () => pluginToml
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(toml_exports);
|
|
24
|
-
var import_path = require("path");
|
|
25
|
-
const pluginToml = () => ({
|
|
26
|
-
name: "rsbuild:toml",
|
|
27
|
-
setup(api) {
|
|
28
|
-
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
29
|
-
chain.module.rule(CHAIN_ID.RULE.TOML).type("javascript/auto").test(/\.toml$/).use(CHAIN_ID.USE.TOML).loader((0, import_path.join)(__dirname, "../../compiled", "toml-loader"));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
pluginToml
|
|
36
|
-
});
|
package/dist/plugins/yaml.d.ts
CHANGED
package/dist/plugins/yaml.js
CHANGED
|
@@ -1,36 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var yaml_exports = {};
|
|
20
|
-
__export(yaml_exports, {
|
|
21
|
-
pluginYaml: () => pluginYaml
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(yaml_exports);
|
|
24
|
-
var import_shared = require("@rsbuild/shared");
|
|
25
|
-
const pluginYaml = () => ({
|
|
26
|
-
name: "rsbuild:yaml",
|
|
27
|
-
setup(api) {
|
|
28
|
-
api.modifyBundlerChain((chain, { CHAIN_ID }) => {
|
|
29
|
-
chain.module.rule(CHAIN_ID.RULE.YAML).type("javascript/auto").test(/\.ya?ml$/).use(CHAIN_ID.USE.YAML).loader((0, import_shared.getSharedPkgCompiledPath)("yaml-loader"));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
pluginYaml
|
|
36
|
-
});
|
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
import { InitConfigsOptions } from './initConfigs';
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
4
|
-
(compiler: RspackCompiler): Promise<{
|
|
5
|
-
stats?: Stats;
|
|
6
|
-
}>;
|
|
7
|
-
(compiler: RspackMultiCompiler): Promise<{
|
|
8
|
-
stats?: MultiStats;
|
|
9
|
-
}>;
|
|
10
|
-
(compiler: RspackCompiler | RspackMultiCompiler): Promise<{
|
|
11
|
-
stats?: Stats | MultiStats;
|
|
12
|
-
}>;
|
|
13
|
-
};
|
|
14
|
-
export declare const rspackBuild: BuildExecuter;
|
|
15
|
-
export declare const build: (initOptions: InitConfigsOptions, { mode, watch, compiler: customCompiler }?: BuildOptions, executer?: BuildExecuter) => Promise<void>;
|
|
2
|
+
import type { BuildOptions } from '@rsbuild/shared';
|
|
3
|
+
export declare const build: (initOptions: InitConfigsOptions, { mode, watch, compiler: customCompiler }?: BuildOptions) => Promise<void>;
|
|
@@ -18,28 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var build_exports = {};
|
|
20
20
|
__export(build_exports, {
|
|
21
|
-
build: () => build
|
|
22
|
-
rspackBuild: () => rspackBuild
|
|
21
|
+
build: () => build
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(build_exports);
|
|
25
24
|
var import_createCompiler = require("./createCompiler");
|
|
26
25
|
var import_initConfigs = require("./initConfigs");
|
|
27
26
|
var import_shared = require("@rsbuild/shared");
|
|
28
|
-
const
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
compiler.run((err, stats) => {
|
|
31
|
-
if (err || stats?.hasErrors()) {
|
|
32
|
-
const buildError = err || new Error("Rspack build failed!");
|
|
33
|
-
reject(buildError);
|
|
34
|
-
} else {
|
|
35
|
-
compiler.close(() => {
|
|
36
|
-
resolve({ stats });
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
const build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}, executer) => {
|
|
27
|
+
const build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}) => {
|
|
43
28
|
if (!process.env.NODE_ENV) {
|
|
44
29
|
process.env.NODE_ENV = mode;
|
|
45
30
|
}
|
|
@@ -56,7 +41,7 @@ const build = async (initOptions, { mode = "production", watch, compiler: custom
|
|
|
56
41
|
});
|
|
57
42
|
bundlerConfigs = rspackConfigs;
|
|
58
43
|
}
|
|
59
|
-
await context.hooks.
|
|
44
|
+
await context.hooks.onBeforeBuild.call({
|
|
60
45
|
bundlerConfigs
|
|
61
46
|
});
|
|
62
47
|
if (watch) {
|
|
@@ -65,15 +50,25 @@ const build = async (initOptions, { mode = "production", watch, compiler: custom
|
|
|
65
50
|
import_shared.logger.error(err);
|
|
66
51
|
}
|
|
67
52
|
});
|
|
68
|
-
|
|
69
|
-
const executeResult = await executer?.(compiler);
|
|
70
|
-
await context.hooks.onAfterBuildHook.call({
|
|
71
|
-
stats: executeResult?.stats
|
|
72
|
-
});
|
|
53
|
+
return;
|
|
73
54
|
}
|
|
55
|
+
const { stats } = await new Promise(
|
|
56
|
+
(resolve, reject) => {
|
|
57
|
+
compiler.run((err, stats2) => {
|
|
58
|
+
if (err || stats2?.hasErrors()) {
|
|
59
|
+
const buildError = err || new Error("Rspack build failed!");
|
|
60
|
+
reject(buildError);
|
|
61
|
+
} else {
|
|
62
|
+
compiler.close(() => {
|
|
63
|
+
resolve({ stats: stats2 });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
await context.hooks.onAfterBuild.call({ stats });
|
|
74
70
|
};
|
|
75
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
72
|
0 && (module.exports = {
|
|
77
|
-
build
|
|
78
|
-
rspackBuild
|
|
73
|
+
build
|
|
79
74
|
});
|
|
@@ -40,7 +40,7 @@ async function createCompiler({
|
|
|
40
40
|
rspackConfigs
|
|
41
41
|
}) {
|
|
42
42
|
(0, import_shared.debug)("create compiler");
|
|
43
|
-
await context.hooks.
|
|
43
|
+
await context.hooks.onBeforeCreateCompiler.call({
|
|
44
44
|
bundlerConfigs: rspackConfigs
|
|
45
45
|
});
|
|
46
46
|
const { rspack } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
@@ -101,7 +101,7 @@ async function createCompiler({
|
|
|
101
101
|
import_shared.logger.warn(message);
|
|
102
102
|
}
|
|
103
103
|
if ((0, import_shared.isDev)()) {
|
|
104
|
-
await context.hooks.
|
|
104
|
+
await context.hooks.onDevCompileDone.call({
|
|
105
105
|
isFirstCompile,
|
|
106
106
|
stats
|
|
107
107
|
});
|
|
@@ -109,7 +109,7 @@ async function createCompiler({
|
|
|
109
109
|
isCompiling = false;
|
|
110
110
|
isFirstCompile = false;
|
|
111
111
|
});
|
|
112
|
-
await context.hooks.
|
|
112
|
+
await context.hooks.onAfterCreateCompiler.call({ compiler });
|
|
113
113
|
(0, import_shared.debug)("create compiler done");
|
|
114
114
|
return compiler;
|
|
115
115
|
}
|
|
@@ -59,7 +59,7 @@ function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
59
59
|
const context = {
|
|
60
60
|
entry: config.source?.entry || getDefaultEntry(rootPath),
|
|
61
61
|
targets: config.output?.targets || [],
|
|
62
|
-
version: "0.
|
|
62
|
+
version: "0.3.0",
|
|
63
63
|
rootPath,
|
|
64
64
|
distPath,
|
|
65
65
|
cachePath,
|
|
@@ -29,7 +29,7 @@ var import_rspackConfig = require("./rspackConfig");
|
|
|
29
29
|
var import_config = require("../config");
|
|
30
30
|
async function modifyRsbuildConfig(context) {
|
|
31
31
|
(0, import_shared.debug)("modify Rsbuild config");
|
|
32
|
-
const [modified] = await context.hooks.
|
|
32
|
+
const [modified] = await context.hooks.modifyRsbuildConfig.call(
|
|
33
33
|
context.config,
|
|
34
34
|
{ mergeRsbuildConfig: import_shared.mergeRsbuildConfig }
|
|
35
35
|
);
|
|
@@ -76,8 +76,8 @@ async function initConfigs({
|
|
|
76
76
|
bundlerConfigs: rspackConfigs
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
-
context.hooks.
|
|
80
|
-
context.hooks.
|
|
79
|
+
context.hooks.onBeforeBuild.tap(inspect);
|
|
80
|
+
context.hooks.onBeforeStartDevServer.tap(inspect);
|
|
81
81
|
}
|
|
82
82
|
return {
|
|
83
83
|
rspackConfigs
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterStartProdServerFn, OnBeforeStartProdServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn } from '@rsbuild/shared';
|
|
2
2
|
export declare function initHooks(): {
|
|
3
3
|
/** parameters are not bundler-related */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
onExit: import("@rsbuild/shared").AsyncHook<OnExitFn>;
|
|
5
|
+
onDevCompileDone: import("@rsbuild/shared").AsyncHook<OnDevCompileDoneFn>;
|
|
6
|
+
onAfterStartDevServer: import("@rsbuild/shared").AsyncHook<OnAfterStartDevServerFn>;
|
|
7
|
+
onBeforeStartDevServer: import("@rsbuild/shared").AsyncHook<OnBeforeStartDevServerFn>;
|
|
8
|
+
onAfterStartProdServer: import("@rsbuild/shared").AsyncHook<OnAfterStartProdServerFn>;
|
|
9
|
+
onBeforeStartProdServer: import("@rsbuild/shared").AsyncHook<OnBeforeStartProdServerFn>;
|
|
10
10
|
/** parameters are bundler-related */
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
onAfterBuild: import("@rsbuild/shared").AsyncHook<OnAfterBuildFn>;
|
|
12
|
+
onBeforeBuild: import("@rsbuild/shared").AsyncHook<OnBeforeBuildFn>;
|
|
13
|
+
modifyRspackConfig: import("@rsbuild/shared").AsyncHook<ModifyRspackConfigFn>;
|
|
14
|
+
modifyBundlerChain: import("@rsbuild/shared").AsyncHook<ModifyBundlerChainFn>;
|
|
15
|
+
modifyWebpackChain: import("@rsbuild/shared").AsyncHook<ModifyWebpackChainFn>;
|
|
16
|
+
modifyWebpackConfig: import("@rsbuild/shared").AsyncHook<ModifyWebpackConfigFn>;
|
|
17
|
+
modifyRsbuildConfig: import("@rsbuild/shared").AsyncHook<ModifyRsbuildConfigFn>;
|
|
18
|
+
onAfterCreateCompiler: import("@rsbuild/shared").AsyncHook<OnAfterCreateCompilerFn>;
|
|
19
|
+
onBeforeCreateCompiler: import("@rsbuild/shared").AsyncHook<OnBeforeCreateCompilerFn>;
|
|
20
20
|
};
|
|
21
21
|
export type Hooks = ReturnType<typeof initHooks>;
|
|
@@ -25,22 +25,22 @@ var import_shared = require("@rsbuild/shared");
|
|
|
25
25
|
function initHooks() {
|
|
26
26
|
return {
|
|
27
27
|
/** parameters are not bundler-related */
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
onExit: (0, import_shared.createAsyncHook)(),
|
|
29
|
+
onDevCompileDone: (0, import_shared.createAsyncHook)(),
|
|
30
|
+
onAfterStartDevServer: (0, import_shared.createAsyncHook)(),
|
|
31
|
+
onBeforeStartDevServer: (0, import_shared.createAsyncHook)(),
|
|
32
|
+
onAfterStartProdServer: (0, import_shared.createAsyncHook)(),
|
|
33
|
+
onBeforeStartProdServer: (0, import_shared.createAsyncHook)(),
|
|
34
34
|
/** parameters are bundler-related */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
onAfterBuild: (0, import_shared.createAsyncHook)(),
|
|
36
|
+
onBeforeBuild: (0, import_shared.createAsyncHook)(),
|
|
37
|
+
modifyRspackConfig: (0, import_shared.createAsyncHook)(),
|
|
38
|
+
modifyBundlerChain: (0, import_shared.createAsyncHook)(),
|
|
39
|
+
modifyWebpackChain: (0, import_shared.createAsyncHook)(),
|
|
40
|
+
modifyWebpackConfig: (0, import_shared.createAsyncHook)(),
|
|
41
|
+
modifyRsbuildConfig: (0, import_shared.createAsyncHook)(),
|
|
42
|
+
onAfterCreateCompiler: (0, import_shared.createAsyncHook)(),
|
|
43
|
+
onBeforeCreateCompiler: (0, import_shared.createAsyncHook)()
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
// Annotate the CommonJS export names for ESM import in node:
|