@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
694: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4
4
|
"use strict";
|
|
5
|
-
const { HtmlWebpackChildCompiler } = __nccwpck_require__(
|
|
5
|
+
const { HtmlWebpackChildCompiler } = __nccwpck_require__(479);
|
|
6
6
|
const compilerMap = new WeakMap();
|
|
7
7
|
class CachedChildCompilation {
|
|
8
8
|
constructor(compiler) {
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
}
|
|
312
312
|
module.exports = { CachedChildCompilation };
|
|
313
313
|
},
|
|
314
|
-
|
|
314
|
+
479: (module) => {
|
|
315
315
|
"use strict";
|
|
316
316
|
class HtmlWebpackChildCompiler {
|
|
317
317
|
constructor(templates) {
|
|
@@ -480,7 +480,7 @@
|
|
|
480
480
|
}
|
|
481
481
|
module.exports = { HtmlWebpackChildCompiler };
|
|
482
482
|
},
|
|
483
|
-
|
|
483
|
+
645: (module) => {
|
|
484
484
|
"use strict";
|
|
485
485
|
module.exports = {};
|
|
486
486
|
module.exports.none = (chunks) => chunks;
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
};
|
|
500
500
|
module.exports.auto = module.exports.none;
|
|
501
501
|
},
|
|
502
|
-
|
|
502
|
+
276: (module) => {
|
|
503
503
|
"use strict";
|
|
504
504
|
module.exports = function (err) {
|
|
505
505
|
return {
|
|
@@ -520,7 +520,7 @@
|
|
|
520
520
|
};
|
|
521
521
|
};
|
|
522
522
|
},
|
|
523
|
-
|
|
523
|
+
171: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
524
524
|
"use strict";
|
|
525
525
|
const { AsyncSeriesWaterfallHook } = __nccwpck_require__(408);
|
|
526
526
|
const htmlWebpackPluginHooksMap = new WeakMap();
|
|
@@ -546,7 +546,7 @@
|
|
|
546
546
|
}
|
|
547
547
|
module.exports = { getHtmlRspackPluginHooks };
|
|
548
548
|
},
|
|
549
|
-
|
|
549
|
+
10: (module) => {
|
|
550
550
|
const voidTags = [
|
|
551
551
|
"area",
|
|
552
552
|
"base",
|
|
@@ -614,19 +614,19 @@
|
|
|
614
614
|
htmlTagObjectToString,
|
|
615
615
|
};
|
|
616
616
|
},
|
|
617
|
-
|
|
617
|
+
387: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
618
618
|
"use strict";
|
|
619
619
|
const promisify = __nccwpck_require__(23).promisify;
|
|
620
620
|
const vm = __nccwpck_require__(154);
|
|
621
621
|
const fs = __nccwpck_require__(896);
|
|
622
622
|
const path = __nccwpck_require__(928);
|
|
623
|
-
const { CachedChildCompilation } = __nccwpck_require__(
|
|
623
|
+
const { CachedChildCompilation } = __nccwpck_require__(694);
|
|
624
624
|
const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
|
|
625
|
-
__nccwpck_require__(
|
|
626
|
-
const prettyError = __nccwpck_require__(
|
|
627
|
-
const chunkSorter = __nccwpck_require__(
|
|
625
|
+
__nccwpck_require__(10);
|
|
626
|
+
const prettyError = __nccwpck_require__(276);
|
|
627
|
+
const chunkSorter = __nccwpck_require__(645);
|
|
628
628
|
const getHtmlRspackPluginHooks =
|
|
629
|
-
__nccwpck_require__(
|
|
629
|
+
__nccwpck_require__(171).getHtmlRspackPluginHooks;
|
|
630
630
|
const WITH_PLACEHOLDER = "function __with_placeholder__";
|
|
631
631
|
class HtmlRspackPlugin {
|
|
632
632
|
constructor(userOptions = {}) {
|
|
@@ -1597,6 +1597,6 @@
|
|
|
1597
1597
|
}
|
|
1598
1598
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
1599
1599
|
__nccwpck_require__.ab = __dirname + "/";
|
|
1600
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
1600
|
+
var __webpack_exports__ = __nccwpck_require__(387);
|
|
1601
1601
|
module.exports = __webpack_exports__;
|
|
1602
1602
|
})();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
module.exports = __nccwpck_require__(
|
|
4
|
+
501: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
module.exports = __nccwpck_require__(143)["default"];
|
|
6
6
|
},
|
|
7
|
-
|
|
7
|
+
143: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
8
8
|
var __webpack_unused_export__;
|
|
9
9
|
__webpack_unused_export__ = { value: true };
|
|
10
10
|
exports["default"] = loader;
|
|
11
11
|
var _nodePath = _interopRequireDefault(__nccwpck_require__(760));
|
|
12
|
-
var _utils = __nccwpck_require__(
|
|
12
|
+
var _utils = __nccwpck_require__(346);
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
14
|
return e && e.__esModule ? e : { default: e };
|
|
15
15
|
}
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
callback(null, result.css, map, { ast });
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
|
|
182
|
+
346: (module, exports, __nccwpck_require__) => {
|
|
183
183
|
module = __nccwpck_require__.nmd(module);
|
|
184
184
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
185
185
|
exports.exec = exec;
|
|
@@ -715,6 +715,6 @@
|
|
|
715
715
|
})();
|
|
716
716
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
717
717
|
__nccwpck_require__.ab = __dirname + "/";
|
|
718
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
718
|
+
var __webpack_exports__ = __nccwpck_require__(501);
|
|
719
719
|
module.exports = __webpack_exports__;
|
|
720
720
|
})();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
4
|
+
305: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.transformFiles =
|
|
7
7
|
exports.reduceChunk =
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
.map(standardizeFilePaths);
|
|
121
121
|
exports.transformFiles = transformFiles;
|
|
122
122
|
},
|
|
123
|
-
|
|
123
|
+
172: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
124
124
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
125
125
|
exports.normalModuleLoaderHook =
|
|
126
126
|
exports.getCompilerHooks =
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
const node_fs_1 = __nccwpck_require__(24);
|
|
131
131
|
const node_path_1 = __nccwpck_require__(760);
|
|
132
132
|
const lite_tapable_1 = __nccwpck_require__(408);
|
|
133
|
-
const helpers_1 = __nccwpck_require__(
|
|
133
|
+
const helpers_1 = __nccwpck_require__(305);
|
|
134
134
|
const compilerHookMap = new WeakMap();
|
|
135
135
|
const getCompilerHooks = (compiler) => {
|
|
136
136
|
let hooks = compilerHookMap.get(compiler);
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
exports.getCompilerHooks =
|
|
328
328
|
void 0;
|
|
329
329
|
const node_path_1 = __nccwpck_require__(760);
|
|
330
|
-
const hooks_1 = __nccwpck_require__(
|
|
330
|
+
const hooks_1 = __nccwpck_require__(172);
|
|
331
331
|
Object.defineProperty(exports, "getCompilerHooks", {
|
|
332
332
|
enumerable: true,
|
|
333
333
|
get: function () {
|
package/dist/131.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/*! For license information please see 131.js.LICENSE.txt */
|
|
2
|
-
"use strict";
|
|
3
2
|
let flagForceColor, swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
|
|
4
3
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
5
4
|
import { createRequire as __rspack_createRequire } from "node:module";
|
|
@@ -2873,6 +2872,13 @@ async function fileExistsByCompilation({ inputFileSystem }, filePath) {
|
|
|
2873
2872
|
}) : resolve(!1);
|
|
2874
2873
|
});
|
|
2875
2874
|
}
|
|
2875
|
+
function readFileAsync(fs, filename) {
|
|
2876
|
+
return new Promise((resolve, reject)=>{
|
|
2877
|
+
fs.readFile(filename, (err, data)=>{
|
|
2878
|
+
err ? reject(err) : void 0 === data ? reject(Error(`Failed to read file: ${filename}, data is undefined`)) : resolve(data);
|
|
2879
|
+
});
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2876
2882
|
async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
2877
2883
|
if (!checkExists || await pathExists(dir)) try {
|
|
2878
2884
|
let entries = await node_fs.promises.readdir(dir, {
|
|
@@ -2880,7 +2886,11 @@ async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
|
2880
2886
|
});
|
|
2881
2887
|
await Promise.all(entries.map(async (entry)=>{
|
|
2882
2888
|
let fullPath = external_node_path_.default.join(dir, entry.name);
|
|
2883
|
-
|
|
2889
|
+
if (keep.length) {
|
|
2890
|
+
let posixFullPath = toPosixPath(fullPath);
|
|
2891
|
+
if (keep.some((regex)=>regex.test(posixFullPath))) return;
|
|
2892
|
+
}
|
|
2893
|
+
entry.isDirectory() ? (await emptyDir(fullPath, keep, !1), keep.length || await node_fs.promises.rmdir(fullPath)) : await node_fs.promises.unlink(fullPath);
|
|
2884
2894
|
}));
|
|
2885
2895
|
} catch (err) {
|
|
2886
2896
|
src_logger.debug(`failed to empty dir: ${dir}`), src_logger.debug(err);
|
|
@@ -3556,7 +3566,7 @@ function createPublicContext(context) {
|
|
|
3556
3566
|
async function createContext(options, userConfig) {
|
|
3557
3567
|
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';
|
|
3558
3568
|
return {
|
|
3559
|
-
version: "1.7.
|
|
3569
|
+
version: "1.7.2",
|
|
3560
3570
|
rootPath,
|
|
3561
3571
|
distPath: '',
|
|
3562
3572
|
cachePath,
|
|
@@ -4470,9 +4480,12 @@ function pluginExternals() {
|
|
|
4470
4480
|
}
|
|
4471
4481
|
};
|
|
4472
4482
|
}
|
|
4473
|
-
let fileSize_gzip = external_node_util_promisify(node_zlib.gzip);
|
|
4474
4483
|
async function gzipSize(input) {
|
|
4475
|
-
let data = await
|
|
4484
|
+
let data = await new Promise((resolve, reject)=>{
|
|
4485
|
+
node_zlib.gzip(input, (err, result)=>{
|
|
4486
|
+
err ? reject(err) : resolve(result);
|
|
4487
|
+
});
|
|
4488
|
+
});
|
|
4476
4489
|
return Buffer.byteLength(data);
|
|
4477
4490
|
}
|
|
4478
4491
|
function getSnapshotPath(dir, snapshotHash) {
|
|
@@ -4720,16 +4733,17 @@ class RsbuildHtmlPlugin {
|
|
|
4720
4733
|
}
|
|
4721
4734
|
apply(compiler) {
|
|
4722
4735
|
let emitFavicon = async ({ compilation, favicon, faviconDistPath })=>{
|
|
4723
|
-
let
|
|
4736
|
+
let fileContent, name = external_node_path_.default.basename(favicon);
|
|
4724
4737
|
if (compilation.assets[name]) return name;
|
|
4725
|
-
|
|
4738
|
+
let inputFs = compilation.inputFileSystem;
|
|
4739
|
+
if (!inputFs) return addCompilationError(compilation, `${color.dim('[rsbuild:html]')} Failed to read the favicon file as ${color.yellow('compilation.inputFileSystem')} is not available.`), null;
|
|
4726
4740
|
let inputFilename = external_node_path_.default.isAbsolute(favicon) ? favicon : external_node_path_.default.join(compilation.compiler.context, favicon);
|
|
4727
4741
|
try {
|
|
4728
|
-
|
|
4742
|
+
fileContent = await readFileAsync(inputFs, inputFilename);
|
|
4729
4743
|
} catch (error) {
|
|
4730
4744
|
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;
|
|
4731
4745
|
}
|
|
4732
|
-
let source = new compiler.webpack.sources.RawSource(
|
|
4746
|
+
let source = new compiler.webpack.sources.RawSource(fileContent, !1), outputFilename = external_node_path_.default.posix.join(faviconDistPath, name);
|
|
4733
4747
|
return compilation.emitAsset(outputFilename, source), outputFilename;
|
|
4734
4748
|
}, addFavicon = async ({ headTags, favicon, faviconDistPath, compilation, publicPath })=>{
|
|
4735
4749
|
let href = favicon;
|
|
@@ -5784,14 +5798,14 @@ let parseRangeHeaders = async (value)=>{
|
|
|
5784
5798
|
'HEAD'
|
|
5785
5799
|
];
|
|
5786
5800
|
function sendError(res, code) {
|
|
5787
|
-
let
|
|
5801
|
+
let content = {
|
|
5788
5802
|
400: 'Bad Request',
|
|
5789
5803
|
403: 'Forbidden',
|
|
5790
5804
|
404: 'Not Found',
|
|
5791
5805
|
412: 'Precondition Failed',
|
|
5792
5806
|
416: 'Range Not Satisfiable',
|
|
5793
5807
|
500: 'Internal Server Error'
|
|
5794
|
-
}[code]}`, document = Buffer.from(`<!DOCTYPE html>
|
|
5808
|
+
}[code], message = `${code} ${content}`, document = Buffer.from(`<!DOCTYPE html>
|
|
5795
5809
|
<html lang="en">
|
|
5796
5810
|
<head>
|
|
5797
5811
|
<meta charset="utf-8">
|
|
@@ -6176,8 +6190,7 @@ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.tes
|
|
|
6176
6190
|
try {
|
|
6177
6191
|
let tracer = cachedTraceMap.get(sourceMapPath);
|
|
6178
6192
|
if (!tracer) {
|
|
6179
|
-
let
|
|
6180
|
-
if (!sourceMap) return;
|
|
6193
|
+
let sourceMap = await readFileAsync(fs, sourceMapPath);
|
|
6181
6194
|
tracer = new TraceMap(sourceMap.toString()), cachedTraceMap.set(sourceMapPath, tracer);
|
|
6182
6195
|
}
|
|
6183
6196
|
let originalPosition = originalPositionFor(tracer, {
|
|
@@ -6678,7 +6691,7 @@ let faviconFallbackMiddleware = (req, res, next)=>{
|
|
|
6678
6691
|
}), next();
|
|
6679
6692
|
};
|
|
6680
6693
|
}, notFoundMiddleware = (_req, res, _next)=>{
|
|
6681
|
-
res.statusCode = 404, res.end();
|
|
6694
|
+
res.statusCode = 404, res.setHeader('Content-Type', 'text/plain; charset=utf-8'), res.end('This page could not be found');
|
|
6682
6695
|
}, optionsFallbackMiddleware = (req, res, next)=>{
|
|
6683
6696
|
if ('OPTIONS' === req.method) {
|
|
6684
6697
|
res.statusCode = 204, res.setHeader('Content-Length', '0'), res.end();
|
|
@@ -7346,7 +7359,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
7346
7359
|
})({
|
|
7347
7360
|
environments: devServerAPI.environments
|
|
7348
7361
|
})), buildManager && (middlewares.push(buildManager.assetsMiddleware), upgradeEvents.push(buildManager.socketServer.upgrade), middlewares.push(function hotUpdateJsonFallbackMiddleware(req, res, next) {
|
|
7349
|
-
req.url?.endsWith('.hot-update.json') && 'OPTIONS' !== req.method ? (res
|
|
7362
|
+
req.url?.endsWith('.hot-update.json') && 'OPTIONS' !== req.method ? notFoundMiddleware(req, res, next) : next();
|
|
7350
7363
|
})), buildManager && middlewares.push((({ distPath, buildManager })=>async function htmlCompletionMiddleware(req, res, next) {
|
|
7351
7364
|
if (!maybeHTMLRequest(req)) return void next();
|
|
7352
7365
|
let pathname = req.url.replace(postfixRE, ''), rewrite = (newUrl)=>{
|
|
@@ -8054,11 +8067,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8054
8067
|
addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to find the icon file at ${color.yellow(icon.absolutePath)}.`);
|
|
8055
8068
|
continue;
|
|
8056
8069
|
}
|
|
8057
|
-
let source = await
|
|
8058
|
-
if (!source) {
|
|
8059
|
-
addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to read the icon file at ${color.yellow(icon.absolutePath)}.`);
|
|
8060
|
-
continue;
|
|
8061
|
-
}
|
|
8070
|
+
let source = await readFileAsync(compilation.inputFileSystem, icon.absolutePath);
|
|
8062
8071
|
compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
|
|
8063
8072
|
}
|
|
8064
8073
|
('apple-touch-icon' === icon.target || !icon.target && icon.size < 200) && tags.push({
|
|
@@ -8433,23 +8442,22 @@ try {
|
|
|
8433
8442
|
isProd
|
|
8434
8443
|
});
|
|
8435
8444
|
if (applyTransformImport(swcConfig, config.source.transformImport), applySwcDecoratorConfig(swcConfig, config), isWebTarget(target)) {
|
|
8436
|
-
let
|
|
8437
|
-
if ('off'
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
let coreJsDir = applyCoreJs(swcConfig, polyfillMode);
|
|
8445
|
+
let { polyfill } = config.output;
|
|
8446
|
+
if ('off' !== polyfill) {
|
|
8447
|
+
swcConfig.env.mode = polyfill;
|
|
8448
|
+
let coreJsDir = applyCoreJs(swcConfig, polyfill);
|
|
8441
8449
|
for (let item of [
|
|
8442
8450
|
rule,
|
|
8443
8451
|
dataUriRule
|
|
8444
8452
|
])item.resolve.alias.set('core-js', coreJsDir);
|
|
8445
8453
|
}
|
|
8446
8454
|
}
|
|
8447
|
-
let
|
|
8455
|
+
let mergedConfig = reduceConfigs({
|
|
8448
8456
|
initial: swcConfig,
|
|
8449
8457
|
config: config.tools.swc,
|
|
8450
8458
|
mergeFn: cjs_default()
|
|
8451
8459
|
});
|
|
8452
|
-
rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(
|
|
8460
|
+
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));
|
|
8453
8461
|
}
|
|
8454
8462
|
});
|
|
8455
8463
|
}
|
|
@@ -8507,32 +8515,37 @@ try {
|
|
|
8507
8515
|
{
|
|
8508
8516
|
name: 'rsbuild:inline-chunk',
|
|
8509
8517
|
setup (api) {
|
|
8510
|
-
let
|
|
8518
|
+
let inlineAssetsByEnvironment = new Map();
|
|
8511
8519
|
api.processAssets({
|
|
8512
8520
|
stage: 'summarize'
|
|
8513
|
-
}, ({ compiler, compilation })=>{
|
|
8514
|
-
|
|
8521
|
+
}, ({ compiler, compilation, environment })=>{
|
|
8522
|
+
let inlinedAssets = inlineAssetsByEnvironment.get(environment.name);
|
|
8523
|
+
if (!inlinedAssets || 0 === inlinedAssets.size) return;
|
|
8515
8524
|
let { devtool } = compiler.options, hasSourceMap = 'hidden-source-map' !== devtool && !1 !== devtool;
|
|
8516
|
-
for (let name of inlinedAssets)
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8525
|
+
for (let name of inlinedAssets){
|
|
8526
|
+
let asset = compilation.assets[name];
|
|
8527
|
+
asset && (hasSourceMap && compilation.updateAsset(name, asset, {
|
|
8528
|
+
related: {
|
|
8529
|
+
sourceMap: null
|
|
8530
|
+
}
|
|
8531
|
+
}), compilation.deleteAsset(name));
|
|
8532
|
+
}
|
|
8521
8533
|
inlinedAssets.clear();
|
|
8522
8534
|
}), api.modifyHTMLTags(({ headTags, bodyTags }, { compiler, compilation, environment })=>{
|
|
8523
|
-
|
|
8535
|
+
var name;
|
|
8536
|
+
let set, { htmlPaths, config } = environment;
|
|
8524
8537
|
if (0 === Object.keys(htmlPaths).length) return {
|
|
8525
8538
|
headTags,
|
|
8526
8539
|
bodyTags
|
|
8527
8540
|
};
|
|
8528
|
-
let { scriptTests, styleTests } = getInlineTests(config);
|
|
8541
|
+
let inlinedAssets = (name = environment.name, (set = inlineAssetsByEnvironment.get(name)) || (set = new Set(), inlineAssetsByEnvironment.set(name, set)), set), { scriptTests, styleTests } = getInlineTests(config);
|
|
8529
8542
|
if (!scriptTests.length && !styleTests.length) return {
|
|
8530
8543
|
headTags,
|
|
8531
8544
|
bodyTags
|
|
8532
8545
|
};
|
|
8533
8546
|
let publicPath = getPublicPathFromCompiler(compiler), updateTag = (tag)=>{
|
|
8534
8547
|
var config;
|
|
8535
|
-
return config = environment.config, "script" === tag.tag ? ((publicPath, tag, compilation, scriptTests, config)=>{
|
|
8548
|
+
return config = environment.config, "script" === tag.tag ? ((publicPath, tag, compilation, inlinedAssets, scriptTests, config)=>{
|
|
8536
8549
|
let { assets } = compilation;
|
|
8537
8550
|
if (!(tag.attrs?.src && 'string' == typeof tag.attrs.src)) return tag;
|
|
8538
8551
|
let { src, ...otherAttrs } = tag.attrs, scriptName = publicPath ? src.replace(publicPath, '') : src, asset = assets[scriptName];
|
|
@@ -8551,7 +8564,7 @@ try {
|
|
|
8551
8564
|
}
|
|
8552
8565
|
};
|
|
8553
8566
|
return inlinedAssets.add(scriptName), ret;
|
|
8554
|
-
})(publicPath, tag, compilation, scriptTests, config) : 'link' === tag.tag && tag.attrs && 'stylesheet' === tag.attrs.rel ? ((publicPath, tag, compilation, styleTests, config)=>{
|
|
8567
|
+
})(publicPath, tag, compilation, inlinedAssets, scriptTests, config) : 'link' === tag.tag && tag.attrs && 'stylesheet' === tag.attrs.rel ? ((publicPath, tag, compilation, inlinedAssets, styleTests, config)=>{
|
|
8555
8568
|
let { assets } = compilation;
|
|
8556
8569
|
if (!(tag.attrs?.href && 'string' == typeof tag.attrs.href)) return tag;
|
|
8557
8570
|
let linkName = publicPath ? tag.attrs.href.replace(publicPath, '') : tag.attrs.href, asset = assets[linkName];
|
|
@@ -8567,7 +8580,7 @@ try {
|
|
|
8567
8580
|
})
|
|
8568
8581
|
};
|
|
8569
8582
|
return inlinedAssets.add(linkName), ret;
|
|
8570
|
-
})(publicPath, tag, compilation, styleTests, config) : tag;
|
|
8583
|
+
})(publicPath, tag, compilation, inlinedAssets, styleTests, config) : tag;
|
|
8571
8584
|
};
|
|
8572
8585
|
return {
|
|
8573
8586
|
headTags: headTags.map(updateTag),
|
|
@@ -9198,7 +9211,7 @@ let applyServerOptions = (command)=>{
|
|
|
9198
9211
|
};
|
|
9199
9212
|
function setupCommands() {
|
|
9200
9213
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9201
|
-
cli.version("1.7.
|
|
9214
|
+
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)', {
|
|
9202
9215
|
default: 'auto'
|
|
9203
9216
|
}).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', {
|
|
9204
9217
|
type: [
|
|
@@ -9267,7 +9280,7 @@ function initNodeEnv() {
|
|
|
9267
9280
|
}
|
|
9268
9281
|
function showGreeting() {
|
|
9269
9282
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9270
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.7.
|
|
9283
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.7.2\n`);
|
|
9271
9284
|
}
|
|
9272
9285
|
function setupLogLevel() {
|
|
9273
9286
|
let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
@@ -9288,5 +9301,5 @@ function runCLI() {
|
|
|
9288
9301
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err);
|
|
9289
9302
|
}
|
|
9290
9303
|
}
|
|
9291
|
-
let src_version = "1.7.
|
|
9304
|
+
let src_version = "1.7.2";
|
|
9292
9305
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, node_fs, node_os, node_process, rspack_rspack as rspack, runCLI, src_logger as logger, src_version as version };
|