@rsbuild/core 1.7.1 → 1.7.2
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/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/131.js +56 -43
- package/dist/index.cjs +80 -66
- package/dist-types/helpers/fs.d.ts +4 -0
- package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +1 -2
- package/dist-types/server/helper.d.ts +10 -8
- package/dist-types/server/proxy.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2982,6 +2982,13 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2982
2982
|
}) : resolve(!1);
|
|
2983
2983
|
});
|
|
2984
2984
|
}
|
|
2985
|
+
function readFileAsync(fs, filename) {
|
|
2986
|
+
return new Promise((resolve, reject)=>{
|
|
2987
|
+
fs.readFile(filename, (err, data)=>{
|
|
2988
|
+
err ? reject(err) : void 0 === data ? reject(Error(`Failed to read file: ${filename}, data is undefined`)) : resolve(data);
|
|
2989
|
+
});
|
|
2990
|
+
});
|
|
2991
|
+
}
|
|
2985
2992
|
async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
2986
2993
|
if (!checkExists || await pathExists(dir)) try {
|
|
2987
2994
|
let entries = await external_node_fs_default().promises.readdir(dir, {
|
|
@@ -2989,7 +2996,11 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2989
2996
|
});
|
|
2990
2997
|
await Promise.all(entries.map(async (entry)=>{
|
|
2991
2998
|
let fullPath = external_node_path_default().join(dir, entry.name);
|
|
2992
|
-
|
|
2999
|
+
if (keep.length) {
|
|
3000
|
+
let posixFullPath = toPosixPath(fullPath);
|
|
3001
|
+
if (keep.some((regex)=>regex.test(posixFullPath))) return;
|
|
3002
|
+
}
|
|
3003
|
+
entry.isDirectory() ? (await emptyDir(fullPath, keep, !1), keep.length || await external_node_fs_default().promises.rmdir(fullPath)) : await external_node_fs_default().promises.unlink(fullPath);
|
|
2993
3004
|
}));
|
|
2994
3005
|
} catch (err) {
|
|
2995
3006
|
src_logger.debug(`failed to empty dir: ${dir}`), src_logger.debug(err);
|
|
@@ -3689,7 +3700,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3689
3700
|
async function createContext(options, userConfig) {
|
|
3690
3701
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
|
|
3691
3702
|
return {
|
|
3692
|
-
version: "1.7.
|
|
3703
|
+
version: "1.7.2",
|
|
3693
3704
|
rootPath,
|
|
3694
3705
|
distPath: '',
|
|
3695
3706
|
cachePath,
|
|
@@ -4592,9 +4603,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4592
4603
|
}
|
|
4593
4604
|
let external_node_zlib_namespaceObject = require("node:zlib");
|
|
4594
4605
|
var external_node_zlib_default = __webpack_require__.n(external_node_zlib_namespaceObject);
|
|
4595
|
-
let fileSize_gzip = (0, external_node_util_.promisify)(external_node_zlib_default().gzip);
|
|
4596
4606
|
async function gzipSize(input) {
|
|
4597
|
-
let data = await
|
|
4607
|
+
let data = await new Promise((resolve, reject)=>{
|
|
4608
|
+
external_node_zlib_default().gzip(input, (err, result)=>{
|
|
4609
|
+
err ? reject(err) : resolve(result);
|
|
4610
|
+
});
|
|
4611
|
+
});
|
|
4598
4612
|
return Buffer.byteLength(data);
|
|
4599
4613
|
}
|
|
4600
4614
|
function getSnapshotPath(dir, snapshotHash) {
|
|
@@ -4843,16 +4857,17 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4843
4857
|
}
|
|
4844
4858
|
apply(compiler) {
|
|
4845
4859
|
let emitFavicon = async ({ compilation, favicon, faviconDistPath })=>{
|
|
4846
|
-
let
|
|
4860
|
+
let fileContent, name = external_node_path_default().basename(favicon);
|
|
4847
4861
|
if (compilation.assets[name]) return name;
|
|
4848
|
-
|
|
4862
|
+
let inputFs = compilation.inputFileSystem;
|
|
4863
|
+
if (!inputFs) return addCompilationError(compilation, `${color.dim('[rsbuild:html]')} Failed to read the favicon file as ${color.yellow('compilation.inputFileSystem')} is not available.`), null;
|
|
4849
4864
|
let inputFilename = external_node_path_default().isAbsolute(favicon) ? favicon : external_node_path_default().join(compilation.compiler.context, favicon);
|
|
4850
4865
|
try {
|
|
4851
|
-
|
|
4866
|
+
fileContent = await readFileAsync(inputFs, inputFilename);
|
|
4852
4867
|
} catch (error) {
|
|
4853
4868
|
return src_logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${color.dim('[rsbuild:html]')} Failed to read the favicon file at ${color.yellow(inputFilename)}.`), null;
|
|
4854
4869
|
}
|
|
4855
|
-
let source = new compiler.webpack.sources.RawSource(
|
|
4870
|
+
let source = new compiler.webpack.sources.RawSource(fileContent, !1), outputFilename = external_node_path_default().posix.join(faviconDistPath, name);
|
|
4856
4871
|
return compilation.emitAsset(outputFilename, source), outputFilename;
|
|
4857
4872
|
}, addFavicon = async ({ headTags, favicon, faviconDistPath, compilation, publicPath })=>{
|
|
4858
4873
|
let href = favicon;
|
|
@@ -5268,7 +5283,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5268
5283
|
function escapeHtml(text) {
|
|
5269
5284
|
return text ? text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') : '';
|
|
5270
5285
|
}
|
|
5271
|
-
let supportedChromiumBrowsers = [
|
|
5286
|
+
let HttpCode_Ok = 200, HttpCode_NotModified = 304, HttpCode_BadRequest = 400, HttpCode_Forbidden = 403, HttpCode_NotFound = 404, HttpCode_PreconditionFailed = 412, HttpCode_RangeNotSatisfiable = 416, HttpCode_InternalServerError = 500, supportedChromiumBrowsers = [
|
|
5272
5287
|
'Google Chrome Canary',
|
|
5273
5288
|
'Google Chrome Dev',
|
|
5274
5289
|
'Google Chrome Beta',
|
|
@@ -5802,15 +5817,15 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5802
5817
|
pathname = decodeURIComponent(pathname);
|
|
5803
5818
|
} catch {
|
|
5804
5819
|
return {
|
|
5805
|
-
errorCode:
|
|
5820
|
+
errorCode: HttpCode_BadRequest
|
|
5806
5821
|
};
|
|
5807
5822
|
}
|
|
5808
5823
|
if (!pathname) return;
|
|
5809
5824
|
if (pathname.includes('\0')) return {
|
|
5810
|
-
errorCode:
|
|
5825
|
+
errorCode: HttpCode_BadRequest
|
|
5811
5826
|
};
|
|
5812
5827
|
if (UP_PATH_REGEXP.test(external_node_path_default().normalize(`./${pathname}`))) return {
|
|
5813
|
-
errorCode:
|
|
5828
|
+
errorCode: HttpCode_Forbidden
|
|
5814
5829
|
};
|
|
5815
5830
|
let stat = async (filename)=>new Promise((resolve, reject)=>{
|
|
5816
5831
|
outputFileSystem.stat(filename, (err, stats)=>{
|
|
@@ -5906,14 +5921,14 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5906
5921
|
'HEAD'
|
|
5907
5922
|
];
|
|
5908
5923
|
function sendError(res, code) {
|
|
5909
|
-
let
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
}[code]}`, document1 = Buffer.from(`<!DOCTYPE html>
|
|
5924
|
+
let content = {
|
|
5925
|
+
[HttpCode_BadRequest]: 'Bad Request',
|
|
5926
|
+
[HttpCode_Forbidden]: 'Forbidden',
|
|
5927
|
+
[HttpCode_NotFound]: 'Not Found',
|
|
5928
|
+
[HttpCode_PreconditionFailed]: 'Precondition Failed',
|
|
5929
|
+
[HttpCode_RangeNotSatisfiable]: 'Range Not Satisfiable',
|
|
5930
|
+
[HttpCode_InternalServerError]: 'Internal Server Error'
|
|
5931
|
+
}[code], message = `${code} ${content}`, document1 = Buffer.from(`<!DOCTYPE html>
|
|
5917
5932
|
<html lang="en">
|
|
5918
5933
|
<head>
|
|
5919
5934
|
<meta charset="utf-8">
|
|
@@ -5959,7 +5974,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5959
5974
|
return !1;
|
|
5960
5975
|
}
|
|
5961
5976
|
function isCachable() {
|
|
5962
|
-
return res.statusCode >= 200 && res.statusCode < 300 ||
|
|
5977
|
+
return res.statusCode >= 200 && res.statusCode < 300 || res.statusCode === HttpCode_NotModified;
|
|
5963
5978
|
}
|
|
5964
5979
|
function isFresh(resHeaders) {
|
|
5965
5980
|
let cacheControl = req.headers['cache-control'];
|
|
@@ -6019,7 +6034,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6019
6034
|
let resolved = await getFileFromUrl(req.url, outputFileSystem, context);
|
|
6020
6035
|
if (!resolved) return void await goNext();
|
|
6021
6036
|
if ('errorCode' in resolved) {
|
|
6022
|
-
|
|
6037
|
+
resolved.errorCode === HttpCode_Forbidden ? src_logger.error(`[rsbuild:middleware] Malicious path "${req.url}".`) : resolved.errorCode === HttpCode_BadRequest && src_logger.error(`[rsbuild:middleware] Invalid pathname "${req.url}".`), sendError(res, resolved.errorCode);
|
|
6023
6038
|
return;
|
|
6024
6039
|
}
|
|
6025
6040
|
let { fsStats, filename } = resolved, { size } = fsStats, len = size, offset = 0;
|
|
@@ -6034,19 +6049,19 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6034
6049
|
res.setHeader('ETag', hash);
|
|
6035
6050
|
}
|
|
6036
6051
|
if (isConditionalGET()) {
|
|
6037
|
-
if (isPreconditionFailure()) return void sendError(res,
|
|
6038
|
-
if (
|
|
6052
|
+
if (isPreconditionFailure()) return void sendError(res, HttpCode_PreconditionFailed);
|
|
6053
|
+
if (res.statusCode === HttpCode_NotFound && (res.statusCode = HttpCode_Ok), isCachable() && isFresh({
|
|
6039
6054
|
etag: res.getHeader('ETag'),
|
|
6040
6055
|
'last-modified': res.getHeader('Last-Modified')
|
|
6041
6056
|
})) {
|
|
6042
|
-
res.statusCode =
|
|
6057
|
+
res.statusCode = HttpCode_NotModified, res.removeHeader('Content-Encoding'), res.removeHeader('Content-Language'), res.removeHeader('Content-Length'), res.removeHeader('Content-Range'), res.removeHeader('Content-Type'), res.end();
|
|
6043
6058
|
return;
|
|
6044
6059
|
}
|
|
6045
6060
|
}
|
|
6046
6061
|
if (rangeHeader) {
|
|
6047
6062
|
let parsedRanges = await parseRangeHeaders(`${size}|${rangeHeader}`);
|
|
6048
6063
|
if (isRangeFresh() || (parsedRanges = []), -1 === parsedRanges) {
|
|
6049
|
-
src_logger.error("[rsbuild:middleware] Unsatisfiable range for 'Range' header."), res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size)), sendError(res,
|
|
6064
|
+
src_logger.error("[rsbuild:middleware] Unsatisfiable range for 'Range' header."), res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size)), sendError(res, HttpCode_RangeNotSatisfiable);
|
|
6050
6065
|
return;
|
|
6051
6066
|
}
|
|
6052
6067
|
-2 === parsedRanges ? src_logger.error("[rsbuild:middleware] A malformed 'Range' header was provided. A regular response will be sent for this request.") : parsedRanges.length > 1 && src_logger.error("[rsbuild:middleware] A 'Range' header with multiple ranges was provided. Multiple ranges are not supported, so a regular response will be sent for this request."), -2 !== parsedRanges && 1 === parsedRanges.length && (res.statusCode = 206, res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size, parsedRanges[0])), [offset, len] = getOffsetAndLenFromRange(parsedRanges[0]));
|
|
@@ -6059,7 +6074,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6059
6074
|
return;
|
|
6060
6075
|
}
|
|
6061
6076
|
if (res.setHeader('Content-Length', byteLength), 'HEAD' === req.method) {
|
|
6062
|
-
|
|
6077
|
+
res.statusCode === HttpCode_NotFound && (res.statusCode = HttpCode_Ok), res.end();
|
|
6063
6078
|
return;
|
|
6064
6079
|
}
|
|
6065
6080
|
if ('function' != typeof bufferOrStream.pipe) return void res.end(bufferOrStream);
|
|
@@ -6071,10 +6086,10 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6071
6086
|
case 'ENAMETOOLONG':
|
|
6072
6087
|
case 'ENOENT':
|
|
6073
6088
|
case 'ENOTDIR':
|
|
6074
|
-
sendError(res,
|
|
6089
|
+
sendError(res, HttpCode_NotFound);
|
|
6075
6090
|
break;
|
|
6076
6091
|
default:
|
|
6077
|
-
sendError(res,
|
|
6092
|
+
sendError(res, HttpCode_InternalServerError);
|
|
6078
6093
|
}
|
|
6079
6094
|
}), bufferOrStream.pipe(res), on_finished_default()(res, cleanup);
|
|
6080
6095
|
});
|
|
@@ -6298,8 +6313,7 @@ init(
|
|
|
6298
6313
|
try {
|
|
6299
6314
|
let tracer = cachedTraceMap.get(sourceMapPath);
|
|
6300
6315
|
if (!tracer) {
|
|
6301
|
-
let
|
|
6302
|
-
if (!sourceMap) return;
|
|
6316
|
+
let sourceMap = await readFileAsync(fs, sourceMapPath);
|
|
6303
6317
|
tracer = new TraceMap(sourceMap.toString()), cachedTraceMap.set(sourceMapPath, tracer);
|
|
6304
6318
|
}
|
|
6305
6319
|
let originalPosition = originalPositionFor(tracer, {
|
|
@@ -6805,7 +6819,7 @@ init(
|
|
|
6805
6819
|
}), next();
|
|
6806
6820
|
};
|
|
6807
6821
|
}, notFoundMiddleware = (_req, res, _next)=>{
|
|
6808
|
-
res.statusCode =
|
|
6822
|
+
res.statusCode = HttpCode_NotFound, res.setHeader('Content-Type', 'text/plain; charset=utf-8'), res.end('This page could not be found');
|
|
6809
6823
|
}, optionsFallbackMiddleware = (req, res, next)=>{
|
|
6810
6824
|
if ('OPTIONS' === req.method) {
|
|
6811
6825
|
res.statusCode = 204, res.setHeader('Content-Length', '0'), res.end();
|
|
@@ -6834,12 +6848,12 @@ init(
|
|
|
6834
6848
|
return;
|
|
6835
6849
|
}
|
|
6836
6850
|
if (req.headers.accept?.includes('text/html')) {
|
|
6837
|
-
res.writeHead(
|
|
6851
|
+
res.writeHead(HttpCode_NotFound, {
|
|
6838
6852
|
'Content-Type': 'text/html'
|
|
6839
6853
|
}), res.end(`The server is configured with a base URL of ${base} - did you mean to visit <a href="${redirectPath}">${redirectPath}</a> instead?`);
|
|
6840
6854
|
return;
|
|
6841
6855
|
}
|
|
6842
|
-
res.writeHead(
|
|
6856
|
+
res.writeHead(HttpCode_NotFound, {
|
|
6843
6857
|
'Content-Type': 'text/plain'
|
|
6844
6858
|
}), res.end(`The server is configured with a base URL of ${base} - did you mean to visit ${redirectPath} instead?`);
|
|
6845
6859
|
};
|
|
@@ -6869,7 +6883,7 @@ init(
|
|
|
6869
6883
|
};
|
|
6870
6884
|
let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
|
|
6871
6885
|
let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
|
|
6872
|
-
!1 === bypassUrl ? (res.statusCode =
|
|
6886
|
+
!1 === bypassUrl ? (res.statusCode = HttpCode_NotFound, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
|
|
6873
6887
|
};
|
|
6874
6888
|
middlewares.push(middleware), opts.ws && proxyMiddlewares.push(proxyMiddleware);
|
|
6875
6889
|
}
|
|
@@ -7418,7 +7432,7 @@ init(
|
|
|
7418
7432
|
launchEditorMiddleware()
|
|
7419
7433
|
]), middlewares.push((({ environments })=>async function viewingServedFilesMiddleware(req, res, next) {
|
|
7420
7434
|
if ('/rsbuild-dev-server' !== req.url.replace(postfixRE, '')) return void next();
|
|
7421
|
-
res.writeHead(
|
|
7435
|
+
res.writeHead(HttpCode_Ok, {
|
|
7422
7436
|
'Content-Type': 'text/html; charset=utf-8'
|
|
7423
7437
|
}), res.write(`<!DOCTYPE html>
|
|
7424
7438
|
<html>
|
|
@@ -7477,7 +7491,7 @@ init(
|
|
|
7477
7491
|
})({
|
|
7478
7492
|
environments: devServerAPI.environments
|
|
7479
7493
|
})), buildManager && (middlewares.push(buildManager.assetsMiddleware), upgradeEvents.push(buildManager.socketServer.upgrade), middlewares.push(function hotUpdateJsonFallbackMiddleware(req, res, next) {
|
|
7480
|
-
req.url?.endsWith('.hot-update.json') && 'OPTIONS' !== req.method ? (res
|
|
7494
|
+
req.url?.endsWith('.hot-update.json') && 'OPTIONS' !== req.method ? notFoundMiddleware(req, res, next) : next();
|
|
7481
7495
|
})), buildManager && middlewares.push((({ distPath, buildManager })=>async function htmlCompletionMiddleware(req, res, next) {
|
|
7482
7496
|
if (!maybeHTMLRequest(req)) return void next();
|
|
7483
7497
|
let pathname = req.url.replace(postfixRE, ''), rewrite = (newUrl)=>{
|
|
@@ -8186,11 +8200,7 @@ init(
|
|
|
8186
8200
|
addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to find the icon file at ${color.yellow(icon.absolutePath)}.`);
|
|
8187
8201
|
continue;
|
|
8188
8202
|
}
|
|
8189
|
-
let source = await (
|
|
8190
|
-
if (!source) {
|
|
8191
|
-
addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to read the icon file at ${color.yellow(icon.absolutePath)}.`);
|
|
8192
|
-
continue;
|
|
8193
|
-
}
|
|
8203
|
+
let source = await readFileAsync(compilation.inputFileSystem, icon.absolutePath);
|
|
8194
8204
|
compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
|
|
8195
8205
|
}
|
|
8196
8206
|
('apple-touch-icon' === icon.target || !icon.target && icon.size < 200) && tags.push({
|
|
@@ -8566,23 +8576,22 @@ try {
|
|
|
8566
8576
|
isProd
|
|
8567
8577
|
});
|
|
8568
8578
|
if (applyTransformImport(swcConfig, config.source.transformImport), applySwcDecoratorConfig(swcConfig, config), isWebTarget(target)) {
|
|
8569
|
-
let
|
|
8570
|
-
if ('off'
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
let coreJsDir = applyCoreJs(swcConfig, polyfillMode);
|
|
8579
|
+
let { polyfill } = config.output;
|
|
8580
|
+
if ('off' !== polyfill) {
|
|
8581
|
+
swcConfig.env.mode = polyfill;
|
|
8582
|
+
let coreJsDir = applyCoreJs(swcConfig, polyfill);
|
|
8574
8583
|
for (let item of [
|
|
8575
8584
|
rule,
|
|
8576
8585
|
dataUriRule
|
|
8577
8586
|
])item.resolve.alias.set('core-js', coreJsDir);
|
|
8578
8587
|
}
|
|
8579
8588
|
}
|
|
8580
|
-
let
|
|
8589
|
+
let mergedConfig = reduceConfigs({
|
|
8581
8590
|
initial: swcConfig,
|
|
8582
8591
|
config: config.tools.swc,
|
|
8583
8592
|
mergeFn: cjs_default()
|
|
8584
8593
|
});
|
|
8585
|
-
rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(
|
|
8594
|
+
mergedConfig.jsc?.target !== void 0 && mergedConfig.env?.targets !== void 0 && 1 === Object.keys(mergedConfig.env).length && delete mergedConfig.env, rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(mergedConfig), dataUriRule.resolve.set('fullySpecified', !1).end().use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(cloneDeep(mergedConfig));
|
|
8586
8595
|
}
|
|
8587
8596
|
});
|
|
8588
8597
|
}
|
|
@@ -8640,32 +8649,37 @@ try {
|
|
|
8640
8649
|
{
|
|
8641
8650
|
name: 'rsbuild:inline-chunk',
|
|
8642
8651
|
setup (api) {
|
|
8643
|
-
let
|
|
8652
|
+
let inlineAssetsByEnvironment = new Map();
|
|
8644
8653
|
api.processAssets({
|
|
8645
8654
|
stage: 'summarize'
|
|
8646
|
-
}, ({ compiler, compilation })=>{
|
|
8647
|
-
|
|
8655
|
+
}, ({ compiler, compilation, environment })=>{
|
|
8656
|
+
let inlinedAssets = inlineAssetsByEnvironment.get(environment.name);
|
|
8657
|
+
if (!inlinedAssets || 0 === inlinedAssets.size) return;
|
|
8648
8658
|
let { devtool } = compiler.options, hasSourceMap = 'hidden-source-map' !== devtool && !1 !== devtool;
|
|
8649
|
-
for (let name of inlinedAssets)
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8659
|
+
for (let name of inlinedAssets){
|
|
8660
|
+
let asset = compilation.assets[name];
|
|
8661
|
+
asset && (hasSourceMap && compilation.updateAsset(name, asset, {
|
|
8662
|
+
related: {
|
|
8663
|
+
sourceMap: null
|
|
8664
|
+
}
|
|
8665
|
+
}), compilation.deleteAsset(name));
|
|
8666
|
+
}
|
|
8654
8667
|
inlinedAssets.clear();
|
|
8655
8668
|
}), api.modifyHTMLTags(({ headTags, bodyTags }, { compiler, compilation, environment })=>{
|
|
8656
|
-
|
|
8669
|
+
var name;
|
|
8670
|
+
let set, { htmlPaths, config } = environment;
|
|
8657
8671
|
if (0 === Object.keys(htmlPaths).length) return {
|
|
8658
8672
|
headTags,
|
|
8659
8673
|
bodyTags
|
|
8660
8674
|
};
|
|
8661
|
-
let { scriptTests, styleTests } = getInlineTests(config);
|
|
8675
|
+
let inlinedAssets = (name = environment.name, (set = inlineAssetsByEnvironment.get(name)) || (set = new Set(), inlineAssetsByEnvironment.set(name, set)), set), { scriptTests, styleTests } = getInlineTests(config);
|
|
8662
8676
|
if (!scriptTests.length && !styleTests.length) return {
|
|
8663
8677
|
headTags,
|
|
8664
8678
|
bodyTags
|
|
8665
8679
|
};
|
|
8666
8680
|
let publicPath = getPublicPathFromCompiler(compiler), updateTag = (tag)=>{
|
|
8667
|
-
var publicPath1, tag1, compilation1, scriptTests1, styleTests1, config;
|
|
8668
|
-
return publicPath1 = publicPath, tag1 = tag, compilation1 = compilation, scriptTests1 = scriptTests, styleTests1 = styleTests, config = environment.config, "script" === tag1.tag ? ((publicPath, tag, compilation, scriptTests, config)=>{
|
|
8681
|
+
var publicPath1, tag1, compilation1, inlinedAssets1, scriptTests1, styleTests1, config;
|
|
8682
|
+
return publicPath1 = publicPath, tag1 = tag, compilation1 = compilation, inlinedAssets1 = inlinedAssets, scriptTests1 = scriptTests, styleTests1 = styleTests, config = environment.config, "script" === tag1.tag ? ((publicPath, tag, compilation, inlinedAssets, scriptTests, config)=>{
|
|
8669
8683
|
let { assets } = compilation;
|
|
8670
8684
|
if (!(tag.attrs?.src && 'string' == typeof tag.attrs.src)) return tag;
|
|
8671
8685
|
let { src, ...otherAttrs } = tag.attrs, scriptName = publicPath ? src.replace(publicPath, '') : src, asset = assets[scriptName];
|
|
@@ -8684,7 +8698,7 @@ try {
|
|
|
8684
8698
|
}
|
|
8685
8699
|
};
|
|
8686
8700
|
return inlinedAssets.add(scriptName), ret;
|
|
8687
|
-
})(publicPath1, tag1, compilation1, scriptTests1, config) : 'link' === tag1.tag && tag1.attrs && 'stylesheet' === tag1.attrs.rel ? ((publicPath, tag, compilation, styleTests, config)=>{
|
|
8701
|
+
})(publicPath1, tag1, compilation1, inlinedAssets1, scriptTests1, config) : 'link' === tag1.tag && tag1.attrs && 'stylesheet' === tag1.attrs.rel ? ((publicPath, tag, compilation, inlinedAssets, styleTests, config)=>{
|
|
8688
8702
|
let { assets } = compilation;
|
|
8689
8703
|
if (!(tag.attrs?.href && 'string' == typeof tag.attrs.href)) return tag;
|
|
8690
8704
|
let linkName = publicPath ? tag.attrs.href.replace(publicPath, '') : tag.attrs.href, asset = assets[linkName];
|
|
@@ -8700,7 +8714,7 @@ try {
|
|
|
8700
8714
|
})
|
|
8701
8715
|
};
|
|
8702
8716
|
return inlinedAssets.add(linkName), ret;
|
|
8703
|
-
})(publicPath1, tag1, compilation1, styleTests1, config) : tag1;
|
|
8717
|
+
})(publicPath1, tag1, compilation1, inlinedAssets1, styleTests1, config) : tag1;
|
|
8704
8718
|
};
|
|
8705
8719
|
return {
|
|
8706
8720
|
headTags: headTags.map(updateTag),
|
|
@@ -9331,7 +9345,7 @@ try {
|
|
|
9331
9345
|
};
|
|
9332
9346
|
function setupCommands() {
|
|
9333
9347
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9334
|
-
cli.version("1.7.
|
|
9348
|
+
cli.version("1.7.2"), 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)', {
|
|
9335
9349
|
default: 'auto'
|
|
9336
9350
|
}).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', {
|
|
9337
9351
|
type: [
|
|
@@ -9400,7 +9414,7 @@ try {
|
|
|
9400
9414
|
}
|
|
9401
9415
|
function showGreeting() {
|
|
9402
9416
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9403
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.7.
|
|
9417
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.7.2\n`);
|
|
9404
9418
|
}
|
|
9405
9419
|
function setupLogLevel() {
|
|
9406
9420
|
let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
@@ -9421,7 +9435,7 @@ try {
|
|
|
9421
9435
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err);
|
|
9422
9436
|
}
|
|
9423
9437
|
}
|
|
9424
|
-
let src_version = "1.7.
|
|
9438
|
+
let src_version = "1.7.2";
|
|
9425
9439
|
})(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
|
|
9426
9440
|
"PLUGIN_CSS_NAME",
|
|
9427
9441
|
"PLUGIN_SWC_NAME",
|
|
@@ -10,4 +10,8 @@ export declare const findExists: (files: string[]) => string | false;
|
|
|
10
10
|
export declare function pathExists(path: string): Promise<boolean>;
|
|
11
11
|
export declare function isFileExists(file: string): Promise<boolean>;
|
|
12
12
|
export declare function fileExistsByCompilation({ inputFileSystem }: Rspack.Compilation, filePath: string): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Read file asynchronously using Rspack compiler's filesystem.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readFileAsync(fs: NonNullable<Rspack.Compilation['inputFileSystem'] | Rspack.OutputFileSystem>, filename: string): Promise<Buffer | string>;
|
|
13
17
|
export declare function emptyDir(dir: string, keep?: RegExp[], checkExists?: boolean): Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Stats as FSStats } from 'node:fs';
|
|
2
2
|
import type { InternalContext, Rspack } from '../../types';
|
|
3
|
-
import { HttpCode } from '../helper';
|
|
4
3
|
/**
|
|
5
4
|
* Resolves URL to file path with security checks and retrieves file from
|
|
6
5
|
* the build output directories.
|
|
@@ -9,5 +8,5 @@ export declare function getFileFromUrl(url: string, outputFileSystem: Rspack.Out
|
|
|
9
8
|
filename: string;
|
|
10
9
|
fsStats: FSStats;
|
|
11
10
|
} | {
|
|
12
|
-
errorCode:
|
|
11
|
+
errorCode: number;
|
|
13
12
|
} | undefined>;
|
|
@@ -78,12 +78,14 @@ export declare function getServerTerminator(server: Server | Http2SecureServer):
|
|
|
78
78
|
* escapeHtml('<div>Hello</div>') // '<div>Hello</div>'
|
|
79
79
|
*/
|
|
80
80
|
export declare function escapeHtml(text: string | null | undefined): string;
|
|
81
|
-
export declare
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
export declare const HttpCode: {
|
|
82
|
+
readonly Ok: 200;
|
|
83
|
+
readonly NotModified: 304;
|
|
84
|
+
readonly BadRequest: 400;
|
|
85
|
+
readonly Forbidden: 403;
|
|
86
|
+
readonly NotFound: 404;
|
|
87
|
+
readonly PreconditionFailed: 412;
|
|
88
|
+
readonly RangeNotSatisfiable: 416;
|
|
89
|
+
readonly InternalServerError: 500;
|
|
90
|
+
};
|
|
89
91
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RequestHandler as Middleware, ProxyConfig } from '../types';
|
|
2
|
-
import type
|
|
2
|
+
import { type UpgradeEvent } from './helper';
|
|
3
3
|
export declare const createProxyMiddleware: (proxyOptions: ProxyConfig) => {
|
|
4
4
|
middlewares: Middleware[];
|
|
5
5
|
upgrade: UpgradeEvent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "1.7.
|
|
49
|
+
"@rspack/core": "~1.7.1",
|
|
50
50
|
"@rspack/lite-tapable": "~1.1.0",
|
|
51
51
|
"@swc/helpers": "^0.5.18",
|
|
52
52
|
"core-js": "~3.47.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@jridgewell/remapping": "^2.3.5",
|
|
57
57
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
58
|
-
"@rslib/core": "0.19.
|
|
58
|
+
"@rslib/core": "0.19.1",
|
|
59
59
|
"@types/connect": "3.4.38",
|
|
60
60
|
"@types/cors": "^2.8.19",
|
|
61
61
|
"@types/node": "^24.10.4",
|