@rsbuild/core 2.0.10 → 2.0.11
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/756.js
CHANGED
|
@@ -3084,10 +3084,10 @@ function exitHook(onExit) {
|
|
|
3084
3084
|
exitHook_callbacks.delete(onExit);
|
|
3085
3085
|
};
|
|
3086
3086
|
}
|
|
3087
|
-
let addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//'), urlJoin = (base, path)=>{
|
|
3087
|
+
let removeTailingSlash = (s)=>s.endsWith('/') ? s.replace(/\/+$/, '') : s, addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//'), urlJoin = (base, path)=>{
|
|
3088
3088
|
let [urlProtocol, baseUrl] = base.split('://');
|
|
3089
3089
|
return `${urlProtocol}://${posix.join(baseUrl, path)}`;
|
|
3090
|
-
}, ensureAssetPrefix = (url, assetPrefix = "/")=>url.startsWith('//') || external_node_url_URL.canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : posix.join(assetPrefix, url), formatPublicPath = (publicPath, withSlash = !0)=>'auto' === publicPath || '' === publicPath ? publicPath : withSlash ? addTrailingSlash(publicPath) : publicPath
|
|
3090
|
+
}, ensureAssetPrefix = (url, assetPrefix = "/")=>url.startsWith('//') || external_node_url_URL.canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : posix.join(assetPrefix, url), formatPublicPath = (publicPath, withSlash = !0)=>'auto' === publicPath || '' === publicPath ? publicPath : withSlash ? addTrailingSlash(publicPath) : removeTailingSlash(publicPath), getPublicPathFromChain = (chain, withSlash = !0)=>{
|
|
3091
3091
|
let publicPath = chain.output.get('publicPath');
|
|
3092
3092
|
return 'string' == typeof publicPath ? formatPublicPath(publicPath, withSlash) : formatPublicPath("/", withSlash);
|
|
3093
3093
|
};
|
|
@@ -3483,7 +3483,7 @@ function createPublicContext(context) {
|
|
|
3483
3483
|
async function createContext(options, userConfig, logger) {
|
|
3484
3484
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
3485
3485
|
return {
|
|
3486
|
-
version: "2.0.
|
|
3486
|
+
version: "2.0.11",
|
|
3487
3487
|
rootPath,
|
|
3488
3488
|
distPath: '',
|
|
3489
3489
|
cachePath,
|
|
@@ -5171,9 +5171,14 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (inp
|
|
|
5171
5171
|
if (prefix?.startsWith('./') && (prefix = prefix.replace('./', '')), !prefix) return '/';
|
|
5172
5172
|
let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
|
|
5173
5173
|
return `${hasLeadingSlash ? '' : '/'}${prefix}${hasTailSlash ? '' : '/'}`;
|
|
5174
|
-
}, joinUrlPath = (basePath, pathname)=>'' === basePath ? pathname : '' === pathname ? basePath : addTrailingSlash(basePath) + pathname.replace(/^\/+/, ''),
|
|
5175
|
-
let basePath = base
|
|
5176
|
-
return '' === basePath
|
|
5174
|
+
}, joinUrlPath = (basePath, pathname)=>'' === basePath ? pathname : '' === pathname ? basePath : addTrailingSlash(basePath) + pathname.replace(/^\/+/, ''), isUrlPathUnderBase = (pathname, base)=>{
|
|
5175
|
+
let basePath = removeTailingSlash(base);
|
|
5176
|
+
return '' === basePath || pathname === basePath || pathname.startsWith(`${basePath}/`);
|
|
5177
|
+
}, removeBasePath = (url, base)=>{
|
|
5178
|
+
let basePath = removeTailingSlash(base);
|
|
5179
|
+
if ('' === basePath || !url.startsWith(basePath)) return url;
|
|
5180
|
+
let nextChar = url[basePath.length];
|
|
5181
|
+
return void 0 === nextChar ? '/' : '/' === nextChar ? url.slice(basePath.length) : '?' === nextChar || '#' === nextChar ? `/${url.slice(basePath.length)}` : url;
|
|
5177
5182
|
}, getRoutes = (context)=>{
|
|
5178
5183
|
let environmentWithHtml = context.environmentList.filter((item)=>Object.keys(item.htmlPaths).length > 0);
|
|
5179
5184
|
if (0 === environmentWithHtml.length) return [];
|
|
@@ -5937,7 +5942,7 @@ async function getFileFromUrl(url, outputFileSystem, context) {
|
|
|
5937
5942
|
}), { environmentList, publicPathnames } = context, distPaths = environmentList.map((env)=>env.distPath), possibleFilenames = new Set();
|
|
5938
5943
|
for (let [index, distPath] of distPaths.entries()){
|
|
5939
5944
|
let prefix = publicPathnames[index];
|
|
5940
|
-
prefix && '/' !== prefix && pathname
|
|
5945
|
+
prefix && '/' !== prefix && isUrlPathUnderBase(pathname, prefix) && possibleFilenames.add(node_path.join(distPath, pathname.slice(prefix.length)));
|
|
5941
5946
|
}
|
|
5942
5947
|
for (let distPath of distPaths)possibleFilenames.add(node_path.join(distPath, pathname));
|
|
5943
5948
|
for (let filename of possibleFilenames){
|
|
@@ -5988,13 +5993,13 @@ function getEtag(stat) {
|
|
|
5988
5993
|
let mtime = stat.mtime.getTime().toString(16), size = stat.size.toString(16);
|
|
5989
5994
|
return `W/"${size}-${mtime}"`;
|
|
5990
5995
|
}
|
|
5991
|
-
function createReadStreamOrReadFileSync(filename, outputFileSystem, start, end) {
|
|
5996
|
+
function createReadStreamOrReadFileSync(filename, outputFileSystem, start, end, byteLength) {
|
|
5992
5997
|
return {
|
|
5993
5998
|
bufferOrStream: outputFileSystem.createReadStream(filename, {
|
|
5994
5999
|
start,
|
|
5995
6000
|
end
|
|
5996
6001
|
}),
|
|
5997
|
-
byteLength
|
|
6002
|
+
byteLength
|
|
5998
6003
|
};
|
|
5999
6004
|
}
|
|
6000
6005
|
async function getContentType(str) {
|
|
@@ -6048,7 +6053,7 @@ function sendError(res, code) {
|
|
|
6048
6053
|
let byteLength = Buffer.byteLength(document);
|
|
6049
6054
|
res.setHeader('Content-Length', byteLength), res.end(document);
|
|
6050
6055
|
}
|
|
6051
|
-
function
|
|
6056
|
+
function createAssetsMiddleware(context, ready, outputFileSystem) {
|
|
6052
6057
|
let { logger } = context;
|
|
6053
6058
|
return async function assetsMiddleware(req, res, next) {
|
|
6054
6059
|
async function goNext() {
|
|
@@ -6173,7 +6178,7 @@ function createMiddleware(context, ready, outputFileSystem) {
|
|
|
6173
6178
|
}
|
|
6174
6179
|
let [start, end] = calcStartAndEnd(offset, len);
|
|
6175
6180
|
try {
|
|
6176
|
-
({ bufferOrStream, byteLength } = createReadStreamOrReadFileSync(filename, outputFileSystem, start, end));
|
|
6181
|
+
({ bufferOrStream, byteLength } = createReadStreamOrReadFileSync(filename, outputFileSystem, start, end, len));
|
|
6177
6182
|
} catch {
|
|
6178
6183
|
await goNext();
|
|
6179
6184
|
return;
|
|
@@ -6338,7 +6343,7 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
|
|
|
6338
6343
|
return name && environments[name] && (writeToDisk = environments[name].config.dev.writeToDisk ?? writeToDisk), 'function' == typeof writeToDisk ? writeToDisk(filePath) : writeToDisk;
|
|
6339
6344
|
});
|
|
6340
6345
|
writeToDisk && setupWriteToDisk(compilers, writeToDisk, logger);
|
|
6341
|
-
let instance =
|
|
6346
|
+
let instance = createAssetsMiddleware(context, (callback)=>{
|
|
6342
6347
|
'done' === context.buildState.status ? callback() : callbacks.push(callback);
|
|
6343
6348
|
}, await setupOutputFileSystem(writeToDisk, compilers));
|
|
6344
6349
|
return instance.watch = ()=>{
|
|
@@ -6990,21 +6995,38 @@ let faviconFallbackMiddleware = (req, res, next)=>{
|
|
|
6990
6995
|
next();
|
|
6991
6996
|
}, middlewares_isFileExists = async (filePath, outputFileSystem)=>new Promise((resolve)=>{
|
|
6992
6997
|
outputFileSystem.stat(filePath, (_error, stats)=>{
|
|
6993
|
-
resolve(stats?.isFile());
|
|
6998
|
+
resolve(!!stats?.isFile());
|
|
6994
6999
|
});
|
|
6995
|
-
}),
|
|
7000
|
+
}), isFileExistsInDistPaths = async (distPaths, filename, outputFileSystem)=>{
|
|
7001
|
+
for (let distPath of distPaths)if (await middlewares_isFileExists(node_path.join(distPath, filename), outputFileSystem)) return !0;
|
|
7002
|
+
return !1;
|
|
7003
|
+
}, maybeHTMLRequest = (req)=>{
|
|
6996
7004
|
if (!req.url || !req.headers || 'GET' !== req.method && 'HEAD' !== req.method) return !1;
|
|
6997
7005
|
let { accept } = req.headers;
|
|
6998
7006
|
return 'string' == typeof accept && (accept.includes('text/html') || accept.includes('*/*'));
|
|
6999
|
-
}, postfixRE = /[?#].*$/,
|
|
7000
|
-
|
|
7001
|
-
let
|
|
7002
|
-
|
|
7007
|
+
}, postfixRE = /[?#].*$/, getHtmlCompletionMiddleware = ({ distPaths, assetsMiddleware, outputFileSystem })=>async function htmlCompletionMiddleware(req, res, next) {
|
|
7008
|
+
if (!maybeHTMLRequest(req)) return void next();
|
|
7009
|
+
let pathname = req.url.replace(postfixRE, ''), rewrite = (newUrl)=>{
|
|
7010
|
+
req.url = newUrl, assetsMiddleware(req, res, (...args)=>{
|
|
7011
|
+
next(...args);
|
|
7012
|
+
});
|
|
7013
|
+
};
|
|
7014
|
+
if (pathname.endsWith('/')) {
|
|
7015
|
+
let newUrl = `${pathname}index.html`;
|
|
7016
|
+
if (await isFileExistsInDistPaths(distPaths, newUrl, outputFileSystem)) return void rewrite(newUrl);
|
|
7017
|
+
} else if (!node_path.extname(pathname)) {
|
|
7018
|
+
let newUrl = `${pathname}.html`;
|
|
7019
|
+
if (await isFileExistsInDistPaths(distPaths, newUrl, outputFileSystem)) return void rewrite(newUrl);
|
|
7020
|
+
}
|
|
7021
|
+
next();
|
|
7022
|
+
}, getBaseUrlMiddleware = ({ base })=>function baseUrlMiddleware(req, res, next) {
|
|
7023
|
+
let url = req.url, pathname = url.replace(postfixRE, '');
|
|
7024
|
+
if (isUrlPathUnderBase(pathname, base)) {
|
|
7003
7025
|
req.url = removeBasePath(url, base), next();
|
|
7004
7026
|
return;
|
|
7005
7027
|
}
|
|
7006
7028
|
let redirectPath = addTrailingSlash(url) !== base ? joinUrlPath(base, url) : base;
|
|
7007
|
-
if ('/' ===
|
|
7029
|
+
if ('/' === pathname || '/index.html' === pathname) {
|
|
7008
7030
|
res.writeHead(302, {
|
|
7009
7031
|
Location: redirectPath
|
|
7010
7032
|
}), res.end();
|
|
@@ -7019,6 +7041,16 @@ let faviconFallbackMiddleware = (req, res, next)=>{
|
|
|
7019
7041
|
res.writeHead(404, {
|
|
7020
7042
|
'Content-Type': 'text/plain'
|
|
7021
7043
|
}), res.end(`The server is configured with a base URL of ${base} - did you mean to visit ${redirectPath} instead?`);
|
|
7044
|
+
}, getHtmlFallbackMiddleware = ({ distPaths, assetsMiddleware, outputFileSystem, logger })=>async function htmlFallbackMiddleware(req, res, next) {
|
|
7045
|
+
if (!maybeHTMLRequest(req) || '/favicon.ico' === req.url) return void next();
|
|
7046
|
+
if (await isFileExistsInDistPaths(distPaths, 'index.html', outputFileSystem)) {
|
|
7047
|
+
let newUrl = '/index.html';
|
|
7048
|
+
isVerbose(logger) && logger.debug(` ${req.method} ${req.url} ${color.yellow('fallback to')} ${newUrl}`), req.url = newUrl, assetsMiddleware(req, res, (...args)=>{
|
|
7049
|
+
next(...args);
|
|
7050
|
+
});
|
|
7051
|
+
return;
|
|
7052
|
+
}
|
|
7053
|
+
next();
|
|
7022
7054
|
};
|
|
7023
7055
|
function formatProxyOptions(proxyOptions, logger) {
|
|
7024
7056
|
let logPrefix = color.dim('[http-proxy-middleware]: '), defaultOptions = {
|
|
@@ -7148,24 +7180,12 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
7148
7180
|
logger
|
|
7149
7181
|
})), buildManager && (middlewares.use(buildManager.assetsMiddleware), upgradeEvents.push(buildManager.socketServer.upgrade), middlewares.use(function hotUpdateJsonFallbackMiddleware(req, res, next) {
|
|
7150
7182
|
req.url?.endsWith('.hot-update.json') && 'OPTIONS' !== req.method ? notFoundMiddleware(req, res, next) : next();
|
|
7151
|
-
})), buildManager && middlewares.use((
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
};
|
|
7158
|
-
if (pathname.endsWith('/')) {
|
|
7159
|
-
let newUrl = `${pathname}index.html`, filePath = node_path.join(distPath, newUrl);
|
|
7160
|
-
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) return void rewrite(newUrl);
|
|
7161
|
-
} else if (!node_path.extname(pathname)) {
|
|
7162
|
-
let newUrl = `${pathname}.html`, filePath = node_path.join(distPath, newUrl);
|
|
7163
|
-
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) return void rewrite(newUrl);
|
|
7164
|
-
}
|
|
7165
|
-
next();
|
|
7166
|
-
})({
|
|
7167
|
-
buildManager,
|
|
7168
|
-
distPath: context.distPath
|
|
7183
|
+
})), buildManager && middlewares.use(getHtmlCompletionMiddleware({
|
|
7184
|
+
assetsMiddleware: buildManager.assetsMiddleware,
|
|
7185
|
+
distPaths: [
|
|
7186
|
+
context.distPath
|
|
7187
|
+
],
|
|
7188
|
+
outputFileSystem: buildManager.outputFileSystem
|
|
7169
7189
|
})), server.publicDir.length) {
|
|
7170
7190
|
let { default: sirv } = await import("./sirv.js");
|
|
7171
7191
|
for (let { name } of server.publicDir){
|
|
@@ -7179,21 +7199,13 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
|
|
|
7179
7199
|
}
|
|
7180
7200
|
}
|
|
7181
7201
|
for (let callback of postCallbacks)await callback();
|
|
7182
|
-
return server.historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === server.historyApiFallback ? {} : server.historyApiFallback)), buildManager?.assetsMiddleware && middlewares.use(buildManager.assetsMiddleware)), buildManager && server.htmlFallback && middlewares.use((
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
});
|
|
7190
|
-
return;
|
|
7191
|
-
}
|
|
7192
|
-
next();
|
|
7193
|
-
})({
|
|
7194
|
-
buildManager,
|
|
7195
|
-
distPath: context.distPath,
|
|
7196
|
-
logger
|
|
7202
|
+
return server.historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === server.historyApiFallback ? {} : server.historyApiFallback)), buildManager?.assetsMiddleware && middlewares.use(buildManager.assetsMiddleware)), buildManager && server.htmlFallback && middlewares.use(getHtmlFallbackMiddleware({
|
|
7203
|
+
assetsMiddleware: buildManager.assetsMiddleware,
|
|
7204
|
+
distPaths: [
|
|
7205
|
+
context.distPath
|
|
7206
|
+
],
|
|
7207
|
+
logger,
|
|
7208
|
+
outputFileSystem: buildManager.outputFileSystem
|
|
7197
7209
|
})), middlewares.use(faviconFallbackMiddleware), {
|
|
7198
7210
|
onUpgrade: (...args)=>{
|
|
7199
7211
|
for (let cb of upgradeEvents)cb(...args);
|
|
@@ -7501,7 +7513,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
7501
7513
|
}
|
|
7502
7514
|
let { createServer } = await import("node:http");
|
|
7503
7515
|
return createServer(middlewares);
|
|
7504
|
-
};
|
|
7516
|
+
}, getPublicPathname = (publicPath)=>'auto' === publicPath || '' === publicPath ? '' : getPathnameFromUrl(publicPath.endsWith('/') ? publicPath : `${publicPath}/`), getPublicPathnames = (publicPaths, base)=>publicPaths.map(getPublicPathname).map((prefix)=>base && '/' !== base ? removeBasePath(prefix, base) : prefix);
|
|
7505
7517
|
async function applyServerSetup(setup, context) {
|
|
7506
7518
|
let postCallbacks = [];
|
|
7507
7519
|
for (let handler of helpers_castArray(setup || [])){
|
|
@@ -7590,10 +7602,9 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7590
7602
|
let startCompile = async ()=>{
|
|
7591
7603
|
let compiler = await createCompiler();
|
|
7592
7604
|
if (!compiler) throw Error(`${color.dim('[rsbuild:server]')} Failed to get compiler instance.`);
|
|
7593
|
-
|
|
7605
|
+
context.publicPathnames = getPublicPathnames(compiler_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
|
|
7594
7606
|
getPublicPathFromCompiler(compiler)
|
|
7595
|
-
],
|
|
7596
|
-
context.publicPathnames = publicPaths.map(getPathnameFromUrl).map((prefix)=>base && '/' !== base ? removeBasePath(prefix, base) : prefix), compiler?.hooks.watchRun.tap('rsbuild:watchRun', ()=>{
|
|
7607
|
+
], config.server.base), compiler?.hooks.watchRun.tap('rsbuild:watchRun', ()=>{
|
|
7597
7608
|
lastStats && (waitLastCompileDoneResolve && (waitLastCompileDoneResolve(), waitLastCompileDoneResolve = null), waitLastCompileDone = new Promise((resolve)=>{
|
|
7598
7609
|
waitLastCompileDoneResolve = resolve;
|
|
7599
7610
|
}));
|
|
@@ -7748,7 +7759,9 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7748
7759
|
}), state.buildManager?.watch(), logger.debug('create dev server done'), devServer;
|
|
7749
7760
|
}
|
|
7750
7761
|
async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
7751
|
-
let { logger } = context, { connect } = await import("./connect-next.js"), middlewares = connect(), { port, portTip } = await resolvePort(config), serverConfig = config.server, { host, headers, proxy, historyApiFallback, compress, base, cors } = serverConfig,
|
|
7762
|
+
let environmentList, { logger } = context, { connect } = await import("./connect-next.js"), middlewares = connect(), { port, portTip } = await resolvePort(config), serverConfig = config.server, { host, headers, proxy, historyApiFallback, compress, base, cors } = serverConfig, assetPrefixes = context.environmentList.map((environment)=>environment.config.output.assetPrefix);
|
|
7763
|
+
context.publicPathnames = getPublicPathnames(assetPrefixes, base);
|
|
7764
|
+
let protocol = serverConfig.https ? 'https' : 'http', routes = getRoutes(context), urls = await getAddressUrls({
|
|
7752
7765
|
protocol,
|
|
7753
7766
|
port,
|
|
7754
7767
|
host
|
|
@@ -7789,21 +7802,14 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
|
7789
7802
|
server: previewServer,
|
|
7790
7803
|
environments: context.environments
|
|
7791
7804
|
});
|
|
7792
|
-
let
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
}), assetPrefixes = context.environmentList.map((e)=>getPathnameFromUrl(e.config.output.assetPrefix));
|
|
7801
|
-
middlewares.use(function staticAssetMiddleware(req, res, next) {
|
|
7802
|
-
let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
|
|
7803
|
-
assetPrefix && url?.startsWith(assetPrefix) ? (req.url = url.slice(assetPrefix.length), assetsMiddleware(req, res, (...args)=>{
|
|
7804
|
-
req.url = url, next(...args);
|
|
7805
|
-
})) : assetsMiddleware(req, res, next);
|
|
7806
|
-
});
|
|
7805
|
+
let assetContext = (environmentList = context.environmentList.filter((environment)=>isWebTarget(environment.config.output.target)), {
|
|
7806
|
+
...context,
|
|
7807
|
+
environmentList,
|
|
7808
|
+
publicPathnames: environmentList.map((environment)=>context.publicPathnames[environment.index])
|
|
7809
|
+
}), assetsMiddleware = createAssetsMiddleware(assetContext, (callback)=>callback(), node_fs), htmlMiddlewareOptions = {
|
|
7810
|
+
assetsMiddleware,
|
|
7811
|
+
distPaths: assetContext.environmentList.map((environment)=>environment.distPath),
|
|
7812
|
+
outputFileSystem: node_fs
|
|
7807
7813
|
};
|
|
7808
7814
|
if (isVerbose(logger) && middlewares.use(getRequestLoggerMiddleware(logger)), cors) {
|
|
7809
7815
|
let { default: corsMiddleware } = await import("./cors.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/cors@2.8.6/node_modules/cors/lib/index.js", 23));
|
|
@@ -7826,8 +7832,11 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
|
|
|
7826
7832
|
}
|
|
7827
7833
|
for (let callback of (base && '/' !== base && middlewares.use(getBaseUrlMiddleware({
|
|
7828
7834
|
base
|
|
7829
|
-
})),
|
|
7830
|
-
return
|
|
7835
|
+
})), middlewares.use(assetsMiddleware), middlewares.use(getHtmlCompletionMiddleware(htmlMiddlewareOptions)), historyApiFallback && (middlewares.use(historyApiFallback_historyApiFallbackMiddleware(logger, !0 === historyApiFallback ? {} : historyApiFallback)), middlewares.use(assetsMiddleware)), postSetupCallbacks))await callback();
|
|
7836
|
+
return serverConfig.htmlFallback && middlewares.use(getHtmlFallbackMiddleware({
|
|
7837
|
+
...htmlMiddlewareOptions,
|
|
7838
|
+
logger
|
|
7839
|
+
})), middlewares.use(faviconFallbackMiddleware), middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), new Promise((resolve)=>{
|
|
7831
7840
|
httpServer.listen({
|
|
7832
7841
|
host,
|
|
7833
7842
|
port
|
|
@@ -9461,7 +9470,7 @@ let applyServerOptions = (command)=>{
|
|
|
9461
9470
|
};
|
|
9462
9471
|
function setupCommands() {
|
|
9463
9472
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9464
|
-
cli.version("2.0.
|
|
9473
|
+
cli.version("2.0.11"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
9465
9474
|
default: 'auto'
|
|
9466
9475
|
}).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
9467
9476
|
type: [
|
|
@@ -9532,7 +9541,7 @@ function initNodeEnv(command) {
|
|
|
9532
9541
|
}
|
|
9533
9542
|
function showGreeting() {
|
|
9534
9543
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9535
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.
|
|
9544
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.11\n`);
|
|
9536
9545
|
}
|
|
9537
9546
|
function setupLogLevel() {
|
|
9538
9547
|
if (cli_argv.length <= 3) return;
|
|
@@ -9554,5 +9563,5 @@ function runCLI() {
|
|
|
9554
9563
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
9555
9564
|
}
|
|
9556
9565
|
}
|
|
9557
|
-
let src_version = "2.0.
|
|
9566
|
+
let src_version = "2.0.11";
|
|
9558
9567
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { InternalContext, RequestHandler, Rspack } from '../../types';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function createAssetsMiddleware(context: InternalContext, ready: (callback: () => void) => void, outputFileSystem: Rspack.OutputFileSystem): RequestHandler;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { type Logger } from '../logger';
|
|
2
|
-
import type { Connect, EnvironmentAPI, RequestHandler } from '../types';
|
|
3
|
-
import type { BuildManager } from './buildManager';
|
|
2
|
+
import type { Connect, EnvironmentAPI, RequestHandler, Rspack } from '../types';
|
|
4
3
|
export declare const faviconFallbackMiddleware: RequestHandler;
|
|
5
4
|
export declare const getRequestLoggerMiddleware: (logger: Logger) => Connect.NextHandleFunction;
|
|
6
5
|
export declare const notFoundMiddleware: RequestHandler;
|
|
7
6
|
export declare const optionsFallbackMiddleware: RequestHandler;
|
|
7
|
+
type HtmlAssetsMiddlewareOptions = {
|
|
8
|
+
distPaths: string[];
|
|
9
|
+
assetsMiddleware: RequestHandler;
|
|
10
|
+
outputFileSystem: Rspack.OutputFileSystem;
|
|
11
|
+
};
|
|
8
12
|
/**
|
|
9
13
|
* Support access HTML without suffix
|
|
10
|
-
*/ export declare const getHtmlCompletionMiddleware: (params:
|
|
11
|
-
distPath: string;
|
|
12
|
-
buildManager: BuildManager;
|
|
13
|
-
}) => RequestHandler;
|
|
14
|
+
*/ export declare const getHtmlCompletionMiddleware: (params: HtmlAssetsMiddlewareOptions) => RequestHandler;
|
|
14
15
|
/**
|
|
15
16
|
* handle `server.base`
|
|
16
17
|
*/ export declare const getBaseUrlMiddleware: (params: {
|
|
@@ -18,9 +19,7 @@ export declare const optionsFallbackMiddleware: RequestHandler;
|
|
|
18
19
|
}) => RequestHandler;
|
|
19
20
|
/**
|
|
20
21
|
* support HTML fallback in some edge cases
|
|
21
|
-
*/ export declare const getHtmlFallbackMiddleware: (params: {
|
|
22
|
-
distPath: string;
|
|
23
|
-
buildManager: BuildManager;
|
|
22
|
+
*/ export declare const getHtmlFallbackMiddleware: (params: HtmlAssetsMiddlewareOptions & {
|
|
24
23
|
logger: Logger;
|
|
25
24
|
}) => RequestHandler;
|
|
26
25
|
/**
|
|
@@ -29,3 +28,4 @@ export declare const optionsFallbackMiddleware: RequestHandler;
|
|
|
29
28
|
environments: EnvironmentAPI;
|
|
30
29
|
logger: Logger;
|
|
31
30
|
}) => RequestHandler;
|
|
31
|
+
export { };
|