@rsbuild/core
Advanced tools
@@ -86,3 +86,3 @@ "use strict"; | ||
function runCli() { | ||
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.14"); | ||
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.15"); | ||
import_commander.program.command("dev").option("--open [url]", "open the page in browser on startup").option( | ||
@@ -89,0 +89,0 @@ "--port <port>", |
@@ -37,3 +37,3 @@ "use strict"; | ||
} | ||
import_rslog.logger.greet(` ${`Rsbuild v${"0.2.14"}`} | ||
import_rslog.logger.greet(` ${`Rsbuild v${"0.2.15"}`} | ||
`); | ||
@@ -40,0 +40,0 @@ } |
@@ -34,35 +34,11 @@ "use strict"; | ||
Object.keys(entry).forEach((entryName) => { | ||
const entryImport = []; | ||
let entryDescription = null; | ||
const appendEntry = (item) => { | ||
if (typeof item === "string") { | ||
entryImport.push(item); | ||
return; | ||
} | ||
if (item.import) { | ||
entryImport.push(...(0, import_shared.castArray)(item.import)); | ||
} | ||
if (entryDescription) { | ||
Object.assign(entryDescription, item); | ||
} else { | ||
entryDescription = item; | ||
} | ||
const entryPoint = chain.entry(entryName); | ||
const addEntry = (item) => { | ||
entryPoint.add(item); | ||
}; | ||
preEntry.forEach(appendEntry); | ||
preEntry.forEach(addEntry); | ||
if (injectCoreJsEntry) { | ||
appendEntry((0, import_shared.createVirtualModule)('import "core-js";')); | ||
addEntry((0, import_shared.createVirtualModule)('import "core-js";')); | ||
} | ||
(0, import_shared.castArray)(entry[entryName]).forEach(appendEntry); | ||
chain.entryPoints.set(entryName, { | ||
// @ts-expect-error EntryDescription type mismatch | ||
values() { | ||
if (entryDescription) { | ||
return { | ||
...entryDescription, | ||
import: entryImport | ||
}; | ||
} | ||
return entryImport; | ||
} | ||
}); | ||
(0, import_shared.castArray)(entry[entryName]).forEach(addEntry); | ||
}); | ||
@@ -69,0 +45,0 @@ }); |
@@ -62,3 +62,3 @@ "use strict"; | ||
targets: config.output?.targets || [], | ||
version: "0.2.14", | ||
version: "0.2.15", | ||
rootPath, | ||
@@ -65,0 +65,0 @@ distPath, |
@@ -128,3 +128,3 @@ "use strict"; | ||
}); | ||
let rspackConfig = chain.toConfig(); | ||
let rspackConfig = (0, import_shared.chainToConfig)(chain); | ||
rspackConfig = await modifyRspackConfig( | ||
@@ -131,0 +131,0 @@ context, |
@@ -138,3 +138,3 @@ "use strict"; | ||
let urls = (0, import_shared.getAddressUrls)(protocol, port, host); | ||
if (printURLs && devServerConfig.printUrls !== false) { | ||
if (printURLs) { | ||
if ((0, import_shared.isFunction)(printURLs)) { | ||
@@ -146,3 +146,10 @@ urls = printURLs(urls); | ||
} | ||
(0, import_helper.printServerURLs)(urls, defaultRoutes, logger); | ||
(0, import_helper.printServerURLs)({ | ||
urls, | ||
port, | ||
routes: defaultRoutes, | ||
logger, | ||
protocol, | ||
printUrls: devServerConfig.printUrls | ||
}); | ||
} | ||
@@ -149,0 +156,0 @@ const compileMiddlewareAPI = await serverAPIs.startCompile(); |
/// <reference types="node" /> | ||
import type { Logger, Routes, DevConfig, RsbuildEntry, RsbuildConfig, OutputStructure } from '@rsbuild/shared'; | ||
import type { Logger, Routes, DevConfig, PrintUrls, RsbuildEntry, RsbuildConfig, OutputStructure } from '@rsbuild/shared'; | ||
export declare const formatRoutes: (entry: RsbuildEntry, prefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes; | ||
export declare function printServerURLs(urls: Array<{ | ||
url: string; | ||
label: string; | ||
}>, routes: Routes, logger?: Logger): void; | ||
export declare function printServerURLs({ urls, port, routes, protocol, printUrls, logger, }: { | ||
urls: Array<{ | ||
url: string; | ||
label: string; | ||
}>; | ||
port: number; | ||
routes: Routes; | ||
logger?: Logger; | ||
protocol: string; | ||
printUrls?: PrintUrls; | ||
}): void; | ||
/** | ||
@@ -57,3 +64,3 @@ * hmr socket connect path | ||
strictPort?: boolean | undefined; | ||
printUrls?: boolean | undefined; | ||
printUrls?: PrintUrls | undefined; | ||
}; | ||
@@ -60,0 +67,0 @@ port: number; |
@@ -37,3 +37,21 @@ "use strict"; | ||
}; | ||
function printServerURLs(urls, routes, logger = import_shared.logger) { | ||
function printServerURLs({ | ||
urls, | ||
port, | ||
routes, | ||
protocol, | ||
printUrls, | ||
logger = import_shared.logger | ||
}) { | ||
if (printUrls === false) { | ||
return; | ||
} | ||
if ((0, import_shared.isFunction)(printUrls)) { | ||
printUrls({ | ||
urls: urls.map((item) => item.url), | ||
port, | ||
protocol | ||
}); | ||
return; | ||
} | ||
let message = ""; | ||
@@ -40,0 +58,0 @@ if (routes.length === 1) { |
@@ -156,9 +156,11 @@ "use strict"; | ||
}); | ||
const urls = (0, import_shared.getAddressUrls)(https ? "https" : "http", port); | ||
if (printURLs && serverConfig.printUrls !== false) { | ||
(0, import_helper.printServerURLs)( | ||
(0, import_shared.isFunction)(printURLs) ? printURLs(urls) : urls, | ||
routes | ||
); | ||
} | ||
const protocol = https ? "https" : "http"; | ||
const urls = (0, import_shared.getAddressUrls)(protocol, port); | ||
(0, import_helper.printServerURLs)({ | ||
urls: (0, import_shared.isFunction)(printURLs) ? printURLs(urls) : urls, | ||
port, | ||
routes, | ||
protocol, | ||
printUrls: serverConfig.printUrls | ||
}); | ||
const onClose = () => { | ||
@@ -165,0 +167,0 @@ server.close(); |
{ | ||
"name": "@rsbuild/core", | ||
"version": "0.2.14", | ||
"version": "0.2.15", | ||
"description": "Unleash the power of Rspack with the out-of-the-box build tool.", | ||
@@ -63,3 +63,3 @@ "homepage": "https://rsbuild.dev", | ||
"postcss": "8.4.31", | ||
"@rsbuild/shared": "0.2.14" | ||
"@rsbuild/shared": "0.2.15" | ||
}, | ||
@@ -66,0 +66,0 @@ "devDependencies": { |
9821
0.1%530774
-0.03%