@rsbuild/core 0.7.4 → 0.7.6
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/index.cjs +43 -25
- package/dist/index.js +43 -25
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1003,7 +1003,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
1003
1003
|
return {
|
|
1004
1004
|
entry: getEntryObject(config, "web"),
|
|
1005
1005
|
targets: config.output?.targets || [],
|
|
1006
|
-
version: "0.7.
|
|
1006
|
+
version: "0.7.6",
|
|
1007
1007
|
rootPath,
|
|
1008
1008
|
distPath,
|
|
1009
1009
|
cachePath,
|
|
@@ -5078,7 +5078,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
5078
5078
|
}
|
|
5079
5079
|
};
|
|
5080
5080
|
}
|
|
5081
|
-
async function applyCoreJs(swcConfig,
|
|
5081
|
+
async function applyCoreJs(swcConfig, polyfillMode) {
|
|
5082
5082
|
const coreJsPath = require.resolve("core-js/package.json");
|
|
5083
5083
|
const version2 = (0, import_shared42.getCoreJsVersion)(coreJsPath);
|
|
5084
5084
|
const coreJsDir = import_node_path23.default.dirname(coreJsPath);
|
|
@@ -5086,9 +5086,7 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
|
|
|
5086
5086
|
if (polyfillMode === "usage") {
|
|
5087
5087
|
swcConfig.env.shippedProposals = true;
|
|
5088
5088
|
}
|
|
5089
|
-
|
|
5090
|
-
"core-js": coreJsDir
|
|
5091
|
-
});
|
|
5089
|
+
return coreJsDir;
|
|
5092
5090
|
}
|
|
5093
5091
|
function applyTransformImport(swcConfig, pluginImport) {
|
|
5094
5092
|
if (pluginImport !== false && pluginImport) {
|
|
@@ -5134,6 +5132,9 @@ var init_swc = __esm({
|
|
|
5134
5132
|
handler: async (chain, { CHAIN_ID: CHAIN_ID3, target }) => {
|
|
5135
5133
|
const config = api.getNormalizedConfig();
|
|
5136
5134
|
const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(import_shared42.SCRIPT_REGEX).type("javascript/auto");
|
|
5135
|
+
const dataUriRule = chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
|
|
5136
|
+
or: ["text/javascript", "application/javascript"]
|
|
5137
|
+
});
|
|
5137
5138
|
(0, import_shared42.applyScriptCondition)({
|
|
5138
5139
|
rule,
|
|
5139
5140
|
chain,
|
|
@@ -5161,7 +5162,10 @@ var init_swc = __esm({
|
|
|
5161
5162
|
swcConfig.env.mode = void 0;
|
|
5162
5163
|
} else {
|
|
5163
5164
|
swcConfig.env.mode = polyfillMode;
|
|
5164
|
-
await applyCoreJs(swcConfig,
|
|
5165
|
+
const coreJsDir = await applyCoreJs(swcConfig, polyfillMode);
|
|
5166
|
+
for (const item of [rule, dataUriRule]) {
|
|
5167
|
+
item.resolve.alias.set("core-js", coreJsDir);
|
|
5168
|
+
}
|
|
5165
5169
|
}
|
|
5166
5170
|
}
|
|
5167
5171
|
const mergedSwcConfig = (0, import_shared42.reduceConfigs)({
|
|
@@ -5170,9 +5174,7 @@ var init_swc = __esm({
|
|
|
5170
5174
|
mergeFn: import_shared42.deepmerge
|
|
5171
5175
|
});
|
|
5172
5176
|
rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
|
|
5173
|
-
|
|
5174
|
-
or: ["text/javascript", "application/javascript"]
|
|
5175
|
-
}).resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared42.cloneDeep)(mergedSwcConfig));
|
|
5177
|
+
dataUriRule.resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared42.cloneDeep)(mergedSwcConfig));
|
|
5176
5178
|
}
|
|
5177
5179
|
});
|
|
5178
5180
|
}
|
|
@@ -5478,25 +5480,24 @@ function pluginOpen() {
|
|
|
5478
5480
|
const onStartServer = async (params) => {
|
|
5479
5481
|
const { port, routes } = params;
|
|
5480
5482
|
const config = api.getNormalizedConfig();
|
|
5481
|
-
const { beforeStartUrl } = config.dev;
|
|
5482
|
-
const open = config.server.open || config.dev.startUrl;
|
|
5483
5483
|
const { https } = api.context.devServer || {};
|
|
5484
|
+
const { targets, before } = normalizeOpenConfig(config);
|
|
5484
5485
|
const isCodesandbox = process.env.CSB === "true";
|
|
5485
|
-
const shouldOpen =
|
|
5486
|
+
const shouldOpen = targets !== void 0 && !isCodesandbox;
|
|
5486
5487
|
if (!shouldOpen) {
|
|
5487
5488
|
return;
|
|
5488
5489
|
}
|
|
5489
5490
|
const urls = [];
|
|
5490
5491
|
const protocol = https ? "https" : "http";
|
|
5491
5492
|
const baseUrl = `${protocol}://localhost:${port}`;
|
|
5492
|
-
if (
|
|
5493
|
+
if (!targets.length) {
|
|
5493
5494
|
if (routes.length) {
|
|
5494
5495
|
urls.push(`${baseUrl}${routes[0].pathname}`);
|
|
5495
5496
|
}
|
|
5496
5497
|
} else {
|
|
5497
5498
|
urls.push(
|
|
5498
|
-
...
|
|
5499
|
-
(
|
|
5499
|
+
...targets.map(
|
|
5500
|
+
(target) => resolveUrl(replacePlaceholder(target, port), baseUrl)
|
|
5500
5501
|
)
|
|
5501
5502
|
);
|
|
5502
5503
|
}
|
|
@@ -5508,20 +5509,17 @@ function pluginOpen() {
|
|
|
5508
5509
|
}
|
|
5509
5510
|
}
|
|
5510
5511
|
};
|
|
5511
|
-
if (
|
|
5512
|
-
|
|
5513
|
-
openUrls
|
|
5514
|
-
);
|
|
5515
|
-
} else {
|
|
5516
|
-
openUrls();
|
|
5512
|
+
if (before) {
|
|
5513
|
+
await before();
|
|
5517
5514
|
}
|
|
5515
|
+
openUrls();
|
|
5518
5516
|
};
|
|
5519
5517
|
api.onAfterStartDevServer(onStartServer);
|
|
5520
5518
|
api.onAfterStartProdServer(onStartServer);
|
|
5521
5519
|
}
|
|
5522
5520
|
};
|
|
5523
5521
|
}
|
|
5524
|
-
var import_node_child_process, import_node_util, import_shared44, execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs;
|
|
5522
|
+
var import_node_child_process, import_node_util, import_shared44, execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs, normalizeOpenConfig;
|
|
5525
5523
|
var init_open = __esm({
|
|
5526
5524
|
"src/plugins/open.ts"() {
|
|
5527
5525
|
"use strict";
|
|
@@ -5550,6 +5548,26 @@ var init_open = __esm({
|
|
|
5550
5548
|
};
|
|
5551
5549
|
replacePlaceholder = (url2, port) => url2.replace(/<port>/g, String(port));
|
|
5552
5550
|
openedURLs = [];
|
|
5551
|
+
normalizeOpenConfig = (config) => {
|
|
5552
|
+
const open = config.server.open || config.dev.startUrl;
|
|
5553
|
+
const { beforeStartUrl } = config.dev;
|
|
5554
|
+
if (open === false) {
|
|
5555
|
+
return {};
|
|
5556
|
+
}
|
|
5557
|
+
if (open === true) {
|
|
5558
|
+
return { targets: [], before: beforeStartUrl };
|
|
5559
|
+
}
|
|
5560
|
+
if (typeof open === "string") {
|
|
5561
|
+
return { targets: [open], before: beforeStartUrl };
|
|
5562
|
+
}
|
|
5563
|
+
if (Array.isArray(open)) {
|
|
5564
|
+
return { targets: open, before: beforeStartUrl };
|
|
5565
|
+
}
|
|
5566
|
+
return {
|
|
5567
|
+
targets: open.target ? (0, import_shared44.castArray)(open.target) : [],
|
|
5568
|
+
before: open.before
|
|
5569
|
+
};
|
|
5570
|
+
};
|
|
5553
5571
|
}
|
|
5554
5572
|
});
|
|
5555
5573
|
|
|
@@ -7206,7 +7224,7 @@ var applyServerOptions = (command) => {
|
|
|
7206
7224
|
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");
|
|
7207
7225
|
};
|
|
7208
7226
|
function runCli() {
|
|
7209
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
7227
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.6");
|
|
7210
7228
|
const devCommand = import_commander.program.command("dev");
|
|
7211
7229
|
const buildCommand = import_commander.program.command("build");
|
|
7212
7230
|
const previewCommand = import_commander.program.command("preview");
|
|
@@ -7296,7 +7314,7 @@ function prepareCli() {
|
|
|
7296
7314
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
7297
7315
|
console.log();
|
|
7298
7316
|
}
|
|
7299
|
-
import_shared61.logger.greet(` ${`Rsbuild v${"0.7.
|
|
7317
|
+
import_shared61.logger.greet(` ${`Rsbuild v${"0.7.6"}`}
|
|
7300
7318
|
`);
|
|
7301
7319
|
}
|
|
7302
7320
|
|
|
@@ -7323,7 +7341,7 @@ init_config();
|
|
|
7323
7341
|
var import_shared62 = require("@rsbuild/shared");
|
|
7324
7342
|
init_mergeConfig();
|
|
7325
7343
|
init_constants();
|
|
7326
|
-
var version = "0.7.
|
|
7344
|
+
var version = "0.7.6";
|
|
7327
7345
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7328
7346
|
0 && (module.exports = {
|
|
7329
7347
|
PLUGIN_CSS_NAME,
|
package/dist/index.js
CHANGED
|
@@ -1042,7 +1042,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
1042
1042
|
return {
|
|
1043
1043
|
entry: getEntryObject(config, "web"),
|
|
1044
1044
|
targets: config.output?.targets || [],
|
|
1045
|
-
version: "0.7.
|
|
1045
|
+
version: "0.7.6",
|
|
1046
1046
|
rootPath,
|
|
1047
1047
|
distPath,
|
|
1048
1048
|
cachePath,
|
|
@@ -5249,7 +5249,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
5249
5249
|
}
|
|
5250
5250
|
};
|
|
5251
5251
|
}
|
|
5252
|
-
async function applyCoreJs(swcConfig,
|
|
5252
|
+
async function applyCoreJs(swcConfig, polyfillMode) {
|
|
5253
5253
|
const coreJsPath = __require.resolve("core-js/package.json");
|
|
5254
5254
|
const version2 = getCoreJsVersion(coreJsPath);
|
|
5255
5255
|
const coreJsDir = path11.dirname(coreJsPath);
|
|
@@ -5257,9 +5257,7 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
|
|
|
5257
5257
|
if (polyfillMode === "usage") {
|
|
5258
5258
|
swcConfig.env.shippedProposals = true;
|
|
5259
5259
|
}
|
|
5260
|
-
|
|
5261
|
-
"core-js": coreJsDir
|
|
5262
|
-
});
|
|
5260
|
+
return coreJsDir;
|
|
5263
5261
|
}
|
|
5264
5262
|
function applyTransformImport(swcConfig, pluginImport) {
|
|
5265
5263
|
if (pluginImport !== false && pluginImport) {
|
|
@@ -5304,6 +5302,9 @@ var init_swc = __esm({
|
|
|
5304
5302
|
handler: async (chain, { CHAIN_ID: CHAIN_ID3, target }) => {
|
|
5305
5303
|
const config = api.getNormalizedConfig();
|
|
5306
5304
|
const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(SCRIPT_REGEX).type("javascript/auto");
|
|
5305
|
+
const dataUriRule = chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
|
|
5306
|
+
or: ["text/javascript", "application/javascript"]
|
|
5307
|
+
});
|
|
5307
5308
|
applyScriptCondition({
|
|
5308
5309
|
rule,
|
|
5309
5310
|
chain,
|
|
@@ -5331,7 +5332,10 @@ var init_swc = __esm({
|
|
|
5331
5332
|
swcConfig.env.mode = void 0;
|
|
5332
5333
|
} else {
|
|
5333
5334
|
swcConfig.env.mode = polyfillMode;
|
|
5334
|
-
await applyCoreJs(swcConfig,
|
|
5335
|
+
const coreJsDir = await applyCoreJs(swcConfig, polyfillMode);
|
|
5336
|
+
for (const item of [rule, dataUriRule]) {
|
|
5337
|
+
item.resolve.alias.set("core-js", coreJsDir);
|
|
5338
|
+
}
|
|
5335
5339
|
}
|
|
5336
5340
|
}
|
|
5337
5341
|
const mergedSwcConfig = reduceConfigs2({
|
|
@@ -5340,9 +5344,7 @@ var init_swc = __esm({
|
|
|
5340
5344
|
mergeFn: deepmerge5
|
|
5341
5345
|
});
|
|
5342
5346
|
rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
|
|
5343
|
-
|
|
5344
|
-
or: ["text/javascript", "application/javascript"]
|
|
5345
|
-
}).resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(cloneDeep(mergedSwcConfig));
|
|
5347
|
+
dataUriRule.resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(cloneDeep(mergedSwcConfig));
|
|
5346
5348
|
}
|
|
5347
5349
|
});
|
|
5348
5350
|
}
|
|
@@ -5661,25 +5663,24 @@ function pluginOpen() {
|
|
|
5661
5663
|
const onStartServer = async (params) => {
|
|
5662
5664
|
const { port, routes } = params;
|
|
5663
5665
|
const config = api.getNormalizedConfig();
|
|
5664
|
-
const { beforeStartUrl } = config.dev;
|
|
5665
|
-
const open = config.server.open || config.dev.startUrl;
|
|
5666
5666
|
const { https } = api.context.devServer || {};
|
|
5667
|
+
const { targets, before } = normalizeOpenConfig(config);
|
|
5667
5668
|
const isCodesandbox = process.env.CSB === "true";
|
|
5668
|
-
const shouldOpen =
|
|
5669
|
+
const shouldOpen = targets !== void 0 && !isCodesandbox;
|
|
5669
5670
|
if (!shouldOpen) {
|
|
5670
5671
|
return;
|
|
5671
5672
|
}
|
|
5672
5673
|
const urls = [];
|
|
5673
5674
|
const protocol = https ? "https" : "http";
|
|
5674
5675
|
const baseUrl = `${protocol}://localhost:${port}`;
|
|
5675
|
-
if (
|
|
5676
|
+
if (!targets.length) {
|
|
5676
5677
|
if (routes.length) {
|
|
5677
5678
|
urls.push(`${baseUrl}${routes[0].pathname}`);
|
|
5678
5679
|
}
|
|
5679
5680
|
} else {
|
|
5680
5681
|
urls.push(
|
|
5681
|
-
...
|
|
5682
|
-
(
|
|
5682
|
+
...targets.map(
|
|
5683
|
+
(target) => resolveUrl(replacePlaceholder(target, port), baseUrl)
|
|
5683
5684
|
)
|
|
5684
5685
|
);
|
|
5685
5686
|
}
|
|
@@ -5691,20 +5692,17 @@ function pluginOpen() {
|
|
|
5691
5692
|
}
|
|
5692
5693
|
}
|
|
5693
5694
|
};
|
|
5694
|
-
if (
|
|
5695
|
-
|
|
5696
|
-
openUrls
|
|
5697
|
-
);
|
|
5698
|
-
} else {
|
|
5699
|
-
openUrls();
|
|
5695
|
+
if (before) {
|
|
5696
|
+
await before();
|
|
5700
5697
|
}
|
|
5698
|
+
openUrls();
|
|
5701
5699
|
};
|
|
5702
5700
|
api.onAfterStartDevServer(onStartServer);
|
|
5703
5701
|
api.onAfterStartProdServer(onStartServer);
|
|
5704
5702
|
}
|
|
5705
5703
|
};
|
|
5706
5704
|
}
|
|
5707
|
-
var execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs;
|
|
5705
|
+
var execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs, normalizeOpenConfig;
|
|
5708
5706
|
var init_open = __esm({
|
|
5709
5707
|
"src/plugins/open.ts"() {
|
|
5710
5708
|
"use strict";
|
|
@@ -5731,6 +5729,26 @@ var init_open = __esm({
|
|
|
5731
5729
|
};
|
|
5732
5730
|
replacePlaceholder = (url2, port) => url2.replace(/<port>/g, String(port));
|
|
5733
5731
|
openedURLs = [];
|
|
5732
|
+
normalizeOpenConfig = (config) => {
|
|
5733
|
+
const open = config.server.open || config.dev.startUrl;
|
|
5734
|
+
const { beforeStartUrl } = config.dev;
|
|
5735
|
+
if (open === false) {
|
|
5736
|
+
return {};
|
|
5737
|
+
}
|
|
5738
|
+
if (open === true) {
|
|
5739
|
+
return { targets: [], before: beforeStartUrl };
|
|
5740
|
+
}
|
|
5741
|
+
if (typeof open === "string") {
|
|
5742
|
+
return { targets: [open], before: beforeStartUrl };
|
|
5743
|
+
}
|
|
5744
|
+
if (Array.isArray(open)) {
|
|
5745
|
+
return { targets: open, before: beforeStartUrl };
|
|
5746
|
+
}
|
|
5747
|
+
return {
|
|
5748
|
+
targets: open.target ? castArray6(open.target) : [],
|
|
5749
|
+
before: open.before
|
|
5750
|
+
};
|
|
5751
|
+
};
|
|
5734
5752
|
}
|
|
5735
5753
|
});
|
|
5736
5754
|
|
|
@@ -7416,7 +7434,7 @@ var applyServerOptions = (command) => {
|
|
|
7416
7434
|
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");
|
|
7417
7435
|
};
|
|
7418
7436
|
function runCli() {
|
|
7419
|
-
program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
7437
|
+
program.name("rsbuild").usage("<command> [options]").version("0.7.6");
|
|
7420
7438
|
const devCommand = program.command("dev");
|
|
7421
7439
|
const buildCommand = program.command("build");
|
|
7422
7440
|
const previewCommand = program.command("preview");
|
|
@@ -7507,7 +7525,7 @@ function prepareCli() {
|
|
|
7507
7525
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
7508
7526
|
console.log();
|
|
7509
7527
|
}
|
|
7510
|
-
logger19.greet(` ${`Rsbuild v${"0.7.
|
|
7528
|
+
logger19.greet(` ${`Rsbuild v${"0.7.6"}`}
|
|
7511
7529
|
`);
|
|
7512
7530
|
}
|
|
7513
7531
|
|
|
@@ -7535,7 +7553,7 @@ init_config();
|
|
|
7535
7553
|
init_mergeConfig();
|
|
7536
7554
|
init_constants();
|
|
7537
7555
|
import { logger as logger20 } from "@rsbuild/shared";
|
|
7538
|
-
var version = "0.7.
|
|
7556
|
+
var version = "0.7.6";
|
|
7539
7557
|
export {
|
|
7540
7558
|
PLUGIN_CSS_NAME,
|
|
7541
7559
|
PLUGIN_SWC_NAME,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"core-js": "~3.36.0",
|
|
52
52
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.7.2",
|
|
53
53
|
"postcss": "^8.4.38",
|
|
54
|
-
"@rsbuild/shared": "0.7.
|
|
54
|
+
"@rsbuild/shared": "0.7.6"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/connect": "3.4.38",
|