@rsbuild/core 1.2.7 → 1.2.8
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 +41 -41
- package/compiled/postcss/index.js +107 -105
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/style-loader/index.js +10 -10
- package/dist/index.cjs +81 -66
- package/dist/index.js +81 -66
- package/dist-types/createRsbuild.d.ts +3 -0
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +3 -3
- package/dist-types/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +2 -2
- package/dist-types/server/getDevMiddlewares.d.ts +3 -2
- package/dist-types/server/runner/basic.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +6 -4
- package/dist-types/server/runner/type.d.ts +7 -1
- package/dist-types/server/watchFiles.d.ts +3 -2
- package/dist-types/types/config.d.ts +11 -3
- package/dist-types/types/hooks.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +138 -66
- package/dist-types/types/rsbuild.d.ts +96 -29
- package/package.json +3 -3
|
@@ -4449,14 +4449,14 @@
|
|
|
4449
4449
|
return a.start - b.start;
|
|
4450
4450
|
}
|
|
4451
4451
|
},
|
|
4452
|
-
|
|
4452
|
+
9527: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4453
4453
|
"use strict";
|
|
4454
|
-
const middleware = __nccwpck_require__(
|
|
4455
|
-
const getFilenameFromUrl = __nccwpck_require__(
|
|
4456
|
-
const setupHooks = __nccwpck_require__(
|
|
4457
|
-
const setupWriteToDisk = __nccwpck_require__(
|
|
4458
|
-
const setupOutputFileSystem = __nccwpck_require__(
|
|
4459
|
-
const ready = __nccwpck_require__(
|
|
4454
|
+
const middleware = __nccwpck_require__(3267);
|
|
4455
|
+
const getFilenameFromUrl = __nccwpck_require__(1695);
|
|
4456
|
+
const setupHooks = __nccwpck_require__(7858);
|
|
4457
|
+
const setupWriteToDisk = __nccwpck_require__(4841);
|
|
4458
|
+
const setupOutputFileSystem = __nccwpck_require__(358);
|
|
4459
|
+
const ready = __nccwpck_require__(9482);
|
|
4460
4460
|
const noop = () => {};
|
|
4461
4461
|
function wdm(compiler, options = {}) {
|
|
4462
4462
|
const context = {
|
|
@@ -4511,14 +4511,14 @@
|
|
|
4511
4511
|
}
|
|
4512
4512
|
module.exports = wdm;
|
|
4513
4513
|
},
|
|
4514
|
-
|
|
4514
|
+
3267: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4515
4515
|
"use strict";
|
|
4516
4516
|
const mrmime = __nccwpck_require__(8311);
|
|
4517
4517
|
const onFinishedStream = __nccwpck_require__(21);
|
|
4518
|
-
const getFilenameFromUrl = __nccwpck_require__(
|
|
4519
|
-
const ready = __nccwpck_require__(
|
|
4520
|
-
const parseTokenList = __nccwpck_require__(
|
|
4521
|
-
const memorize = __nccwpck_require__(
|
|
4518
|
+
const getFilenameFromUrl = __nccwpck_require__(1695);
|
|
4519
|
+
const ready = __nccwpck_require__(9482);
|
|
4520
|
+
const parseTokenList = __nccwpck_require__(6817);
|
|
4521
|
+
const memorize = __nccwpck_require__(8791);
|
|
4522
4522
|
async function getEtag(stat) {
|
|
4523
4523
|
const mtime = stat.mtime.getTime().toString(16);
|
|
4524
4524
|
const size = stat.size.toString(16);
|
|
@@ -4610,7 +4610,7 @@
|
|
|
4610
4610
|
return;
|
|
4611
4611
|
}
|
|
4612
4612
|
function sendError(status, options) {
|
|
4613
|
-
const escapeHtml = __nccwpck_require__(
|
|
4613
|
+
const escapeHtml = __nccwpck_require__(7111);
|
|
4614
4614
|
const content = statuses[status] || String(status);
|
|
4615
4615
|
const document = Buffer.from(
|
|
4616
4616
|
`<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<title>Error</title>\n</head>\n<body>\n<pre>${escapeHtml(content)}</pre>\n</body>\n</html>`,
|
|
@@ -4915,7 +4915,7 @@
|
|
|
4915
4915
|
}
|
|
4916
4916
|
module.exports = wrapper;
|
|
4917
4917
|
},
|
|
4918
|
-
|
|
4918
|
+
7111: (module) => {
|
|
4919
4919
|
"use strict";
|
|
4920
4920
|
const matchHtmlRegExp = /["'&<>]/;
|
|
4921
4921
|
function escapeHtml(string) {
|
|
@@ -4960,13 +4960,13 @@
|
|
|
4960
4960
|
}
|
|
4961
4961
|
module.exports = escapeHtml;
|
|
4962
4962
|
},
|
|
4963
|
-
|
|
4963
|
+
1695: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4964
4964
|
"use strict";
|
|
4965
4965
|
const path = __nccwpck_require__(6928);
|
|
4966
4966
|
const { parse } = __nccwpck_require__(7016);
|
|
4967
4967
|
const querystring = __nccwpck_require__(3480);
|
|
4968
|
-
const getPaths = __nccwpck_require__(
|
|
4969
|
-
const memorize = __nccwpck_require__(
|
|
4968
|
+
const getPaths = __nccwpck_require__(1093);
|
|
4969
|
+
const memorize = __nccwpck_require__(8791);
|
|
4970
4970
|
const memoizedParse = memorize(parse, undefined, (value) => {
|
|
4971
4971
|
if (value.pathname) {
|
|
4972
4972
|
value.pathname = decode(value.pathname);
|
|
@@ -5049,7 +5049,7 @@
|
|
|
5049
5049
|
}
|
|
5050
5050
|
module.exports = getFilenameFromUrl;
|
|
5051
5051
|
},
|
|
5052
|
-
|
|
5052
|
+
1093: (module) => {
|
|
5053
5053
|
"use strict";
|
|
5054
5054
|
function getPaths(context) {
|
|
5055
5055
|
const { stats, options } = context;
|
|
@@ -5070,7 +5070,7 @@
|
|
|
5070
5070
|
}
|
|
5071
5071
|
module.exports = getPaths;
|
|
5072
5072
|
},
|
|
5073
|
-
|
|
5073
|
+
8791: (module) => {
|
|
5074
5074
|
"use strict";
|
|
5075
5075
|
const cacheStore = new WeakMap();
|
|
5076
5076
|
function memorize(fn, { cache = new Map() } = {}, callback) {
|
|
@@ -5092,7 +5092,7 @@
|
|
|
5092
5092
|
}
|
|
5093
5093
|
module.exports = memorize;
|
|
5094
5094
|
},
|
|
5095
|
-
|
|
5095
|
+
6817: (module) => {
|
|
5096
5096
|
"use strict";
|
|
5097
5097
|
function parseTokenList(str) {
|
|
5098
5098
|
let end = 0;
|
|
@@ -5125,7 +5125,7 @@
|
|
|
5125
5125
|
}
|
|
5126
5126
|
module.exports = parseTokenList;
|
|
5127
5127
|
},
|
|
5128
|
-
|
|
5128
|
+
9482: (module) => {
|
|
5129
5129
|
"use strict";
|
|
5130
5130
|
function ready(context, callback, req) {
|
|
5131
5131
|
if (context.state) {
|
|
@@ -5140,7 +5140,7 @@
|
|
|
5140
5140
|
}
|
|
5141
5141
|
module.exports = ready;
|
|
5142
5142
|
},
|
|
5143
|
-
|
|
5143
|
+
7858: (module) => {
|
|
5144
5144
|
"use strict";
|
|
5145
5145
|
function setupHooks(context) {
|
|
5146
5146
|
function invalid() {
|
|
@@ -5172,7 +5172,7 @@
|
|
|
5172
5172
|
}
|
|
5173
5173
|
module.exports = setupHooks;
|
|
5174
5174
|
},
|
|
5175
|
-
|
|
5175
|
+
358: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5176
5176
|
"use strict";
|
|
5177
5177
|
const memfs = __nccwpck_require__(5590);
|
|
5178
5178
|
function setupOutputFileSystem(context) {
|
|
@@ -5199,7 +5199,7 @@
|
|
|
5199
5199
|
}
|
|
5200
5200
|
module.exports = setupOutputFileSystem;
|
|
5201
5201
|
},
|
|
5202
|
-
|
|
5202
|
+
4841: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5203
5203
|
"use strict";
|
|
5204
5204
|
const fs = __nccwpck_require__(9896);
|
|
5205
5205
|
const path = __nccwpck_require__(6928);
|
|
@@ -6185,6 +6185,6 @@
|
|
|
6185
6185
|
}
|
|
6186
6186
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
6187
6187
|
__nccwpck_require__.ab = __dirname + "/";
|
|
6188
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
6188
|
+
var __webpack_exports__ = __nccwpck_require__(9527);
|
|
6189
6189
|
module.exports = __webpack_exports__;
|
|
6190
6190
|
})();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
const loader = __nccwpck_require__(
|
|
4
|
+
882: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5
|
+
const loader = __nccwpck_require__(720);
|
|
6
6
|
module.exports = loader.default;
|
|
7
7
|
},
|
|
8
|
-
|
|
8
|
+
720: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
var _path = _interopRequireDefault(__nccwpck_require__(928));
|
|
12
|
-
var _utils = __nccwpck_require__(
|
|
13
|
-
var _options = _interopRequireDefault(__nccwpck_require__(
|
|
12
|
+
var _utils = __nccwpck_require__(385);
|
|
13
|
+
var _options = _interopRequireDefault(__nccwpck_require__(897));
|
|
14
14
|
function _interopRequireDefault(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
16
16
|
}
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
};
|
|
105
105
|
var _default = (exports["default"] = loader);
|
|
106
106
|
},
|
|
107
|
-
|
|
107
|
+
3: (module) => {
|
|
108
108
|
function isEqualLocals(a, b, isNamedExport) {
|
|
109
109
|
if ((!a && b) || (a && !b)) {
|
|
110
110
|
return false;
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
}
|
|
131
131
|
module.exports = isEqualLocals;
|
|
132
132
|
},
|
|
133
|
-
|
|
133
|
+
385: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
134
134
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
135
135
|
exports.getExportLazyStyleCode = getExportLazyStyleCode;
|
|
136
136
|
exports.getExportStyleCode = getExportStyleCode;
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
exports.getdomAPI = getdomAPI;
|
|
152
152
|
exports.stringifyRequest = stringifyRequest;
|
|
153
153
|
var _path = _interopRequireDefault(__nccwpck_require__(928));
|
|
154
|
-
var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(
|
|
154
|
+
var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(3));
|
|
155
155
|
function _interopRequireDefault(obj) {
|
|
156
156
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
157
157
|
}
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
928: (module) => {
|
|
395
395
|
module.exports = require("path");
|
|
396
396
|
},
|
|
397
|
-
|
|
397
|
+
897: (module) => {
|
|
398
398
|
module.exports = JSON.parse(
|
|
399
399
|
'{"title":"Style Loader options","type":"object","properties":{"injectType":{"description":"Allows to setup how styles will be injected into DOM.","link":"https://github.com/webpack-contrib/style-loader#injecttype","enum":["styleTag","singletonStyleTag","autoStyleTag","lazyStyleTag","lazySingletonStyleTag","lazyAutoStyleTag","linkTag"]},"attributes":{"description":"Adds custom attributes to tag.","link":"https://github.com/webpack-contrib/style-loader#attributes","type":"object"},"insert":{"description":"Inserts `<style>`/`<link>` at the given position.","link":"https://github.com/webpack-contrib/style-loader#insert","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"base":{"description":"Sets module ID base for DLLPlugin.","link":"https://github.com/webpack-contrib/style-loader#base","type":"number"},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"styleTagTransform":{"description":"Transform tag and css when insert \'style\' tag into the DOM","link":"https://github.com/webpack-contrib/style-loader#styleTagTransform","anyOf":[{"type":"string"},{"instanceof":"Function"}]}},"additionalProperties":false}',
|
|
400
400
|
);
|
|
@@ -422,6 +422,6 @@
|
|
|
422
422
|
}
|
|
423
423
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
424
424
|
__nccwpck_require__.ab = __dirname + "/";
|
|
425
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
425
|
+
var __webpack_exports__ = __nccwpck_require__(882);
|
|
426
426
|
module.exports = __webpack_exports__;
|
|
427
427
|
})();
|
package/dist/index.cjs
CHANGED
|
@@ -1708,7 +1708,7 @@ var __webpack_exports__ = {};
|
|
|
1708
1708
|
async function createContext(options, userConfig, bundlerType) {
|
|
1709
1709
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
1710
1710
|
return {
|
|
1711
|
-
version: "1.2.
|
|
1711
|
+
version: "1.2.8",
|
|
1712
1712
|
rootPath,
|
|
1713
1713
|
distPath: '',
|
|
1714
1714
|
cachePath,
|
|
@@ -2036,7 +2036,7 @@ var __webpack_exports__ = {};
|
|
|
2036
2036
|
recursive: !0
|
|
2037
2037
|
}), await external_node_fs_default().promises.writeFile(configFile, JSON.stringify(buildDependencies));
|
|
2038
2038
|
}
|
|
2039
|
-
async function getBuildDependencies(context, config, environmentContext) {
|
|
2039
|
+
async function getBuildDependencies(context, config, environmentContext, userBuildDependencies) {
|
|
2040
2040
|
var _config__privateMeta;
|
|
2041
2041
|
let rootPackageJson = (0, external_node_path_namespaceObject.join)(context.rootPath, 'package.json'), browserslistConfig = (0, external_node_path_namespaceObject.join)(context.rootPath, '.browserslistrc'), buildDependencies = {};
|
|
2042
2042
|
await isFileExists(rootPackageJson) && (buildDependencies.packageJson = [
|
|
@@ -2058,7 +2058,10 @@ var __webpack_exports__ = {};
|
|
|
2058
2058
|
].map((ext)=>(0, external_node_path_namespaceObject.join)(context.rootPath, `tailwind.config.${ext}`)));
|
|
2059
2059
|
return tailwindConfig && (buildDependencies.tailwindcss = [
|
|
2060
2060
|
tailwindConfig
|
|
2061
|
-
]),
|
|
2061
|
+
]), {
|
|
2062
|
+
...buildDependencies,
|
|
2063
|
+
...userBuildDependencies
|
|
2064
|
+
};
|
|
2062
2065
|
}
|
|
2063
2066
|
let pluginCache = ()=>({
|
|
2064
2067
|
name: 'rsbuild:cache',
|
|
@@ -2071,7 +2074,9 @@ var __webpack_exports__ = {};
|
|
|
2071
2074
|
cacheEnabled = !0;
|
|
2072
2075
|
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = function({ cacheDirectory }, context) {
|
|
2073
2076
|
return cacheDirectory ? (0, external_node_path_namespaceObject.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_namespaceObject.join)(context.rootPath, cacheDirectory) : (0, external_node_path_namespaceObject.join)(context.cachePath, context.bundlerType);
|
|
2074
|
-
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment
|
|
2077
|
+
}(cacheConfig, context), buildDependencies = await getBuildDependencies(context, config, environment, cacheConfig.buildDependencies ? {
|
|
2078
|
+
userBuildDependencies: cacheConfig.buildDependencies
|
|
2079
|
+
} : {});
|
|
2075
2080
|
'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
|
|
2076
2081
|
let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${digest = cacheConfig.cacheDigest, external_node_crypto_default().createHash('md5').update(JSON.stringify(digest)).digest('hex').slice(0, 8)}` : `${environment.name}-${env}`;
|
|
2077
2082
|
'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
|
|
@@ -2365,7 +2370,7 @@ var __webpack_exports__ = {};
|
|
|
2365
2370
|
async function gzipSize(input) {
|
|
2366
2371
|
return (await fileSize_gzip(input)).length;
|
|
2367
2372
|
}
|
|
2368
|
-
let
|
|
2373
|
+
let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? index_js_default().red : size > 100000 ? index_js_default().yellow : index_js_default().green, calcFileSize = (len)=>{
|
|
2369
2374
|
let val = len / 1000;
|
|
2370
2375
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
2371
2376
|
}, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? index_js_default().cyan(assetName) : CSS_REGEX.test(assetName) ? index_js_default().yellow(assetName) : HTML_REGEX.test(assetName) ? index_js_default().green(assetName) : index_js_default().magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
|
|
@@ -2424,7 +2429,7 @@ var __webpack_exports__ = {};
|
|
|
2424
2429
|
let totalSize = 0, totalGzipSize = 0;
|
|
2425
2430
|
for (let asset of assets){
|
|
2426
2431
|
let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
|
|
2427
|
-
if (totalSize += asset.size,
|
|
2432
|
+
if (totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size), !1 !== options.detail) {
|
|
2428
2433
|
sizeLength < longestLabelLength && (sizeLabel += ' '.repeat(longestLabelLength - sizeLength));
|
|
2429
2434
|
let fileNameLabel = index_js_default().dim(asset.folder + external_node_path_default().sep) + coloringAssetName(asset.name);
|
|
2430
2435
|
fileNameLength < longestFileLength && (fileNameLabel += ' '.repeat(longestFileLength - fileNameLength));
|
|
@@ -3549,7 +3554,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3549
3554
|
}) : obj[key] = value, obj;
|
|
3550
3555
|
}
|
|
3551
3556
|
let HtmlPreloadOrPrefetchPlugin_defaultOptions = {
|
|
3552
|
-
type: 'async-chunks'
|
|
3557
|
+
type: 'async-chunks',
|
|
3558
|
+
dedupe: !0
|
|
3553
3559
|
};
|
|
3554
3560
|
class HtmlPreloadOrPrefetchPlugin {
|
|
3555
3561
|
apply(compiler) {
|
|
@@ -3626,7 +3632,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3626
3632
|
if (this.resourceHints) {
|
|
3627
3633
|
var resourceHints, scripts;
|
|
3628
3634
|
htmlPluginData.assetTags.styles = [
|
|
3629
|
-
...(resourceHints = this.resourceHints, scripts = htmlPluginData.assetTags.scripts, resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href))),
|
|
3635
|
+
...this.options.dedupe ? (resourceHints = this.resourceHints, scripts = htmlPluginData.assetTags.scripts, resourceHints.filter((resourceHint)=>!scripts.find((script)=>script.attributes.src === resourceHint.attributes.href))) : this.resourceHints,
|
|
3630
3636
|
...htmlPluginData.assetTags.styles
|
|
3631
3637
|
];
|
|
3632
3638
|
}
|
|
@@ -4987,15 +4993,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4987
4993
|
content: `module.exports = (${modulePath.map((arg)=>`require(${JSON.stringify(`./${arg}`)})`).join(', ')});`,
|
|
4988
4994
|
subPath: ''
|
|
4989
4995
|
};
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
};
|
|
4997
|
-
}
|
|
4998
|
-
return null;
|
|
4996
|
+
let joinedPath = isRelativePath(modulePath) ? external_node_path_default().join(currentDirectory, modulePath) : modulePath;
|
|
4997
|
+
return this._options.isBundleOutput(joinedPath) ? {
|
|
4998
|
+
path: joinedPath,
|
|
4999
|
+
content: this._options.readFileSync(joinedPath),
|
|
5000
|
+
subPath: getSubPath(modulePath)
|
|
5001
|
+
} : null;
|
|
4999
5002
|
}
|
|
5000
5003
|
preExecute(_code, _file) {}
|
|
5001
5004
|
postExecute(_m, _file) {}
|
|
@@ -5049,7 +5052,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5049
5052
|
this.requirers.set('miss', this.createMissRequirer()), this.requirers.set('entry', this.createCjsRequirer());
|
|
5050
5053
|
}
|
|
5051
5054
|
createMissRequirer() {
|
|
5052
|
-
return (_currentDirectory, modulePath, _context = {})=>
|
|
5055
|
+
return (_currentDirectory, modulePath, _context = {})=>{
|
|
5056
|
+
let resolvedPath = cjs_require.resolve(modulePath, {
|
|
5057
|
+
paths: [
|
|
5058
|
+
_currentDirectory
|
|
5059
|
+
]
|
|
5060
|
+
});
|
|
5061
|
+
return cjs_require(resolvedPath.startsWith('node:') ? resolvedPath.slice(5) : resolvedPath);
|
|
5062
|
+
};
|
|
5053
5063
|
}
|
|
5054
5064
|
createCjsRequirer() {
|
|
5055
5065
|
let requireCache = Object.create(null);
|
|
@@ -5073,10 +5083,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5073
5083
|
}({});
|
|
5074
5084
|
class EsmRunner extends CommonJsRunner {
|
|
5075
5085
|
createRunner() {
|
|
5076
|
-
|
|
5077
|
-
|
|
5086
|
+
var _this__options_compilerOptions_experiments;
|
|
5087
|
+
super.createRunner(), this.requirers.set('cjs', this.getRequire()), this.requirers.set('esm', this.createEsmRequirer());
|
|
5088
|
+
let outputModule = null === (_this__options_compilerOptions_experiments = this._options.compilerOptions.experiments) || void 0 === _this__options_compilerOptions_experiments ? void 0 : _this__options_compilerOptions_experiments.outputModule;
|
|
5089
|
+
this.requirers.set('entry', (currentDirectory, modulePath, context)=>{
|
|
5078
5090
|
let file = this.getFile(modulePath, currentDirectory);
|
|
5079
|
-
return file ? file.path.endsWith('.
|
|
5091
|
+
return file ? outputModule && !file.path.endsWith('.cjs') ? this.requirers.get('esm')(currentDirectory, modulePath, {
|
|
5080
5092
|
...context,
|
|
5081
5093
|
file
|
|
5082
5094
|
}) : this.requirers.get('cjs')(currentDirectory, modulePath, {
|
|
@@ -5118,16 +5130,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5118
5130
|
}
|
|
5119
5131
|
}
|
|
5120
5132
|
class BasicRunnerFactory {
|
|
5121
|
-
create(
|
|
5122
|
-
return this.createRunner(
|
|
5133
|
+
create(options) {
|
|
5134
|
+
return this.createRunner(options);
|
|
5123
5135
|
}
|
|
5124
|
-
createRunner(
|
|
5136
|
+
createRunner(options) {
|
|
5125
5137
|
let runnerOptions = {
|
|
5126
5138
|
name: this.name,
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
readFileSync
|
|
5130
|
-
};
|
|
5139
|
+
...options
|
|
5140
|
+
}, { compilerOptions } = options;
|
|
5131
5141
|
if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`[rsbuild:runner] Not support run "${compilerOptions.target}" resource in Rsbuild server`);
|
|
5132
5142
|
return new EsmRunner(runnerOptions);
|
|
5133
5143
|
}
|
|
@@ -5142,7 +5152,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5142
5152
|
}(this, "name", void 0), this.name = name;
|
|
5143
5153
|
}
|
|
5144
5154
|
}
|
|
5145
|
-
let runner_run = async (bundlePath,
|
|
5155
|
+
let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunnerFactory(bundlePath).create(runnerFactoryOptions).run(bundlePath), loadBundle = async (stats, entryName, utils)=>{
|
|
5146
5156
|
let { chunks, entrypoints, outputPath } = stats.toJson({
|
|
5147
5157
|
all: !1,
|
|
5148
5158
|
chunks: !0,
|
|
@@ -5159,7 +5169,14 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5159
5169
|
}, []);
|
|
5160
5170
|
if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
|
|
5161
5171
|
if (files.length > 1) throw Error(`[rsbuild:loadBundle] Only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
|
|
5162
|
-
|
|
5172
|
+
let allChunkFiles = (null == chunks ? void 0 : chunks.flatMap((c)=>c.files).map((file)=>(0, external_node_path_namespaceObject.join)(outputPath, file))) || [];
|
|
5173
|
+
return await runner_run({
|
|
5174
|
+
bundlePath: files[0],
|
|
5175
|
+
dist: outputPath,
|
|
5176
|
+
compilerOptions: stats.compilation.options,
|
|
5177
|
+
readFileSync: utils.readFileSync,
|
|
5178
|
+
isBundleOutput: (modulePath)=>allChunkFiles.includes(modulePath)
|
|
5179
|
+
});
|
|
5163
5180
|
}, getTransformedHtml = async (entryName, utils)=>{
|
|
5164
5181
|
let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
|
|
5165
5182
|
if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
|
|
@@ -5470,11 +5487,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5470
5487
|
return createServer(middlewares);
|
|
5471
5488
|
}, devServer_formatDevConfig = (config, port)=>('<port>' === config.client.port && (config.client.port = String(port)), config);
|
|
5472
5489
|
async function devServer_createDevServer(options, createCompiler, config, { compiler: customCompiler, getPortSilently, runCompile = !0 } = {}) {
|
|
5473
|
-
let lastStats;
|
|
5490
|
+
let lastStats, fileWatcher, devMiddlewares;
|
|
5474
5491
|
rslog_index_js_namespaceObject.logger.debug('create dev server');
|
|
5475
5492
|
let { port, host, https, portTip } = await getServerConfig({
|
|
5476
5493
|
config
|
|
5477
|
-
}), devConfig = devServer_formatDevConfig(config.dev, port), routes = getRoutes(options.context);
|
|
5494
|
+
}), devConfig = devServer_formatDevConfig(config.dev, port), routes = getRoutes(options.context), root = options.context.rootPath;
|
|
5478
5495
|
options.context.devServer = {
|
|
5479
5496
|
hostname: host,
|
|
5480
5497
|
port,
|
|
@@ -5508,11 +5525,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5508
5525
|
protocol,
|
|
5509
5526
|
port,
|
|
5510
5527
|
host
|
|
5511
|
-
})
|
|
5512
|
-
await options.context.hooks.onBeforeStartDevServer.call({
|
|
5513
|
-
environments: options.context.environments
|
|
5514
|
-
});
|
|
5515
|
-
let cliShortcutsEnabled = isCliShortcutsEnabled(devConfig), printUrls = ()=>printServerURLs({
|
|
5528
|
+
}), cliShortcutsEnabled = isCliShortcutsEnabled(devConfig), printUrls = ()=>printServerURLs({
|
|
5516
5529
|
urls,
|
|
5517
5530
|
port,
|
|
5518
5531
|
routes,
|
|
@@ -5527,7 +5540,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5527
5540
|
clearCache: !0
|
|
5528
5541
|
}), closeServer = async ()=>{
|
|
5529
5542
|
await options.context.hooks.onCloseDevServer.call(), await Promise.all([
|
|
5530
|
-
devMiddlewares.close(),
|
|
5543
|
+
null == devMiddlewares ? void 0 : devMiddlewares.close(),
|
|
5531
5544
|
null == fileWatcher ? void 0 : fileWatcher.close()
|
|
5532
5545
|
]);
|
|
5533
5546
|
}, beforeCreateCompiler = ()=>{
|
|
@@ -5545,14 +5558,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5545
5558
|
options.context.hooks.onCloseDevServer.tap(cleanup);
|
|
5546
5559
|
}
|
|
5547
5560
|
!getPortSilently && portTip && rslog_index_js_namespaceObject.logger.info(portTip);
|
|
5548
|
-
}
|
|
5549
|
-
runCompile ? options.context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
|
|
5550
|
-
let compileMiddlewareAPI = runCompile ? await startCompile() : void 0, root = options.context.rootPath, fileWatcher = await setupWatchFiles({
|
|
5551
|
-
dev: devConfig,
|
|
5552
|
-
server: config.server,
|
|
5553
|
-
compileMiddlewareAPI,
|
|
5554
|
-
root
|
|
5555
|
-
}), readFileSync = (fileName)=>'readFileSync' in outputFileSystem ? outputFileSystem.readFileSync(fileName, 'utf-8') : external_node_fs_default().readFileSync(fileName, 'utf-8'), cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>getTransformedHtml(entryName, utils)), environmentAPI = Object.fromEntries(Object.entries(options.context.environments).map(([name, environment])=>[
|
|
5561
|
+
}, readFileSync = (fileName)=>'readFileSync' in outputFileSystem ? outputFileSystem.readFileSync(fileName, 'utf-8') : external_node_fs_default().readFileSync(fileName, 'utf-8'), cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>getTransformedHtml(entryName, utils)), environmentAPI = Object.fromEntries(Object.entries(options.context.environments).map(([name, environment])=>[
|
|
5556
5562
|
name,
|
|
5557
5563
|
{
|
|
5558
5564
|
getStats: async ()=>{
|
|
@@ -5568,19 +5574,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5568
5574
|
environment
|
|
5569
5575
|
}))
|
|
5570
5576
|
}
|
|
5571
|
-
])),
|
|
5572
|
-
pwd: root,
|
|
5573
|
-
compileMiddlewareAPI,
|
|
5574
|
-
dev: devConfig,
|
|
5575
|
-
server: config.server,
|
|
5576
|
-
environments: environmentAPI,
|
|
5577
|
-
output: {
|
|
5578
|
-
distPath: options.context.distPath || ROOT_DIST_DIR
|
|
5579
|
-
},
|
|
5580
|
-
outputFileSystem
|
|
5581
|
-
}), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect();
|
|
5582
|
-
for (let item of devMiddlewares.middlewares)Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5583
|
-
let devServerAPI = {
|
|
5577
|
+
])), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect(), devServerAPI = {
|
|
5584
5578
|
port,
|
|
5585
5579
|
middlewares,
|
|
5586
5580
|
environments: environmentAPI,
|
|
@@ -5595,7 +5589,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5595
5589
|
port
|
|
5596
5590
|
}, async (err)=>{
|
|
5597
5591
|
if (err) throw err;
|
|
5598
|
-
middlewares.use(notFoundMiddleware), httpServer.on('upgrade', devMiddlewares.onUpgrade), rslog_index_js_namespaceObject.logger.debug('listen dev server done'), await devServerAPI.afterListen(), onBeforeRestartServer(devServerAPI.close), resolve({
|
|
5592
|
+
middlewares.use(notFoundMiddleware), devMiddlewares && httpServer.on('upgrade', devMiddlewares.onUpgrade), rslog_index_js_namespaceObject.logger.debug('listen dev server done'), await devServerAPI.afterListen(), onBeforeRestartServer(devServerAPI.close), resolve({
|
|
5599
5593
|
port,
|
|
5600
5594
|
urls: urls.map((item)=>item.url),
|
|
5601
5595
|
server: {
|
|
@@ -5613,12 +5607,33 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5613
5607
|
});
|
|
5614
5608
|
},
|
|
5615
5609
|
connectWebSocket: ({ server })=>{
|
|
5616
|
-
server.on('upgrade', devMiddlewares.onUpgrade);
|
|
5610
|
+
devMiddlewares && server.on('upgrade', devMiddlewares.onUpgrade);
|
|
5617
5611
|
},
|
|
5618
5612
|
close: closeServer,
|
|
5619
5613
|
printUrls,
|
|
5620
5614
|
open: openPage
|
|
5621
5615
|
};
|
|
5616
|
+
await options.context.hooks.onBeforeStartDevServer.call({
|
|
5617
|
+
server: devServerAPI,
|
|
5618
|
+
environments: options.context.environments
|
|
5619
|
+
}), runCompile ? options.context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
|
|
5620
|
+
let compileMiddlewareAPI = runCompile ? await startCompile() : void 0;
|
|
5621
|
+
for (let item of (fileWatcher = await setupWatchFiles({
|
|
5622
|
+
dev: devConfig,
|
|
5623
|
+
server: config.server,
|
|
5624
|
+
compileMiddlewareAPI,
|
|
5625
|
+
root
|
|
5626
|
+
}), (devMiddlewares = await getMiddlewares({
|
|
5627
|
+
pwd: root,
|
|
5628
|
+
compileMiddlewareAPI,
|
|
5629
|
+
dev: devConfig,
|
|
5630
|
+
server: config.server,
|
|
5631
|
+
environments: environmentAPI,
|
|
5632
|
+
output: {
|
|
5633
|
+
distPath: options.context.distPath || ROOT_DIST_DIR
|
|
5634
|
+
},
|
|
5635
|
+
outputFileSystem
|
|
5636
|
+
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5622
5637
|
return rslog_index_js_namespaceObject.logger.debug('create dev server done'), devServerAPI;
|
|
5623
5638
|
}
|
|
5624
5639
|
async function createCompiler_createCompiler(options) {
|
|
@@ -6616,7 +6631,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6616
6631
|
}), actionArgs.push(options), command.commandAction.apply(this, actionArgs);
|
|
6617
6632
|
}
|
|
6618
6633
|
}
|
|
6619
|
-
let
|
|
6634
|
+
let dist = (name = "")=>new CAC(name), applyCommonOptions = (cli)=>{
|
|
6620
6635
|
cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
|
|
6621
6636
|
default: 'jiti'
|
|
6622
6637
|
}).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
@@ -6640,12 +6655,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6640
6655
|
}
|
|
6641
6656
|
}(), process.title = 'rsbuild-node';
|
|
6642
6657
|
let { npm_execpath } = process.env;
|
|
6643
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.
|
|
6658
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.8\n`);
|
|
6644
6659
|
}();
|
|
6645
6660
|
try {
|
|
6646
6661
|
!function() {
|
|
6647
|
-
let cli =
|
|
6648
|
-
cli.help(), cli.version("1.2.
|
|
6662
|
+
let cli = dist('rsbuild');
|
|
6663
|
+
cli.help(), cli.version("1.2.8"), applyCommonOptions(cli);
|
|
6649
6664
|
let devCommand = cli.command('dev', 'starting the dev server'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
|
|
6650
6665
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6651
6666
|
try {
|
|
@@ -6696,7 +6711,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6696
6711
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
6697
6712
|
}
|
|
6698
6713
|
}
|
|
6699
|
-
let src_rslib_entry_version = "1.2.
|
|
6714
|
+
let src_rslib_entry_version = "1.2.8";
|
|
6700
6715
|
})();
|
|
6701
6716
|
var __webpack_export_target__ = exports;
|
|
6702
6717
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|