@rsbuild/core 1.2.0-alpha.0 → 1.2.0-beta.1
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/README.md +1 -1
- package/compiled/css-loader/index.js +43 -62
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.js +20 -22
- package/compiled/postcss/index.js +131 -117
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +8 -28
- package/compiled/rsbuild-dev-middleware/index.js +25 -25
- package/compiled/rspack-chain/index.d.ts +1 -0
- package/compiled/rspack-chain/index.js +67 -66
- package/compiled/rspack-chain/package.json +1 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/style-loader/index.js +10 -10
- package/dist/client/overlay.js +2 -2
- package/dist/index.cjs +254 -250
- package/dist/index.js +544 -540
- package/dist/transformRawLoader.mjs +1 -1
- package/dist-types/helpers/fs.d.ts +1 -1
- package/dist-types/hooks.d.ts +2 -2
- package/dist-types/index.d.ts +2 -1
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +1 -0
- package/dist-types/types/config.d.ts +25 -3
- package/dist-types/types/hooks.d.ts +1 -1
- package/dist-types/types/plugin.d.ts +13 -2
- package/package.json +8 -8
- package/types.d.ts +4 -0
- package/dist-types/internal.d.ts +0 -6
package/dist/index.cjs
CHANGED
|
@@ -3,14 +3,8 @@ var __webpack_modules__ = {
|
|
|
3
3
|
"../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js": function(module) {
|
|
4
4
|
"use strict";
|
|
5
5
|
var isMergeableObject = function(value) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}(value) && !function(value) {
|
|
9
|
-
var stringValue = Object.prototype.toString.call(value);
|
|
10
|
-
return '[object RegExp]' === stringValue || '[object Date]' === stringValue || function(value) {
|
|
11
|
-
return value.$$typeof === REACT_ELEMENT_TYPE;
|
|
12
|
-
}(value);
|
|
13
|
-
}(value);
|
|
6
|
+
var value1, value2, stringValue;
|
|
7
|
+
return !!(value1 = value) && 'object' == typeof value1 && (value2 = value, '[object RegExp]' !== (stringValue = Object.prototype.toString.call(value2)) && '[object Date]' !== stringValue && value2.$$typeof !== REACT_ELEMENT_TYPE);
|
|
14
8
|
}, REACT_ELEMENT_TYPE = 'function' == typeof Symbol && Symbol.for ? Symbol.for('react.element') : 0xeac7;
|
|
15
9
|
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
16
10
|
return !1 !== options.clone && options.isMergeableObject(value) ? deepmerge(Array.isArray(value) ? [] : {}, value, options) : value;
|
|
@@ -21,10 +15,9 @@ var __webpack_modules__ = {
|
|
|
21
15
|
});
|
|
22
16
|
}
|
|
23
17
|
function getKeys(target) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}) : []));
|
|
18
|
+
return Object.keys(target).concat(Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
19
|
+
return Object.propertyIsEnumerable.call(target, symbol);
|
|
20
|
+
}) : []);
|
|
28
21
|
}
|
|
29
22
|
function propertyIsOnObject(object, property) {
|
|
30
23
|
try {
|
|
@@ -35,27 +28,23 @@ var __webpack_modules__ = {
|
|
|
35
28
|
}
|
|
36
29
|
function deepmerge(target, source, options) {
|
|
37
30
|
(options = options || {}).arrayMerge = options.arrayMerge || defaultArrayMerge, options.isMergeableObject = options.isMergeableObject || isMergeableObject, options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
destination[key] =
|
|
43
|
-
}), getKeys(source1).forEach(function(key) {
|
|
44
|
-
var target, key1;
|
|
45
|
-
if (!propertyIsOnObject(target = target1, key1 = key) || !!(Object.hasOwnProperty.call(target, key1) && Object.propertyIsEnumerable.call(target, key1))) propertyIsOnObject(target1, key) && options1.isMergeableObject(source1[key]) ? destination[key] = (function(key, options) {
|
|
31
|
+
var options1, destination, sourceIsArray = Array.isArray(source);
|
|
32
|
+
return sourceIsArray !== Array.isArray(target) ? cloneUnlessOtherwiseSpecified(source, options) : sourceIsArray ? options.arrayMerge(target, source, options) : (destination = {}, (options1 = options).isMergeableObject(target) && getKeys(target).forEach(function(key) {
|
|
33
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options1);
|
|
34
|
+
}), getKeys(source).forEach(function(key) {
|
|
35
|
+
(!propertyIsOnObject(target, key) || Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)) && (propertyIsOnObject(target, key) && options1.isMergeableObject(source[key]) ? destination[key] = (function(key, options) {
|
|
46
36
|
if (!options.customMerge) return deepmerge;
|
|
47
37
|
var customMerge = options.customMerge(key);
|
|
48
38
|
return 'function' == typeof customMerge ? customMerge : deepmerge;
|
|
49
|
-
})(key, options1)(
|
|
50
|
-
}), destination;
|
|
39
|
+
})(key, options1)(target[key], source[key], options1) : destination[key] = cloneUnlessOtherwiseSpecified(source[key], options1));
|
|
40
|
+
}), destination);
|
|
51
41
|
}
|
|
52
42
|
deepmerge.all = function(array, options) {
|
|
53
43
|
if (!Array.isArray(array)) throw Error('first argument should be an array');
|
|
54
44
|
return array.reduce(function(prev, next) {
|
|
55
45
|
return deepmerge(prev, next, options);
|
|
56
46
|
}, {});
|
|
57
|
-
};
|
|
58
|
-
module.exports = deepmerge;
|
|
47
|
+
}, module.exports = deepmerge;
|
|
59
48
|
},
|
|
60
49
|
"../../node_modules/.pnpm/dotenv-expand@12.0.1/node_modules/dotenv-expand/lib/main.js": function(module) {
|
|
61
50
|
"use strict";
|
|
@@ -219,7 +208,8 @@ var __webpack_modules__ = {
|
|
|
219
208
|
if (decryptionFailed) {
|
|
220
209
|
let err = Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
|
|
221
210
|
throw err.code = 'DECRYPTION_FAILED', err;
|
|
222
|
-
}
|
|
211
|
+
}
|
|
212
|
+
throw error;
|
|
223
213
|
}
|
|
224
214
|
},
|
|
225
215
|
parse: function(src) {
|
|
@@ -454,7 +444,8 @@ var __webpack_exports__ = {};
|
|
|
454
444
|
'avif',
|
|
455
445
|
'tif',
|
|
456
446
|
'tiff',
|
|
457
|
-
'jfif'
|
|
447
|
+
'jfif',
|
|
448
|
+
'cur'
|
|
458
449
|
], VIDEO_EXTENSIONS = [
|
|
459
450
|
'mp4',
|
|
460
451
|
'webm',
|
|
@@ -476,8 +467,7 @@ var __webpack_exports__ = {};
|
|
|
476
467
|
'*'
|
|
477
468
|
].some((key)=>values.includes(key));
|
|
478
469
|
};
|
|
479
|
-
isDebug() && (rslog_index_js_namespaceObject.logger.level = 'verbose')
|
|
480
|
-
rslog_index_js_namespaceObject.logger.override({
|
|
470
|
+
isDebug() && (rslog_index_js_namespaceObject.logger.level = 'verbose'), rslog_index_js_namespaceObject.logger.override({
|
|
481
471
|
debug: (message, ...args)=>{
|
|
482
472
|
if ('verbose' !== rslog_index_js_namespaceObject.logger.level) return;
|
|
483
473
|
let time = index_js_default().gray(`${function() {
|
|
@@ -517,12 +507,15 @@ var __webpack_exports__ = {};
|
|
|
517
507
|
});
|
|
518
508
|
});
|
|
519
509
|
}
|
|
520
|
-
async function emptyDir(dir) {
|
|
521
|
-
if (
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
force: !0
|
|
510
|
+
async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
511
|
+
if (!checkExists || await pathExists(dir)) try {
|
|
512
|
+
let entries = await external_node_fs_default().promises.readdir(dir, {
|
|
513
|
+
withFileTypes: !0
|
|
525
514
|
});
|
|
515
|
+
await Promise.all(entries.map(async (entry)=>{
|
|
516
|
+
let fullPath = external_node_path_default().resolve(dir, entry.name);
|
|
517
|
+
!keep.some((reg)=>reg.test(fullPath)) && (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));
|
|
518
|
+
}));
|
|
526
519
|
} catch (err) {
|
|
527
520
|
rslog_index_js_namespaceObject.logger.debug(`Failed to empty dir: ${dir}`), rslog_index_js_namespaceObject.logger.debug(err);
|
|
528
521
|
}
|
|
@@ -611,7 +604,7 @@ var __webpack_exports__ = {};
|
|
|
611
604
|
message = `${fileName}${mainMessage}${details}${stack}${moduleTrace}`;
|
|
612
605
|
} else message = stats;
|
|
613
606
|
let innerError = '-- inner error --';
|
|
614
|
-
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), (message = (
|
|
607
|
+
return !verbose && message.includes(innerError) && (message = message.split(innerError)[0]), (message = (message = hintNodePolyfill(message = function(message) {
|
|
615
608
|
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
616
609
|
if (-1 === message.indexOf(hint)) return message;
|
|
617
610
|
for (let plugin of [
|
|
@@ -649,13 +642,12 @@ var __webpack_exports__ = {};
|
|
|
649
642
|
}
|
|
650
643
|
])if (plugin.test.test(message)) return message.replace(hint, plugin.hint);
|
|
651
644
|
return message;
|
|
652
|
-
}(message))).split('\n')
|
|
645
|
+
}(message))).split('\n').filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim()).join('\n')).trim();
|
|
653
646
|
}
|
|
654
647
|
function formatStatsMessages(stats, verbose) {
|
|
655
648
|
var _stats_errors, _stats_warnings;
|
|
656
|
-
let formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
657
649
|
return {
|
|
658
|
-
errors:
|
|
650
|
+
errors: (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [],
|
|
659
651
|
warnings: (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || []
|
|
660
652
|
};
|
|
661
653
|
}
|
|
@@ -727,8 +719,7 @@ var __webpack_exports__ = {};
|
|
|
727
719
|
return 'string' == typeof publicPath ? formatPublicPath(publicPath, withSlash) : formatPublicPath(DEFAULT_ASSET_PREFIX, withSlash);
|
|
728
720
|
}, getPublicPathFromCompiler = (compiler)=>{
|
|
729
721
|
let { publicPath } = compiler.options.output;
|
|
730
|
-
|
|
731
|
-
return DEFAULT_ASSET_PREFIX;
|
|
722
|
+
return 'string' == typeof publicPath ? 'auto' === publicPath ? '' : publicPath.endsWith('/') ? publicPath : `${publicPath}/` : DEFAULT_ASSET_PREFIX;
|
|
732
723
|
}, urlJoin = (base, path)=>{
|
|
733
724
|
let [urlProtocol, baseUrl] = base.split('://');
|
|
734
725
|
return `${urlProtocol}://${external_node_path_namespaceObject.posix.join(baseUrl, path)}`;
|
|
@@ -768,7 +759,7 @@ var __webpack_exports__ = {};
|
|
|
768
759
|
}
|
|
769
760
|
let applyToCompiler = (compiler, apply)=>{
|
|
770
761
|
isMultiCompiler(compiler) ? compiler.compilers.forEach(apply) : apply(compiler, 0);
|
|
771
|
-
}, upperFirst = (str)=>str ? str.charAt(0).toUpperCase() + str.slice(1) : '', isURL = (str)=>str.startsWith('http') || str.startsWith('//:'), createVirtualModule = (content)=>`data:text/javascript,${content}`, isMultiCompiler = (compiler)=>'
|
|
762
|
+
}, upperFirst = (str)=>str ? str.charAt(0).toUpperCase() + str.slice(1) : '', isURL = (str)=>str.startsWith('http') || str.startsWith('//:'), createVirtualModule = (content)=>`data:text/javascript,${content}`, isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers);
|
|
772
763
|
function pick(obj, keys) {
|
|
773
764
|
return keys.reduce((ret, key)=>(void 0 !== obj[key] && (ret[key] = obj[key]), ret), {});
|
|
774
765
|
}
|
|
@@ -806,9 +797,7 @@ var __webpack_exports__ = {};
|
|
|
806
797
|
parsed,
|
|
807
798
|
cleanup: ()=>{
|
|
808
799
|
if (!cleaned) {
|
|
809
|
-
for (let key of Object.keys(parsed))
|
|
810
|
-
if ('NODE_ENV' !== key) process.env[key] === parsed[key] && delete process.env[key];
|
|
811
|
-
}
|
|
800
|
+
for (let key of Object.keys(parsed))'NODE_ENV' !== key && process.env[key] === parsed[key] && delete process.env[key];
|
|
812
801
|
cleaned = !0;
|
|
813
802
|
}
|
|
814
803
|
},
|
|
@@ -953,7 +942,7 @@ var __webpack_exports__ = {};
|
|
|
953
942
|
config.source ||= {}, config.source.define = {
|
|
954
943
|
...envs.publicVars,
|
|
955
944
|
...config.source.define
|
|
956
|
-
}, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.open
|
|
945
|
+
}, commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), !commonOpts.open || (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.open) || (config.server ||= {}, config.server.open = commonOpts.open), commonOpts.host && (config.server ||= {}, config.server.host = commonOpts.host), commonOpts.port && (config.server ||= {}, config.server.port = commonOpts.port), (null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.cliShortcuts) === void 0 && (config.dev ||= {}, config.dev.cliShortcuts = !0);
|
|
957
946
|
let rsbuild = await createRsbuild({
|
|
958
947
|
cwd: root,
|
|
959
948
|
rsbuildConfig: config,
|
|
@@ -985,7 +974,7 @@ var __webpack_exports__ = {};
|
|
|
985
974
|
let rsbuild = await init({
|
|
986
975
|
isRestart: !0
|
|
987
976
|
});
|
|
988
|
-
|
|
977
|
+
rsbuild && await rsbuild.startDevServer();
|
|
989
978
|
}, restartBuild = async ({ filePath, clear = !0 } = {})=>{
|
|
990
979
|
await beforeRestart({
|
|
991
980
|
filePath,
|
|
@@ -996,7 +985,7 @@ var __webpack_exports__ = {};
|
|
|
996
985
|
isRestart: !0,
|
|
997
986
|
isBuildWatch: !0
|
|
998
987
|
});
|
|
999
|
-
|
|
988
|
+
rsbuild && onBeforeRestartServer((await rsbuild.build({
|
|
1000
989
|
watch: !0
|
|
1001
990
|
})).close);
|
|
1002
991
|
};
|
|
@@ -1007,7 +996,7 @@ var __webpack_exports__ = {};
|
|
|
1007
996
|
let publicDirs = normalizePublicDirs(serverConfig.publicDir);
|
|
1008
997
|
if (!publicDirs.length) return;
|
|
1009
998
|
let watchPaths = publicDirs.filter((item)=>item.watch).map((item)=>item.name);
|
|
1010
|
-
if (
|
|
999
|
+
if (watchPaths.length) return startWatchFiles(prepareWatchOptions(watchPaths), compileMiddlewareAPI, root);
|
|
1011
1000
|
}(server, compileMiddlewareAPI, root);
|
|
1012
1001
|
return {
|
|
1013
1002
|
async close () {
|
|
@@ -1165,7 +1154,7 @@ var __webpack_exports__ = {};
|
|
|
1165
1154
|
exportLocalsConvention: 'camelCase'
|
|
1166
1155
|
},
|
|
1167
1156
|
emitAssets: !0
|
|
1168
|
-
}), getDefaultResolveConfig = ()=>(
|
|
1157
|
+
}), getDefaultResolveConfig = ()=>(swcHelpersPath || (swcHelpersPath = (0, external_node_path_namespaceObject.dirname)(config_require.resolve('@swc/helpers/package.json'))), {
|
|
1169
1158
|
alias: {
|
|
1170
1159
|
'@swc/helpers': swcHelpersPath
|
|
1171
1160
|
},
|
|
@@ -1235,8 +1224,7 @@ var __webpack_exports__ = {};
|
|
|
1235
1224
|
ignoreInitial: !0,
|
|
1236
1225
|
ignorePermissionErrors: !0,
|
|
1237
1226
|
...watchOptions
|
|
1238
|
-
})
|
|
1239
|
-
let callback = (func = async (filePath)=>{
|
|
1227
|
+
}), callback = (func = async (filePath)=>{
|
|
1240
1228
|
watcher.close(), isBuildWatch ? await restartBuild({
|
|
1241
1229
|
filePath
|
|
1242
1230
|
}) : await restartDevServer({
|
|
@@ -1482,7 +1470,7 @@ var __webpack_exports__ = {};
|
|
|
1482
1470
|
for(let index = 0; index < compilers.length; index++){
|
|
1483
1471
|
let compiler = compilers[index], compilerDone = !1;
|
|
1484
1472
|
(isWatch ? compiler.hooks.watchRun : compiler.hooks.run).tapPromise(name, async ()=>{
|
|
1485
|
-
!compilerDone && (compilerDone = !0, doneCompilers++),
|
|
1473
|
+
!compilerDone && (compilerDone = !0, doneCompilers++), waitBeforeCompileDone || (waitBeforeCompileDone = null == beforeCompile ? void 0 : beforeCompile()), await waitBeforeCompileDone, await beforeEnvironmentCompiler(index);
|
|
1486
1474
|
}), compiler.hooks.invalid.tap(name, ()=>{
|
|
1487
1475
|
compilerDone && (compilerDone = !1, doneCompilers--), doneCompilers <= 0 && (waitBeforeCompileDone = void 0);
|
|
1488
1476
|
});
|
|
@@ -1715,7 +1703,7 @@ var __webpack_exports__ = {};
|
|
|
1715
1703
|
async function createContext(options, userConfig, bundlerType) {
|
|
1716
1704
|
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;
|
|
1717
1705
|
return {
|
|
1718
|
-
version: "1.2.0-
|
|
1706
|
+
version: "1.2.0-beta.1",
|
|
1719
1707
|
rootPath,
|
|
1720
1708
|
distPath: '',
|
|
1721
1709
|
cachePath,
|
|
@@ -1880,17 +1868,17 @@ var __webpack_exports__ = {};
|
|
|
1880
1868
|
...AUDIO_EXTENSIONS
|
|
1881
1869
|
], emitAssets), createAssetRule('font', FONT_EXTENSIONS, emitAssets);
|
|
1882
1870
|
let assetsFilename = getMergedFilename('assets');
|
|
1883
|
-
chain.output.assetModuleFilename(assetsFilename),
|
|
1871
|
+
chain.output.assetModuleFilename(assetsFilename), emitAssets || chain.module.generator.merge({
|
|
1884
1872
|
'asset/resource': {
|
|
1885
1873
|
emit: !1
|
|
1886
1874
|
}
|
|
1887
1875
|
});
|
|
1888
1876
|
let { assetsInclude } = config.source;
|
|
1889
1877
|
if (assetsInclude) {
|
|
1890
|
-
let { dataUriLimit } = config.output
|
|
1878
|
+
let { dataUriLimit } = config.output;
|
|
1891
1879
|
chainStaticAssetRule({
|
|
1892
1880
|
emit: emitAssets,
|
|
1893
|
-
rule,
|
|
1881
|
+
rule: chain.module.rule('additional-assets').test(assetsInclude),
|
|
1894
1882
|
maxSize: 'number' == typeof dataUriLimit ? dataUriLimit : dataUriLimit.assets,
|
|
1895
1883
|
filename: assetsFilename,
|
|
1896
1884
|
assetType: 'additional'
|
|
@@ -1968,7 +1956,7 @@ var __webpack_exports__ = {};
|
|
|
1968
1956
|
let pluginCache = ()=>({
|
|
1969
1957
|
name: 'rsbuild:cache',
|
|
1970
1958
|
setup (api) {
|
|
1971
|
-
|
|
1959
|
+
'rspack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { environment, env })=>{
|
|
1972
1960
|
var digest;
|
|
1973
1961
|
let { config } = environment, { buildCache } = config.performance;
|
|
1974
1962
|
if (!1 === buildCache) {
|
|
@@ -1991,18 +1979,39 @@ var __webpack_exports__ = {};
|
|
|
1991
1979
|
}), addTrailingSep = (dir)=>dir.endsWith(external_node_path_namespaceObject.sep) ? dir : dir + external_node_path_namespaceObject.sep, isStrictSubdir = (parent, child)=>{
|
|
1992
1980
|
let parentDir = addTrailingSep(parent), childDir = addTrailingSep(child);
|
|
1993
1981
|
return parentDir !== childDir && childDir.startsWith(parentDir);
|
|
1982
|
+
}, normalizeCleanDistPath = (userOptions)=>{
|
|
1983
|
+
let defaultOptions = {
|
|
1984
|
+
enable: 'auto'
|
|
1985
|
+
};
|
|
1986
|
+
return 'boolean' == typeof userOptions || 'auto' === userOptions ? {
|
|
1987
|
+
...defaultOptions,
|
|
1988
|
+
enable: userOptions
|
|
1989
|
+
} : {
|
|
1990
|
+
...defaultOptions,
|
|
1991
|
+
...userOptions
|
|
1992
|
+
};
|
|
1994
1993
|
}, pluginCleanOutput = ()=>({
|
|
1995
1994
|
name: 'rsbuild:clean-output',
|
|
1996
1995
|
setup (api) {
|
|
1997
|
-
let
|
|
1998
|
-
let { rootPath, distPath } = api.context, config = api.getNormalizedConfig(),
|
|
1999
|
-
if (!0 ===
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
1996
|
+
let getRsbuildOutputPath = ()=>{
|
|
1997
|
+
let { rootPath, distPath } = api.context, config = api.getNormalizedConfig(), targetPath = (0, external_node_path_namespaceObject.join)(distPath, RSBUILD_OUTPUTS_PATH), { enable } = normalizeCleanDistPath(config.output.cleanDistPath);
|
|
1998
|
+
if (!0 === enable || 'auto' === enable && isStrictSubdir(rootPath, targetPath)) return {
|
|
1999
|
+
path: targetPath
|
|
2000
|
+
};
|
|
2001
|
+
}, getPathInfo = (environment)=>{
|
|
2002
|
+
let { rootPath } = api.context, { config, distPath } = environment, { enable, keep } = normalizeCleanDistPath(config.output.cleanDistPath);
|
|
2003
|
+
return 'auto' === enable ? isStrictSubdir(rootPath, distPath) ? {
|
|
2004
|
+
path: distPath,
|
|
2005
|
+
keep
|
|
2006
|
+
} : (rslog_index_js_namespaceObject.logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), rslog_index_js_namespaceObject.logger.warn(`Please set ${index_js_default().yellow('`output.cleanDistPath`')} config manually.`), rslog_index_js_namespaceObject.logger.warn(`Current root path: ${index_js_default().dim(rootPath)}`), void rslog_index_js_namespaceObject.logger.warn(`Current dist path: ${index_js_default().dim(distPath)}`)) : !0 === enable ? {
|
|
2007
|
+
path: distPath,
|
|
2008
|
+
keep
|
|
2009
|
+
} : void 0;
|
|
2003
2010
|
}, cleanAll = async (params)=>{
|
|
2004
|
-
|
|
2005
|
-
|
|
2011
|
+
for (let pathInfo of [
|
|
2012
|
+
...Object.values(params.environments).reduce((result, curr)=>(result.find((item)=>item.distPath === curr.distPath) || result.push(curr), result), []).map(getPathInfo),
|
|
2013
|
+
getRsbuildOutputPath()
|
|
2014
|
+
].filter((pathInfo)=>!!pathInfo))await emptyDir(pathInfo.path, pathInfo.keep);
|
|
2006
2015
|
};
|
|
2007
2016
|
api.onBeforeBuild(async ({ isFirstCompile, environments })=>{
|
|
2008
2017
|
isFirstCompile && await cleanAll({
|
|
@@ -2047,9 +2056,9 @@ var __webpack_exports__ = {};
|
|
|
2047
2056
|
}
|
|
2048
2057
|
let pluginHelper_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), setHTMLPlugin = (plugin)=>{
|
|
2049
2058
|
plugin && (pluginHelper_htmlPlugin = plugin);
|
|
2050
|
-
}, getHTMLPlugin = ()=>(
|
|
2059
|
+
}, getHTMLPlugin = ()=>(pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
|
|
2051
2060
|
cssExtractPlugin = plugin;
|
|
2052
|
-
}, getCssExtractPlugin = ()=>cssExtractPlugin
|
|
2061
|
+
}, getCssExtractPlugin = ()=>cssExtractPlugin || core_default().CssExtractRspackPlugin, getCSSModulesLocalIdentName = (config, isProd)=>config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), normalizeCssLoaderOptions = (options, exportOnlyLocals)=>{
|
|
2053
2062
|
if (options.modules && exportOnlyLocals) {
|
|
2054
2063
|
let { modules } = options;
|
|
2055
2064
|
return modules = !0 === modules ? {
|
|
@@ -2143,7 +2152,7 @@ var __webpack_exports__ = {};
|
|
|
2143
2152
|
order: 'pre',
|
|
2144
2153
|
handler: async (chain, { target, isProd, CHAIN_ID, environment })=>{
|
|
2145
2154
|
let rule = chain.module.rule(CHAIN_ID.RULE.CSS), { config } = environment;
|
|
2146
|
-
rule.test(CSS_REGEX).type(
|
|
2155
|
+
rule.test(CSS_REGEX).type("javascript/auto").dependency({
|
|
2147
2156
|
not: 'url'
|
|
2148
2157
|
});
|
|
2149
2158
|
let emitCss = config.output.emitCss ?? 'web' === target;
|
|
@@ -2363,8 +2372,8 @@ var __webpack_exports__ = {};
|
|
|
2363
2372
|
'link',
|
|
2364
2373
|
'style',
|
|
2365
2374
|
'meta',
|
|
2366
|
-
|
|
2367
|
-
|
|
2375
|
+
"script",
|
|
2376
|
+
"noscript",
|
|
2368
2377
|
'template'
|
|
2369
2378
|
], FILE_ATTRS = {
|
|
2370
2379
|
link: 'href',
|
|
@@ -2448,7 +2457,7 @@ var __webpack_exports__ = {};
|
|
|
2448
2457
|
return compilation.emitAsset(name, source), name;
|
|
2449
2458
|
}, addFavicon = async (headTags, favicon, compilation, publicPath)=>{
|
|
2450
2459
|
let href = favicon;
|
|
2451
|
-
|
|
2460
|
+
isURL(favicon) || (href = ensureAssetPrefix(await emitFavicon(compilation, favicon), publicPath));
|
|
2452
2461
|
let tag = {
|
|
2453
2462
|
tagName: 'link',
|
|
2454
2463
|
voidTag: !0,
|
|
@@ -2466,7 +2475,7 @@ var __webpack_exports__ = {};
|
|
|
2466
2475
|
let entryName = null === (_data_plugin_options = data.plugin.options) || void 0 === _data_plugin_options ? void 0 : _data_plugin_options.entryName;
|
|
2467
2476
|
if (!entryName) return data;
|
|
2468
2477
|
let { headTags, bodyTags } = data, { favicon, tagConfig, templateContent } = this.options[entryName];
|
|
2469
|
-
|
|
2478
|
+
hasTitle(templateContent) || addTitleTag(headTags, null === (_data_plugin_options1 = data.plugin.options) || void 0 === _data_plugin_options1 ? void 0 : _data_plugin_options1.title), favicon && await addFavicon(headTags, favicon, compilation, data.publicPath);
|
|
2470
2479
|
let tags = {
|
|
2471
2480
|
headTags: headTags.map(formatBasicTag),
|
|
2472
2481
|
bodyTags: bodyTags.map(formatBasicTag)
|
|
@@ -2514,7 +2523,7 @@ var __webpack_exports__ = {};
|
|
|
2514
2523
|
}
|
|
2515
2524
|
let getTagConfig = (config)=>{
|
|
2516
2525
|
let tags = castArray(config.html.tags).filter(Boolean);
|
|
2517
|
-
if (
|
|
2526
|
+
if (tags.length) return {
|
|
2518
2527
|
append: !0,
|
|
2519
2528
|
hash: !1,
|
|
2520
2529
|
publicPath: !0,
|
|
@@ -2527,7 +2536,6 @@ var __webpack_exports__ = {};
|
|
|
2527
2536
|
let { config, htmlPaths } = environment;
|
|
2528
2537
|
if (0 === Object.keys(htmlPaths).length) return;
|
|
2529
2538
|
let assetPrefix = getPublicPathFromChain(chain, !1), entries = chain.entryPoints.entries() || {}, entryNames = Object.keys(entries).filter((entryName)=>!!htmlPaths[entryName]), htmlInfoMap = {}, finalOptions = await Promise.all(entryNames.map(async (entryName)=>{
|
|
2530
|
-
var entryName1, entryName2, config1, assetPrefix1, entryName3, entryName4;
|
|
2531
2539
|
let entryValue = entries[entryName].values(), chunks = function(entryName, entryValue) {
|
|
2532
2540
|
let chunks = [
|
|
2533
2541
|
entryName
|
|
@@ -2535,40 +2543,16 @@ var __webpack_exports__ = {};
|
|
|
2535
2543
|
for (let item of entryValue){
|
|
2536
2544
|
if (!isPlainObject(item)) continue;
|
|
2537
2545
|
let { dependOn } = item;
|
|
2538
|
-
|
|
2546
|
+
dependOn && ('string' == typeof dependOn ? chunks.unshift(dependOn) : chunks.unshift(...dependOn));
|
|
2539
2547
|
}
|
|
2540
2548
|
return chunks;
|
|
2541
|
-
}(entryName, entryValue)
|
|
2542
|
-
let inject = (entryName1 = entryName, reduceConfigsMergeContext({
|
|
2549
|
+
}(entryName, entryValue), inject = reduceConfigsMergeContext({
|
|
2543
2550
|
initial: 'head',
|
|
2544
2551
|
config: config.html.inject,
|
|
2545
2552
|
ctx: {
|
|
2546
|
-
entryName:
|
|
2553
|
+
entryName: entryName
|
|
2547
2554
|
}
|
|
2548
|
-
})
|
|
2549
|
-
let templateParameters = (entryName2 = entryName, config1 = config, assetPrefix1 = assetPrefix, (compilation, assets, assetTags, pluginOptions)=>{
|
|
2550
|
-
let { mountId, templateParameters } = config1.html, rspackConfig = compilation.options, htmlPlugin = {
|
|
2551
|
-
tags: assetTags,
|
|
2552
|
-
files: assets,
|
|
2553
|
-
options: pluginOptions
|
|
2554
|
-
};
|
|
2555
|
-
return reduceConfigsWithContext({
|
|
2556
|
-
initial: {
|
|
2557
|
-
mountId,
|
|
2558
|
-
entryName: entryName2,
|
|
2559
|
-
assetPrefix: assetPrefix1,
|
|
2560
|
-
compilation,
|
|
2561
|
-
htmlPlugin,
|
|
2562
|
-
rspackConfig,
|
|
2563
|
-
webpackConfig: rspackConfig,
|
|
2564
|
-
htmlWebpackPlugin: htmlPlugin
|
|
2565
|
-
},
|
|
2566
|
-
config: templateParameters,
|
|
2567
|
-
ctx: {
|
|
2568
|
-
entryName: entryName2
|
|
2569
|
-
}
|
|
2570
|
-
});
|
|
2571
|
-
}), pluginOptions = {
|
|
2555
|
+
}), filename = htmlPaths[entryName], { templatePath, templateContent } = await getTemplate(entryName, config, api.context.rootPath), pluginOptions = {
|
|
2572
2556
|
meta: function(entryName, config, templateContent) {
|
|
2573
2557
|
let metaTags = reduceConfigsMergeContext({
|
|
2574
2558
|
initial: {},
|
|
@@ -2583,27 +2567,49 @@ var __webpack_exports__ = {};
|
|
|
2583
2567
|
inject,
|
|
2584
2568
|
filename,
|
|
2585
2569
|
entryName,
|
|
2586
|
-
templateParameters,
|
|
2570
|
+
templateParameters: (compilation, assets, assetTags, pluginOptions)=>{
|
|
2571
|
+
let { mountId, templateParameters } = config.html, rspackConfig = compilation.options, htmlPlugin = {
|
|
2572
|
+
tags: assetTags,
|
|
2573
|
+
files: assets,
|
|
2574
|
+
options: pluginOptions
|
|
2575
|
+
};
|
|
2576
|
+
return reduceConfigsWithContext({
|
|
2577
|
+
initial: {
|
|
2578
|
+
mountId,
|
|
2579
|
+
entryName: entryName,
|
|
2580
|
+
assetPrefix: assetPrefix,
|
|
2581
|
+
compilation,
|
|
2582
|
+
htmlPlugin,
|
|
2583
|
+
rspackConfig,
|
|
2584
|
+
webpackConfig: rspackConfig,
|
|
2585
|
+
htmlWebpackPlugin: htmlPlugin
|
|
2586
|
+
},
|
|
2587
|
+
config: templateParameters,
|
|
2588
|
+
ctx: {
|
|
2589
|
+
entryName: entryName
|
|
2590
|
+
}
|
|
2591
|
+
});
|
|
2592
|
+
},
|
|
2587
2593
|
scriptLoading: config.html.scriptLoading
|
|
2588
2594
|
};
|
|
2589
2595
|
templatePath && (pluginOptions.template = templatePath), chunks.length > 1 && (pluginOptions.chunksSortMode = 'manual');
|
|
2590
2596
|
let htmlInfo = {};
|
|
2591
2597
|
htmlInfoMap[entryName] = htmlInfo, templateContent && (htmlInfo.templateContent = templateContent);
|
|
2592
2598
|
let tagConfig = getTagConfig(environment.config);
|
|
2593
|
-
tagConfig && (htmlInfo.tagConfig = tagConfig), pluginOptions.title =
|
|
2599
|
+
tagConfig && (htmlInfo.tagConfig = tagConfig), pluginOptions.title = reduceConfigsMergeContext({
|
|
2594
2600
|
initial: '',
|
|
2595
2601
|
config: config.html.title,
|
|
2596
2602
|
ctx: {
|
|
2597
|
-
entryName:
|
|
2603
|
+
entryName: entryName
|
|
2598
2604
|
}
|
|
2599
|
-
})
|
|
2600
|
-
let favicon =
|
|
2605
|
+
});
|
|
2606
|
+
let favicon = reduceConfigsMergeContext({
|
|
2601
2607
|
initial: '',
|
|
2602
2608
|
config: config.html.favicon,
|
|
2603
2609
|
ctx: {
|
|
2604
|
-
entryName:
|
|
2610
|
+
entryName: entryName
|
|
2605
2611
|
}
|
|
2606
|
-
})
|
|
2612
|
+
});
|
|
2607
2613
|
favicon && (htmlInfo.favicon = favicon);
|
|
2608
2614
|
let finalOptions = reduceConfigsWithContext({
|
|
2609
2615
|
initial: pluginOptions,
|
|
@@ -2613,7 +2619,7 @@ var __webpack_exports__ = {};
|
|
|
2613
2619
|
entryValue
|
|
2614
2620
|
}
|
|
2615
2621
|
});
|
|
2616
|
-
return
|
|
2622
|
+
return finalOptions.template || finalOptions.templateContent || (pluginOptions.template = '', pluginOptions.templateContent = templateContent), finalOptions;
|
|
2617
2623
|
}));
|
|
2618
2624
|
if (entryNames.forEach((entryName, index)=>{
|
|
2619
2625
|
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).use(HtmlPlugin, [
|
|
@@ -2638,7 +2644,7 @@ var __webpack_exports__ = {};
|
|
|
2638
2644
|
let formattedCrossorigin = !0 === crossorigin ? 'anonymous' : crossorigin;
|
|
2639
2645
|
for (let tag of allTags){
|
|
2640
2646
|
var _tag_attrs, _tag_attrs1;
|
|
2641
|
-
(
|
|
2647
|
+
("script" === tag.tag && (null === (_tag_attrs = tag.attrs) || void 0 === _tag_attrs ? void 0 : _tag_attrs.src) || 'link' === tag.tag && (null === (_tag_attrs1 = tag.attrs) || void 0 === _tag_attrs1 ? void 0 : _tag_attrs1.rel) === 'stylesheet') && (tag.attrs.crossorigin ??= formattedCrossorigin);
|
|
2642
2648
|
}
|
|
2643
2649
|
}
|
|
2644
2650
|
return {
|
|
@@ -2675,7 +2681,7 @@ var __webpack_exports__ = {};
|
|
|
2675
2681
|
let source = asset.source().toString();
|
|
2676
2682
|
if (!matchTests(scriptName, source, scriptTests)) return tag;
|
|
2677
2683
|
let ret = {
|
|
2678
|
-
tag:
|
|
2684
|
+
tag: "script",
|
|
2679
2685
|
children: updateSourceMappingURL({
|
|
2680
2686
|
source,
|
|
2681
2687
|
compilation,
|
|
@@ -2707,7 +2713,7 @@ var __webpack_exports__ = {};
|
|
|
2707
2713
|
})
|
|
2708
2714
|
};
|
|
2709
2715
|
return inlinedAssets.add(linkName), ret;
|
|
2710
|
-
}, getInlinedTag = (publicPath, tag, compilation, scriptTests, styleTests, config)=>
|
|
2716
|
+
}, getInlinedTag = (publicPath, tag, compilation, scriptTests, styleTests, config)=>"script" === tag.tag ? getInlinedScriptTag(publicPath, tag, compilation, scriptTests, config) : 'link' === tag.tag && tag.attrs && 'stylesheet' === tag.attrs.rel ? getInlinedCSSTag(publicPath, tag, compilation, styleTests, config) : tag;
|
|
2711
2717
|
api.processAssets({
|
|
2712
2718
|
stage: 'summarize'
|
|
2713
2719
|
}, ({ compiler, compilation })=>{
|
|
@@ -2740,7 +2746,7 @@ var __webpack_exports__ = {};
|
|
|
2740
2746
|
var _config_dev;
|
|
2741
2747
|
if (isProd || 'web' !== target) return;
|
|
2742
2748
|
let { config } = environment, options = null === (_config_dev = config.dev) || void 0 === _config_dev ? void 0 : _config_dev.lazyCompilation;
|
|
2743
|
-
|
|
2749
|
+
options && chain.experiments({
|
|
2744
2750
|
...chain.get('experiments'),
|
|
2745
2751
|
lazyCompilation: options
|
|
2746
2752
|
});
|
|
@@ -2828,10 +2834,11 @@ var __webpack_exports__ = {};
|
|
|
2828
2834
|
...defaultOptions,
|
|
2829
2835
|
...manifest
|
|
2830
2836
|
};
|
|
2831
|
-
}(manifest), { RspackManifestPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rspack-manifest-plugin/index.js")), { htmlPaths } = environment;
|
|
2837
|
+
}(manifest), { RspackManifestPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rspack-manifest-plugin/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
|
|
2832
2838
|
chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
|
|
2833
2839
|
{
|
|
2834
2840
|
fileName: manifestOptions.filename,
|
|
2841
|
+
filter,
|
|
2835
2842
|
writeToFileEmit: isDev && !0 !== writeToDisk,
|
|
2836
2843
|
generate: generateManifest(htmlPaths, manifestOptions)
|
|
2837
2844
|
}
|
|
@@ -2904,13 +2911,13 @@ var __webpack_exports__ = {};
|
|
|
2904
2911
|
let applyPatch = (cacheGroup)=>{
|
|
2905
2912
|
if ('object' != typeof cacheGroup || (0, types_namespaceObject.isRegExp)(cacheGroup)) return;
|
|
2906
2913
|
let { chunks } = cacheGroup;
|
|
2907
|
-
if (
|
|
2914
|
+
if (chunks && 'async' !== chunks) {
|
|
2908
2915
|
if ('function' == typeof chunks) {
|
|
2909
2916
|
cacheGroup.chunks = (chunk)=>(!chunk.name || chunk.name !== this.name) && chunks(chunk);
|
|
2910
2917
|
return;
|
|
2911
2918
|
}
|
|
2912
2919
|
if ('all' === chunks) {
|
|
2913
|
-
cacheGroup.chunks = (chunk)
|
|
2920
|
+
cacheGroup.chunks = (chunk)=>!chunk.name || chunk.name !== this.name;
|
|
2914
2921
|
return;
|
|
2915
2922
|
}
|
|
2916
2923
|
if ('initial' === chunks) {
|
|
@@ -2921,7 +2928,7 @@ var __webpack_exports__ = {};
|
|
|
2921
2928
|
};
|
|
2922
2929
|
applyPatch(splitChunks);
|
|
2923
2930
|
let { cacheGroups } = splitChunks;
|
|
2924
|
-
if (
|
|
2931
|
+
if (cacheGroups) for (let cacheGroupKey of Object.keys(cacheGroups))applyPatch(cacheGroups[cacheGroupKey]);
|
|
2925
2932
|
}
|
|
2926
2933
|
constructor(name){
|
|
2927
2934
|
!function(obj, key, value) {
|
|
@@ -3001,7 +3008,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3001
3008
|
...headTags,
|
|
3002
3009
|
...bodyTags
|
|
3003
3010
|
];
|
|
3004
|
-
if (nonce) for (let tag of allTags)(
|
|
3011
|
+
if (nonce) for (let tag of allTags)("script" === tag.tag || 'style' === tag.tag) && (tag.attrs ??= {}, tag.attrs.nonce = nonce);
|
|
3005
3012
|
return {
|
|
3006
3013
|
headTags,
|
|
3007
3014
|
bodyTags
|
|
@@ -3100,7 +3107,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3100
3107
|
let interfaces = external_node_os_default().networkInterfaces(), ipv4Interfaces = new Map();
|
|
3101
3108
|
for (let key of Object.keys(interfaces))for (let detail of interfaces[key]){
|
|
3102
3109
|
let familyV4Value = 'string' == typeof detail.family ? 'IPv4' : 4;
|
|
3103
|
-
detail.family
|
|
3110
|
+
detail.family !== familyV4Value || ipv4Interfaces.has(detail.address) || ipv4Interfaces.set(detail.address, detail);
|
|
3104
3111
|
}
|
|
3105
3112
|
return Array.from(ipv4Interfaces.values());
|
|
3106
3113
|
}, isLoopbackHost = (host)=>[
|
|
@@ -3188,7 +3195,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3188
3195
|
}), !0;
|
|
3189
3196
|
rslog_index_js_namespaceObject.logger.debug('Failed to find the target browser.');
|
|
3190
3197
|
} catch (err) {
|
|
3191
|
-
rslog_index_js_namespaceObject.logger.debug(
|
|
3198
|
+
rslog_index_js_namespaceObject.logger.debug("Failed to open start URL with apple script."), rslog_index_js_namespaceObject.logger.debug(err);
|
|
3192
3199
|
}
|
|
3193
3200
|
try {
|
|
3194
3201
|
let { default: open } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/open/index.js"));
|
|
@@ -3226,7 +3233,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3226
3233
|
} catch (e) {
|
|
3227
3234
|
throw Error('[rsbuild:open]: Invalid input: not a valid URL or pathname');
|
|
3228
3235
|
}
|
|
3229
|
-
})(replacePortPlaceholder(target, port), baseUrl))) : routes.length && urls.push(`${baseUrl}${routes[0].pathname}`), before && await before(), urls))
|
|
3236
|
+
})(replacePortPlaceholder(target, port), baseUrl))) : routes.length && urls.push(`${baseUrl}${routes[0].pathname}`), before && await before(), urls))openedURLs.includes(url) || (openBrowser(url), openedURLs.push(url));
|
|
3230
3237
|
}
|
|
3231
3238
|
let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync : isServer ? jsPath : jsPath ? `${jsPath}/async` : 'async', pluginOutput = ()=>({
|
|
3232
3239
|
name: 'rsbuild:output',
|
|
@@ -3305,13 +3312,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3305
3312
|
}
|
|
3306
3313
|
}), api.modifyBundlerChain((chain, { environment })=>{
|
|
3307
3314
|
let { config } = environment, { profile } = config.performance;
|
|
3308
|
-
|
|
3315
|
+
profile && chain.profile(profile);
|
|
3309
3316
|
});
|
|
3310
3317
|
}
|
|
3311
3318
|
}), pluginProgress = ()=>({
|
|
3312
3319
|
name: 'rsbuild:progress',
|
|
3313
3320
|
setup (api) {
|
|
3314
|
-
|
|
3321
|
+
'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
3315
3322
|
let { config } = environment, options = config.dev.progressBar ?? 'production' === config.mode;
|
|
3316
3323
|
if (!options) return;
|
|
3317
3324
|
let prefix = !0 !== options && void 0 !== options.id ? options.id : environment.name;
|
|
@@ -3332,17 +3339,17 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3332
3339
|
let { config, tsconfigPath } = environment;
|
|
3333
3340
|
chain.resolve.extensions.merge([
|
|
3334
3341
|
...config.resolve.extensions
|
|
3335
|
-
]), tsconfigPath && chain.resolve.extensionAlias.merge({
|
|
3342
|
+
]), tsconfigPath && !tsconfigPath.endsWith('jsconfig.json') && chain.resolve.extensionAlias.merge({
|
|
3336
3343
|
'.js': [
|
|
3344
|
+
'.js',
|
|
3337
3345
|
'.ts',
|
|
3338
|
-
'.tsx'
|
|
3339
|
-
'.js'
|
|
3346
|
+
'.tsx'
|
|
3340
3347
|
],
|
|
3341
3348
|
'.jsx': [
|
|
3342
|
-
'.
|
|
3343
|
-
'.
|
|
3349
|
+
'.jsx',
|
|
3350
|
+
'.tsx'
|
|
3344
3351
|
]
|
|
3345
|
-
}),
|
|
3352
|
+
}), function({ chain, config, rootPath }) {
|
|
3346
3353
|
let mergedAlias = reduceConfigs({
|
|
3347
3354
|
initial: {},
|
|
3348
3355
|
config: config.resolve.alias
|
|
@@ -3411,7 +3418,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3411
3418
|
};
|
|
3412
3419
|
class HtmlPreloadOrPrefetchPlugin {
|
|
3413
3420
|
apply(compiler) {
|
|
3414
|
-
compiler.hooks.compilation.tap(this.
|
|
3421
|
+
compiler.hooks.compilation.tap(this.name, (compilation)=>{
|
|
3415
3422
|
getHTMLPlugin().getHooks(compilation).beforeAssetTagGeneration.tap(`HTML${upperFirst(this.type)}Plugin`, (htmlPluginData)=>(this.resourceHints = function(options, type, compilation, htmlPluginData, HTMLCount) {
|
|
3416
3423
|
let extractedChunks = function({ compilation, includeType }) {
|
|
3417
3424
|
let chunks = [
|
|
@@ -3426,7 +3433,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3426
3433
|
...(null === (_compilation_assetsInfo = compilation.assetsInfo) || void 0 === _compilation_assetsInfo ? void 0 : _compilation_assetsInfo.values()) || []
|
|
3427
3434
|
].map((info)=>{
|
|
3428
3435
|
var _info_related;
|
|
3429
|
-
return
|
|
3436
|
+
return null !== (_info_related = info.related) && void 0 !== _info_related && !!_info_related.license && info.related.license;
|
|
3430
3437
|
}).filter(Boolean);
|
|
3431
3438
|
return [
|
|
3432
3439
|
{
|
|
@@ -3442,8 +3449,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3442
3449
|
...new Set(('all-assets' === options.type || 1 === HTMLCount ? extractedChunks : extractedChunks.filter((chunk)=>(function({ chunk, htmlPluginData }) {
|
|
3443
3450
|
let { options } = htmlPluginData.plugin;
|
|
3444
3451
|
return recursiveChunkEntryNames(chunk).some((chunkName)=>{
|
|
3445
|
-
var
|
|
3446
|
-
return
|
|
3452
|
+
var includeChunks, excludeChunks;
|
|
3453
|
+
return includeChunks = null == options ? void 0 : options.chunks, excludeChunks = null == options ? void 0 : options.excludeChunks, !(Array.isArray(includeChunks) && -1 === includeChunks.indexOf(chunkName) || Array.isArray(excludeChunks) && -1 !== excludeChunks.indexOf(chunkName));
|
|
3447
3454
|
});
|
|
3448
3455
|
})({
|
|
3449
3456
|
chunk: chunk,
|
|
@@ -3468,11 +3475,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3468
3475
|
'css'
|
|
3469
3476
|
].includes(extension) ? 'style' : IMAGE_EXTENSIONS.includes(extension) ? 'image' : VIDEO_EXTENSIONS.includes(extension) ? 'video' : AUDIO_EXTENSIONS.includes(extension) ? 'audio' : FONT_EXTENSIONS.includes(extension) ? 'font' : [
|
|
3470
3477
|
'vtt'
|
|
3471
|
-
].includes(extension) ? 'track' :
|
|
3478
|
+
].includes(extension) ? 'track' : "script";
|
|
3472
3479
|
}({
|
|
3473
3480
|
href,
|
|
3474
3481
|
file
|
|
3475
|
-
}), 'font' === attributes.as && (attributes.crossorigin = ''), (
|
|
3482
|
+
}), 'font' === attributes.as && (attributes.crossorigin = ''), ("script" === attributes.as || 'style' === attributes.as) && crossOriginLoading && !('use-credentials' !== crossOriginLoading && '/' === publicPath) && (attributes.crossorigin = 'anonymous' === crossOriginLoading ? '' : crossOriginLoading)), links.push({
|
|
3476
3483
|
tagName: 'link',
|
|
3477
3484
|
attributes,
|
|
3478
3485
|
voidTag: !0,
|
|
@@ -3493,7 +3500,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3493
3500
|
});
|
|
3494
3501
|
}
|
|
3495
3502
|
constructor(options, type, HTMLCount){
|
|
3496
|
-
HtmlPreloadOrPrefetchPlugin_define_property(this, "options", void 0), HtmlPreloadOrPrefetchPlugin_define_property(this, "resourceHints", []), HtmlPreloadOrPrefetchPlugin_define_property(this, "type", void 0), HtmlPreloadOrPrefetchPlugin_define_property(this, "HTMLCount", void 0), this.options = {
|
|
3503
|
+
HtmlPreloadOrPrefetchPlugin_define_property(this, "options", void 0), HtmlPreloadOrPrefetchPlugin_define_property(this, "name", 'HtmlPreloadOrPrefetchPlugin'), HtmlPreloadOrPrefetchPlugin_define_property(this, "resourceHints", []), HtmlPreloadOrPrefetchPlugin_define_property(this, "type", void 0), HtmlPreloadOrPrefetchPlugin_define_property(this, "HTMLCount", void 0), this.options = {
|
|
3497
3504
|
...HtmlPreloadOrPrefetchPlugin_defaultOptions,
|
|
3498
3505
|
...'boolean' == typeof options ? {} : options
|
|
3499
3506
|
}, this.type = type, this.HTMLCount = HTMLCount;
|
|
@@ -3572,7 +3579,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3572
3579
|
rslog_index_js_namespaceObject.logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${index_js_default().bold(index_js_default().yellow(packageName))} module.`);
|
|
3573
3580
|
return;
|
|
3574
3581
|
}
|
|
3575
|
-
if (
|
|
3582
|
+
if (module && module[pluginName]) {
|
|
3576
3583
|
for (let config of bundlerConfigs)config.plugins ||= [], config.plugins.push(new module[pluginName]());
|
|
3577
3584
|
rslog_index_js_namespaceObject.logger.info(`${index_js_default().bold(index_js_default().yellow(packageName))} enabled.`);
|
|
3578
3585
|
}
|
|
@@ -3581,7 +3588,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3581
3588
|
}), external_node_inspector_namespaceObject = require("node:inspector");
|
|
3582
3589
|
var external_node_inspector_default = __webpack_require__.n(external_node_inspector_namespaceObject);
|
|
3583
3590
|
let stopProfiler = (output, profileSession)=>{
|
|
3584
|
-
|
|
3591
|
+
profileSession && profileSession.post('Profiler.stop', (error, param)=>{
|
|
3585
3592
|
if (error) {
|
|
3586
3593
|
rslog_index_js_namespaceObject.logger.error('Failed to generate JS CPU profile:', error);
|
|
3587
3594
|
return;
|
|
@@ -3598,7 +3605,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3598
3605
|
if (!RSPACK_PROFILE) return;
|
|
3599
3606
|
let timestamp = Date.now(), profileDirName = `rspack-profile-${timestamp}`, enableProfileTrace = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('TRACE'), enableCPUProfile = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('CPU'), enableLogging = 'ALL' === RSPACK_PROFILE || RSPACK_PROFILE.includes('LOGGING'), onStart = ()=>{
|
|
3600
3607
|
let profileDir = external_node_path_default().join(api.context.distPath, profileDirName), traceFilePath = external_node_path_default().join(profileDir, 'trace.json');
|
|
3601
|
-
|
|
3608
|
+
external_node_fs_default().existsSync(profileDir) || external_node_fs_default().mkdirSync(profileDir, {
|
|
3602
3609
|
recursive: !0
|
|
3603
3610
|
}), enableProfileTrace && core_default().experiments.globalTrace.register('trace', 'chrome', traceFilePath), enableCPUProfile && ((profileSession = new (external_node_inspector_default()).Session()).connect(), profileSession.post('Profiler.enable'), profileSession.post('Profiler.start'));
|
|
3604
3611
|
};
|
|
@@ -3636,7 +3643,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3636
3643
|
}
|
|
3637
3644
|
};
|
|
3638
3645
|
api.onAfterStartDevServer(onStartServer), api.onAfterStartProdServer(onStartServer), api.onBeforeBuild(async ({ isFirstCompile, environments })=>{
|
|
3639
|
-
if (
|
|
3646
|
+
if (isFirstCompile) for (let publicDir of normalizePublicDirs(api.getNormalizedConfig().server.publicDir)){
|
|
3640
3647
|
let { name, copyOnBuild } = publicDir;
|
|
3641
3648
|
if (!1 === copyOnBuild || !name) continue;
|
|
3642
3649
|
let normalizedPath = (0, external_node_path_namespaceObject.isAbsolute)(name) ? name : (0, external_node_path_namespaceObject.join)(api.context.rootPath, name);
|
|
@@ -3821,10 +3828,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3821
3828
|
...tags.bodyTags
|
|
3822
3829
|
]){
|
|
3823
3830
|
let url = '';
|
|
3824
|
-
if (!tag.attrs) continue;
|
|
3825
|
-
if ('script' === tag.tag && 'string' == typeof tag.attrs.src ? url = tag.attrs.src : 'link' === tag.tag && isSriLinkRel(tag.attrs.rel) && 'string' == typeof tag.attrs.href && (url = tag.attrs.href), !url) continue;
|
|
3831
|
+
if (!tag.attrs || ("script" === tag.tag && 'string' == typeof tag.attrs.src ? url = tag.attrs.src : 'link' === tag.tag && isSriLinkRel(tag.attrs.rel) && 'string' == typeof tag.attrs.href && (url = tag.attrs.href), !url)) continue;
|
|
3826
3832
|
let assetName = getAssetName(url, assetPrefix);
|
|
3827
|
-
|
|
3833
|
+
assetName && (tag.attrs.integrity ??= `${placeholder}${assetName}`);
|
|
3828
3834
|
}
|
|
3829
3835
|
return tags;
|
|
3830
3836
|
}
|
|
@@ -3837,10 +3843,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3837
3843
|
};
|
|
3838
3844
|
for (let match of matches){
|
|
3839
3845
|
let assetName = match[1];
|
|
3840
|
-
if (
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3846
|
+
if (assetName) {
|
|
3847
|
+
if (assets[assetName]) {
|
|
3848
|
+
let integrity = calcIntegrity(algorithm, assetName, assets[assetName].buffer());
|
|
3849
|
+
replacedHtml = replacedHtml.replaceAll(`integrity="${placeholder}${assetName}"`, `integrity="${integrity}"`);
|
|
3850
|
+
} else rslog_index_js_namespaceObject.logger.debug(`[rsbuild:sri] failed to generate integrity for ${assetName}.`), replacedHtml = replacedHtml.replace(`integrity="${placeholder}${assetName}"`, '');
|
|
3851
|
+
}
|
|
3844
3852
|
}
|
|
3845
3853
|
return replacedHtml;
|
|
3846
3854
|
};
|
|
@@ -3855,7 +3863,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3855
3863
|
for (let asset of Object.keys(assets)){
|
|
3856
3864
|
if (!HTML_REGEX.test(asset)) continue;
|
|
3857
3865
|
let htmlContent = assets[asset].source();
|
|
3858
|
-
|
|
3866
|
+
htmlContent.includes(placeholder) && (assets[asset] = new sources.RawSource(replaceIntegrity(htmlContent, assets, algorithm, integrityCache)));
|
|
3859
3867
|
}
|
|
3860
3868
|
});
|
|
3861
3869
|
}
|
|
@@ -3865,13 +3873,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3865
3873
|
api.modifyBundlerChain({
|
|
3866
3874
|
order: 'pre',
|
|
3867
3875
|
handler: async (chain, { CHAIN_ID, isDev, target, environment })=>{
|
|
3868
|
-
|
|
3869
|
-
let { config, browserslist: browserslist1 } = environment, cacheRoot = external_node_path_default().join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).type('javascript/auto').dependency({
|
|
3876
|
+
let { config, browserslist } = environment, cacheRoot = external_node_path_default().join(api.context.cachePath, '.swc'), rule = chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).type("javascript/auto").dependency({
|
|
3870
3877
|
not: 'url'
|
|
3871
3878
|
}), dataUriRule = chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
3872
3879
|
or: [
|
|
3873
|
-
|
|
3874
|
-
|
|
3880
|
+
"text/javascript",
|
|
3881
|
+
"application/javascript"
|
|
3875
3882
|
]
|
|
3876
3883
|
});
|
|
3877
3884
|
if (!function({ rule, isDev, config, context, rsbuildTarget }) {
|
|
@@ -3891,12 +3898,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3891
3898
|
context: api.context,
|
|
3892
3899
|
rsbuildTarget: target
|
|
3893
3900
|
}), 'webpack' === api.context.bundlerType) return;
|
|
3894
|
-
let swcConfig =
|
|
3901
|
+
let swcConfig = {
|
|
3895
3902
|
jsc: {
|
|
3896
3903
|
externalHelpers: !0,
|
|
3897
3904
|
parser: {
|
|
3898
3905
|
tsx: !1,
|
|
3899
|
-
syntax:
|
|
3906
|
+
syntax: "typescript",
|
|
3900
3907
|
decorators: !0
|
|
3901
3908
|
},
|
|
3902
3909
|
experimental: {
|
|
@@ -3908,7 +3915,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3908
3915
|
env: {
|
|
3909
3916
|
targets: browserslist
|
|
3910
3917
|
}
|
|
3911
|
-
}
|
|
3918
|
+
};
|
|
3912
3919
|
if (function(swcConfig, pluginImport) {
|
|
3913
3920
|
let finalPluginImport = reduceTransformImportConfig(pluginImport);
|
|
3914
3921
|
(null == finalPluginImport ? void 0 : finalPluginImport.length) && (swcConfig.rspackExperiments ??= {}, swcConfig.rspackExperiments.import ??= [], swcConfig.rspackExperiments.import.push(...finalPluginImport));
|
|
@@ -3925,7 +3932,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3925
3932
|
default:
|
|
3926
3933
|
throw Error(`[rsbuild:swc] Unknown decorators version: ${version}`);
|
|
3927
3934
|
}
|
|
3928
|
-
}(swcConfig, config), castArray(
|
|
3935
|
+
}(swcConfig, config), castArray(target).includes('web') || target.includes('web-worker')) {
|
|
3929
3936
|
let polyfillMode = config.output.polyfill;
|
|
3930
3937
|
if ('off' === polyfillMode) swcConfig.env.mode = void 0;
|
|
3931
3938
|
else {
|
|
@@ -4011,12 +4018,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4011
4018
|
});
|
|
4012
4019
|
});
|
|
4013
4020
|
}
|
|
4014
|
-
}), getInspectOutputPath = (context, inspectOptions)=>
|
|
4015
|
-
if (inspectOptions.outputPath) return (0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath);
|
|
4016
|
-
return (0, external_node_path_namespaceObject.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
|
|
4017
|
-
};
|
|
4021
|
+
}), getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath) : (0, external_node_path_namespaceObject.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
|
|
4018
4022
|
async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions = {} }) {
|
|
4019
|
-
inspectOptions.mode ? setNodeEnv(inspectOptions.mode) :
|
|
4023
|
+
inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : getNodeEnv() || setNodeEnv('development');
|
|
4020
4024
|
let rspackConfigs = bundlerConfigs || (await initConfigs({
|
|
4021
4025
|
context,
|
|
4022
4026
|
pluginManager,
|
|
@@ -4124,7 +4128,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4124
4128
|
POSTCSS: 'postcss',
|
|
4125
4129
|
LIGHTNINGCSS: 'lightningcss',
|
|
4126
4130
|
IGNORE_CSS: 'ignore-css',
|
|
4127
|
-
CSS_MODULES_TS:
|
|
4131
|
+
CSS_MODULES_TS: "css-modules-typescript",
|
|
4128
4132
|
MINI_CSS_EXTRACT: 'mini-css-extract',
|
|
4129
4133
|
RESOLVE_URL: 'resolve-url-loader'
|
|
4130
4134
|
},
|
|
@@ -4179,22 +4183,22 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4179
4183
|
mergeConfig: merge,
|
|
4180
4184
|
addRules (rules) {
|
|
4181
4185
|
let ruleArr = castArray(rules);
|
|
4182
|
-
|
|
4186
|
+
config.module || (config.module = {}), config.module.rules || (config.module.rules = []), config.module.rules.unshift(...ruleArr);
|
|
4183
4187
|
},
|
|
4184
4188
|
appendRules (rules) {
|
|
4185
4189
|
let ruleArr = castArray(rules);
|
|
4186
|
-
|
|
4190
|
+
config.module || (config.module = {}), config.module.rules || (config.module.rules = []), config.module.rules.push(...ruleArr);
|
|
4187
4191
|
},
|
|
4188
4192
|
prependPlugins (plugins) {
|
|
4189
4193
|
let pluginArr = castArray(plugins);
|
|
4190
|
-
|
|
4194
|
+
config.plugins || (config.plugins = []), config.plugins.unshift(...pluginArr);
|
|
4191
4195
|
},
|
|
4192
4196
|
appendPlugins (plugins) {
|
|
4193
4197
|
let pluginArr = castArray(plugins);
|
|
4194
|
-
|
|
4198
|
+
config.plugins || (config.plugins = []), config.plugins.push(...pluginArr);
|
|
4195
4199
|
},
|
|
4196
4200
|
removePlugin (pluginName) {
|
|
4197
|
-
|
|
4201
|
+
config.plugins && (config.plugins = config.plugins.filter((plugin)=>!plugin || (plugin.name || plugin.constructor.name) !== pluginName));
|
|
4198
4202
|
}
|
|
4199
4203
|
};
|
|
4200
4204
|
}
|
|
@@ -4253,7 +4257,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4253
4257
|
}
|
|
4254
4258
|
let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)=>{
|
|
4255
4259
|
let defaultEntry;
|
|
4256
|
-
let getDefaultEntryWithMemo = ()=>(
|
|
4260
|
+
let getDefaultEntryWithMemo = ()=>(defaultEntry || (defaultEntry = function(root) {
|
|
4257
4261
|
let entryFile = findExists([
|
|
4258
4262
|
'ts',
|
|
4259
4263
|
'js',
|
|
@@ -4266,7 +4270,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4266
4270
|
index: entryFile
|
|
4267
4271
|
} : {};
|
|
4268
4272
|
}(rootPath)), defaultEntry), { environments, dev, server, provider, ...rsbuildSharedConfig } = normalizedConfig, isEnvironmentEnabled = (name)=>!specifiedEnvironments || specifiedEnvironments.includes(name), applyEnvironmentDefaultConfig = (config)=>{
|
|
4269
|
-
|
|
4273
|
+
config.source.entry && 0 !== Object.keys(config.source.entry).length || (config.source.entry = getDefaultEntryWithMemo());
|
|
4270
4274
|
let isServer = 'node' === config.output.target;
|
|
4271
4275
|
return void 0 === config.output.distPath.js && (config.output.distPath.js = isServer ? '' : 'static/js'), config;
|
|
4272
4276
|
};
|
|
@@ -4449,8 +4453,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4449
4453
|
return (options)=>{
|
|
4450
4454
|
let { clientPaths, clientConfig, callbacks, liveReload, ...restOptions } = options;
|
|
4451
4455
|
return applyToCompiler(multiCompiler, (compiler)=>{
|
|
4452
|
-
clientPaths &&
|
|
4453
|
-
if (
|
|
4456
|
+
clientPaths && function({ compiler, clientPaths, clientConfig = {}, liveReload = !0 }) {
|
|
4457
|
+
if (isClientCompiler(compiler)) for (let clientPath of (new compiler.webpack.DefinePlugin({
|
|
4454
4458
|
RSBUILD_COMPILATION_NAME: JSON.stringify(getCompilationId(compiler)),
|
|
4455
4459
|
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
|
|
4456
4460
|
RSBUILD_DEV_LIVE_RELOAD: liveReload
|
|
@@ -4512,7 +4516,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4512
4516
|
}
|
|
4513
4517
|
class SocketServer {
|
|
4514
4518
|
upgrade(req, sock, head) {
|
|
4515
|
-
|
|
4519
|
+
this.wsServer.shouldHandle(req) && this.wsServer.handleUpgrade(req, sock, head, (connection)=>{
|
|
4516
4520
|
this.wsServer.emit('connection', connection, req);
|
|
4517
4521
|
});
|
|
4518
4522
|
}
|
|
@@ -4556,9 +4560,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4556
4560
|
this.timer && (clearInterval(this.timer), this.timer = null);
|
|
4557
4561
|
}
|
|
4558
4562
|
onConnect(socket, params) {
|
|
4559
|
-
|
|
4563
|
+
socket.isAlive = !0, socket.on('pong', ()=>{
|
|
4560
4564
|
socket.isAlive = !0;
|
|
4561
|
-
}),
|
|
4565
|
+
}), socket && (this.sockets.push(socket), socket.on('close', ()=>{
|
|
4562
4566
|
let idx = this.sockets.indexOf(socket);
|
|
4563
4567
|
idx >= 0 && this.sockets.splice(idx, 1);
|
|
4564
4568
|
}), (this.options.hmr || this.options.liveReload) && this.singleWrite(socket, {
|
|
@@ -4567,7 +4571,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4567
4571
|
}), this.stats && this.sendStats({
|
|
4568
4572
|
force: !0,
|
|
4569
4573
|
compilationId: params.compilationId
|
|
4570
|
-
});
|
|
4574
|
+
}));
|
|
4571
4575
|
}
|
|
4572
4576
|
getStats(name) {
|
|
4573
4577
|
let curStats = this.stats[name];
|
|
@@ -4589,20 +4593,16 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4589
4593
|
});
|
|
4590
4594
|
}
|
|
4591
4595
|
sendStats({ force = !1, compilationId }) {
|
|
4592
|
-
var a, b;
|
|
4593
4596
|
let stats = this.getStats(compilationId);
|
|
4594
4597
|
if (!stats) return null;
|
|
4595
4598
|
let newInitialChunks = new Set();
|
|
4596
4599
|
if (stats.entrypoints) for (let entrypoint of Object.values(stats.entrypoints)){
|
|
4597
4600
|
let chunks = entrypoint.chunks;
|
|
4598
|
-
if (
|
|
4599
|
-
if (!!chunkName) newInitialChunks.add(String(chunkName));
|
|
4600
|
-
}
|
|
4601
|
+
if (Array.isArray(chunks)) for (let chunkName of chunks)chunkName && newInitialChunks.add(String(chunkName));
|
|
4601
4602
|
}
|
|
4602
|
-
let initialChunks = this.initialChunks[compilationId]
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
].every((value)=>b.has(value))));
|
|
4603
|
+
let initialChunks = this.initialChunks[compilationId], shouldReload = !!stats.entrypoints && !!initialChunks && !(initialChunks.size === newInitialChunks.size && [
|
|
4604
|
+
...initialChunks
|
|
4605
|
+
].every((value)=>newInitialChunks.has(value)));
|
|
4606
4606
|
if (this.initialChunks[compilationId] = newInitialChunks, shouldReload) return this.sockWrite({
|
|
4607
4607
|
type: 'static-changed',
|
|
4608
4608
|
compilationId
|
|
@@ -4626,13 +4626,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4626
4626
|
data: {
|
|
4627
4627
|
text: formattedErrors,
|
|
4628
4628
|
html: function(errors) {
|
|
4629
|
-
let htmlItems = errors.map((item)=>{
|
|
4630
|
-
var text;
|
|
4631
|
-
return server_ansiHTML((text = item) ? text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') : '').replace(/(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g, (file)=>{
|
|
4629
|
+
let htmlItems = errors.map((item)=>server_ansiHTML(item ? item.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''') : '').replace(/(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g, (file)=>{
|
|
4632
4630
|
let hasClosingSpan = file.includes('</span>') && !file.includes('<span'), filePath = hasClosingSpan ? file.replace('</span>', '') : file;
|
|
4633
4631
|
return `<a class="file-link" data-file="${filePath}">${filePath}</a>${hasClosingSpan ? '</span>' : ''}`;
|
|
4634
|
-
});
|
|
4635
|
-
});
|
|
4632
|
+
}));
|
|
4636
4633
|
return `
|
|
4637
4634
|
<style>
|
|
4638
4635
|
.root {
|
|
@@ -4776,7 +4773,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4776
4773
|
});
|
|
4777
4774
|
}
|
|
4778
4775
|
send(connection, message) {
|
|
4779
|
-
|
|
4776
|
+
1 === connection.readyState && connection.send(message);
|
|
4780
4777
|
}
|
|
4781
4778
|
constructor(options){
|
|
4782
4779
|
socketServer_define_property(this, "wsServer", void 0), socketServer_define_property(this, "sockets", []), socketServer_define_property(this, "options", void 0), socketServer_define_property(this, "stats", void 0), socketServer_define_property(this, "initialChunks", void 0), socketServer_define_property(this, "timer", null), this.options = options, this.stats = {}, this.initialChunks = {};
|
|
@@ -4854,7 +4851,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4854
4851
|
clientPaths: function(devConfig) {
|
|
4855
4852
|
var _devConfig_client;
|
|
4856
4853
|
let clientPaths = [];
|
|
4857
|
-
return devConfig.hmr || devConfig.liveReload
|
|
4854
|
+
return (devConfig.hmr || devConfig.liveReload) && (clientPaths.push(compilerDevMiddleware_require.resolve('@rsbuild/core/client/hmr')), (null === (_devConfig_client = devConfig.client) || void 0 === _devConfig_client ? void 0 : _devConfig_client.overlay) && clientPaths.push(`${compilerDevMiddleware_require.resolve('@rsbuild/core/client/overlay')}`)), clientPaths;
|
|
4858
4855
|
}(devConfig),
|
|
4859
4856
|
clientConfig: devConfig.client,
|
|
4860
4857
|
liveReload: devConfig.liveReload,
|
|
@@ -4888,7 +4885,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4888
4885
|
].map((name)=>`const _${name} = ${SYNTHETIC_MODULES_STORE}[${i}]${'default' === name ? '' : `[${JSON.stringify(name)}]`}; export { _${name} as ${name}};`).join('\n'), m = new (external_node_vm_default()).SourceTextModule(code, {
|
|
4889
4886
|
context
|
|
4890
4887
|
});
|
|
4891
|
-
return unlinked
|
|
4888
|
+
return unlinked || (await m.link(()=>{}), m.instantiate && m.instantiate(), await m.evaluate()), m;
|
|
4892
4889
|
};
|
|
4893
4890
|
function basic_define_property(obj, key, value) {
|
|
4894
4891
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
@@ -4911,7 +4908,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4911
4908
|
};
|
|
4912
4909
|
class BasicRunner {
|
|
4913
4910
|
run(file) {
|
|
4914
|
-
|
|
4911
|
+
this.globalContext || (this.globalContext = this.createGlobalContext()), this.baseModuleScope = this.createBaseModuleScope(), this.createRunner();
|
|
4915
4912
|
let res = this.getRequire()(this._options.dist, file.startsWith('./') ? file : `./${file}`);
|
|
4916
4913
|
return 'object' == typeof res && 'then' in res ? res : Promise.resolve(res);
|
|
4917
4914
|
}
|
|
@@ -5032,7 +5029,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5032
5029
|
let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
|
|
5033
5030
|
if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
|
|
5034
5031
|
let esm = esmCache.get(file.path);
|
|
5035
|
-
return (
|
|
5032
|
+
return (esm || (esm = new (external_node_vm_default()).SourceTextModule(file.content, {
|
|
5036
5033
|
identifier: `${esmIdentifier}-${file.path}`,
|
|
5037
5034
|
url: `${(0, external_node_url_namespaceObject.pathToFileURL)(file.path).href}?${esmIdentifier}`,
|
|
5038
5035
|
context: esmContext,
|
|
@@ -5420,9 +5417,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5420
5417
|
};
|
|
5421
5418
|
let outputFileSystem = external_node_fs_default(), waitFirstCompileDone = runCompile ? new Promise((resolve)=>{
|
|
5422
5419
|
options.context.hooks.onDevCompileDone.tap(({ stats, isFirstCompile })=>{
|
|
5423
|
-
|
|
5420
|
+
lastStats = 'stats' in stats ? stats.stats : [
|
|
5424
5421
|
stats
|
|
5425
|
-
],
|
|
5422
|
+
], isFirstCompile && resolve();
|
|
5426
5423
|
});
|
|
5427
5424
|
}) : Promise.resolve(), startCompile = async ()=>{
|
|
5428
5425
|
let compiler = customCompiler || await createCompiler();
|
|
@@ -5567,10 +5564,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5567
5564
|
environments: context.environments
|
|
5568
5565
|
}), !await isSatisfyRspackVersion(core_namespaceObject.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${index_js_default().green(rspackMinVersion)}`);
|
|
5569
5566
|
let compiler = 1 === rspackConfigs.length ? (0, core_namespaceObject.rspack)(rspackConfigs[0]) : (0, core_namespaceObject.rspack)(rspackConfigs), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
5570
|
-
|
|
5567
|
+
isVersionLogged || (rslog_index_js_namespaceObject.logger.debug(`Use Rspack v${core_namespaceObject.rspack.rspackVersion}`), isVersionLogged = !0);
|
|
5571
5568
|
};
|
|
5572
5569
|
compiler.hooks.watchRun.tap('rsbuild:compiling', ()=>{
|
|
5573
|
-
logRspackVersion(),
|
|
5570
|
+
logRspackVersion(), isCompiling || rslog_index_js_namespaceObject.logger.start('Building...'), isCompiling = !0;
|
|
5574
5571
|
}), 'build' === context.command && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
|
|
5575
5572
|
let done = (stats)=>{
|
|
5576
5573
|
let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
|
|
@@ -5870,7 +5867,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5870
5867
|
api.modifyRsbuildConfig({
|
|
5871
5868
|
order: 'post',
|
|
5872
5869
|
handler: (config)=>{
|
|
5873
|
-
if (
|
|
5870
|
+
if (isUseAnalyzer(config) || Object.values(config.environments || []).some((config)=>isUseAnalyzer(config))) return config.dev ||= {}, config.dev.writeToDisk = !0, config;
|
|
5874
5871
|
}
|
|
5875
5872
|
}), api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
5876
5873
|
let { config } = environment;
|
|
@@ -5892,24 +5889,22 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5892
5889
|
{
|
|
5893
5890
|
name: 'rsbuild:module-federation',
|
|
5894
5891
|
setup (api) {
|
|
5895
|
-
|
|
5892
|
+
'webpack' !== api.context.bundlerType && (api.modifyRsbuildConfig((config)=>{
|
|
5896
5893
|
let { moduleFederation } = config;
|
|
5897
|
-
if (
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
config.dev ||= {}, (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.port) && !(null === (_config_dev_client = config.dev.client) || void 0 === _config_dev_client ? void 0 : _config_dev_client.port) && (config.dev.client ||= {}, config.dev.client.port = config.server.port), (null === (_originalConfig_dev = api.getRsbuildConfig('original').dev) || void 0 === _originalConfig_dev ? void 0 : _originalConfig_dev.assetPrefix) === void 0 && config.dev.assetPrefix === (null === (_config_server1 = config.server) || void 0 === _config_server1 ? void 0 : _config_server1.base) && (config.dev.assetPrefix = !0);
|
|
5901
|
-
}
|
|
5894
|
+
if ((null == moduleFederation ? void 0 : moduleFederation.options) && moduleFederation.options.exposes) {
|
|
5895
|
+
var _config_server, _config_dev_client, _originalConfig_dev, _config_server1;
|
|
5896
|
+
config.dev ||= {}, (null === (_config_server = config.server) || void 0 === _config_server ? void 0 : _config_server.port) && !(null === (_config_dev_client = config.dev.client) || void 0 === _config_dev_client ? void 0 : _config_dev_client.port) && (config.dev.client ||= {}, config.dev.client.port = config.server.port), (null === (_originalConfig_dev = api.getRsbuildConfig('original').dev) || void 0 === _originalConfig_dev ? void 0 : _originalConfig_dev.assetPrefix) === void 0 && config.dev.assetPrefix === (null === (_config_server1 = config.server) || void 0 === _config_server1 ? void 0 : _config_server1.base) && (config.dev.assetPrefix = !0);
|
|
5902
5897
|
}
|
|
5903
5898
|
}), api.modifyEnvironmentConfig((config)=>{
|
|
5904
5899
|
var _config_moduleFederation, _config_performance_chunkSplit, _config_performance;
|
|
5905
|
-
|
|
5900
|
+
(null === (_config_moduleFederation = config.moduleFederation) || void 0 === _config_moduleFederation ? void 0 : _config_moduleFederation.options) && ((null === (_config_performance = config.performance) || void 0 === _config_performance ? void 0 : null === (_config_performance_chunkSplit = _config_performance.chunkSplit) || void 0 === _config_performance_chunkSplit ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience' && (config.performance.chunkSplit = {
|
|
5906
5901
|
...config.performance.chunkSplit,
|
|
5907
5902
|
strategy: 'custom'
|
|
5908
5903
|
}), config.source.include = [
|
|
5909
5904
|
...config.source.include || [],
|
|
5910
5905
|
/@module-federation[\\/]sdk/,
|
|
5911
5906
|
/@module-federation[\\/]runtime/
|
|
5912
|
-
];
|
|
5907
|
+
]);
|
|
5913
5908
|
}), api.modifyBundlerChain(async (chain, { CHAIN_ID, target, environment })=>{
|
|
5914
5909
|
var _config_moduleFederation;
|
|
5915
5910
|
let { config } = environment;
|
|
@@ -5919,8 +5914,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5919
5914
|
options
|
|
5920
5915
|
]), options.name && (options.exposes && chain.plugin('mf-patch-split-chunks').use(PatchSplitChunksPlugin, [
|
|
5921
5916
|
options.name
|
|
5922
|
-
]),
|
|
5923
|
-
});
|
|
5917
|
+
]), chain.output.get('uniqueName') || chain.output.set('uniqueName', options.name));
|
|
5918
|
+
}));
|
|
5924
5919
|
}
|
|
5925
5920
|
},
|
|
5926
5921
|
pluginRspackProfile(),
|
|
@@ -5930,20 +5925,20 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5930
5925
|
]);
|
|
5931
5926
|
}
|
|
5932
5927
|
async function createRsbuild(options = {}) {
|
|
5933
|
-
let plugins
|
|
5928
|
+
let plugins;
|
|
5929
|
+
let { rsbuildConfig = {} } = options, rsbuildOptions = {
|
|
5934
5930
|
cwd: process.cwd(),
|
|
5935
5931
|
rsbuildConfig,
|
|
5936
5932
|
...options
|
|
5937
|
-
}
|
|
5938
|
-
let pluginManager = (plugins = [], {
|
|
5933
|
+
}, pluginManager = (plugins = [], {
|
|
5939
5934
|
getPlugins: (options = {
|
|
5940
5935
|
environment: RSBUILD_ALL_ENVIRONMENT_SYMBOL
|
|
5941
5936
|
})=>plugins.filter((p)=>isPluginMatchEnvironment(p.environment, options.environment)).map((p)=>p.instance),
|
|
5942
5937
|
getAllPluginsWithMeta: ()=>plugins,
|
|
5943
5938
|
addPlugins: (newPlugins, options)=>{
|
|
5944
5939
|
let { before, environment = RSBUILD_ALL_ENVIRONMENT_SYMBOL } = options || {};
|
|
5945
|
-
for (let newPlugin of newPlugins){
|
|
5946
|
-
if (
|
|
5940
|
+
for (let newPlugin of newPlugins)if (newPlugin) {
|
|
5941
|
+
if (function(plugin) {
|
|
5947
5942
|
let type = typeof plugin;
|
|
5948
5943
|
if ('object' !== type || null === plugin) throw Error(`[rsbuild:plugin] Expect Rsbuild plugin instance to be an object, but got ${type}.`);
|
|
5949
5944
|
if (!isFunction(plugin.setup)) {
|
|
@@ -6035,7 +6030,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6035
6030
|
}, transformId = 0, transformer = {}, processAssetsFns = [], resolveFns = [];
|
|
6036
6031
|
hooks.modifyBundlerChain.tap((chain, { target, environment })=>{
|
|
6037
6032
|
let pluginName = 'RsbuildCorePlugin';
|
|
6038
|
-
chain.plugin(pluginName).use(class
|
|
6033
|
+
chain.plugin(pluginName).use(class {
|
|
6039
6034
|
apply(compiler) {
|
|
6040
6035
|
for (let { handler, environment: pluginEnvironment } of (compiler.__rsbuildTransformer = transformer, resolveFns)){
|
|
6041
6036
|
if (pluginEnvironment && !isPluginMatchEnvironment(pluginEnvironment, environment.name)) return;
|
|
@@ -6068,6 +6063,15 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6068
6063
|
}
|
|
6069
6064
|
});
|
|
6070
6065
|
}
|
|
6066
|
+
constructor(){
|
|
6067
|
+
var key;
|
|
6068
|
+
(key = "name") in this ? Object.defineProperty(this, key, {
|
|
6069
|
+
value: pluginName,
|
|
6070
|
+
enumerable: !0,
|
|
6071
|
+
configurable: !0,
|
|
6072
|
+
writable: !0
|
|
6073
|
+
}) : this[key] = pluginName;
|
|
6074
|
+
}
|
|
6071
6075
|
});
|
|
6072
6076
|
});
|
|
6073
6077
|
let getTransformFn = (environment)=>(descriptor, handler)=>{
|
|
@@ -6077,7 +6081,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6077
6081
|
handler: (chain, { target, environment })=>{
|
|
6078
6082
|
if (descriptor.targets && !descriptor.targets.includes(target) || descriptor.environments && !descriptor.environments.includes(environment.name)) return;
|
|
6079
6083
|
let rule = chain.module.rule(id);
|
|
6080
|
-
descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer);
|
|
6084
|
+
descriptor.test && rule.test(descriptor.test), descriptor.resourceQuery && rule.resourceQuery(descriptor.resourceQuery), descriptor.layer && rule.layer(descriptor.layer), descriptor.issuerLayer && rule.issuerLayer(descriptor.issuerLayer), descriptor.issuer && rule.issuer(descriptor.issuer), descriptor.with && rule.with(descriptor.with);
|
|
6081
6085
|
let loaderName = descriptor.raw ? 'transformRawLoader.mjs' : 'transformLoader.mjs', loaderPath = (0, external_node_path_namespaceObject.join)(LOADER_PATH, loaderName);
|
|
6082
6086
|
rule.use(id).loader(loaderPath).options({
|
|
6083
6087
|
id,
|
|
@@ -6097,7 +6101,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6097
6101
|
handler
|
|
6098
6102
|
});
|
|
6099
6103
|
}, onExitListened = !1, onExit = (cb)=>{
|
|
6100
|
-
|
|
6104
|
+
onExitListened || (process.on('exit', ()=>{
|
|
6101
6105
|
hooks.onExit.call();
|
|
6102
6106
|
}), onExitListened = !0), hooks.onExit.tap(cb);
|
|
6103
6107
|
};
|
|
@@ -6169,35 +6173,35 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6169
6173
|
pluginManager,
|
|
6170
6174
|
rsbuildOptions,
|
|
6171
6175
|
helpers: provider_helpers_namespaceObject
|
|
6172
|
-
}),
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6176
|
+
}), rsbuild = {
|
|
6177
|
+
build: async (...args)=>{
|
|
6178
|
+
context.command = 'build', getNodeEnv() || setNodeEnv('production');
|
|
6179
|
+
let buildInstance = await providerInstance.build(...args);
|
|
6180
|
+
return {
|
|
6181
|
+
...buildInstance,
|
|
6182
|
+
close: async ()=>{
|
|
6183
|
+
await context.hooks.onCloseBuild.call(), await buildInstance.close();
|
|
6184
|
+
}
|
|
6185
|
+
};
|
|
6186
|
+
},
|
|
6187
|
+
preview: async (options = {})=>{
|
|
6188
|
+
context.command = 'preview', getNodeEnv() || setNodeEnv('production');
|
|
6189
|
+
let config = await initRsbuildConfig({
|
|
6190
|
+
context,
|
|
6191
|
+
pluginManager
|
|
6192
|
+
}), { distPath } = context, { checkDistDir = !0 } = options;
|
|
6193
|
+
if (checkDistDir) {
|
|
6194
|
+
if (!(0, external_node_fs_namespaceObject.existsSync)(distPath)) throw Error(`[rsbuild:preview] The output directory ${index_js_default().yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
6195
|
+
if (function(path) {
|
|
6196
|
+
let files = external_node_fs_default().readdirSync(path);
|
|
6197
|
+
return 0 === files.length || 1 === files.length && '.git' === files[0];
|
|
6198
|
+
}(distPath)) throw Error(`[rsbuild:preview] The output directory ${index_js_default().yellow(distPath)} is empty, please build the project before previewing.`);
|
|
6193
6199
|
}
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
createCompiler: (...args)=>(!context.command && (context.command = 'development' === getNodeEnv() ? 'dev' : 'build'), providerInstance.createCompiler(...args)),
|
|
6200
|
-
createDevServer: (...args)=>(context.command = 'dev', !getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
|
|
6200
|
+
return startProdServer(context, config, options);
|
|
6201
|
+
},
|
|
6202
|
+
startDevServer: (...args)=>(context.command = 'dev', getNodeEnv() || setNodeEnv('development'), providerInstance.startDevServer(...args)),
|
|
6203
|
+
createCompiler: (...args)=>(context.command || (context.command = 'development' === getNodeEnv() ? 'dev' : 'build'), providerInstance.createCompiler(...args)),
|
|
6204
|
+
createDevServer: (...args)=>(context.command = 'dev', getNodeEnv() || setNodeEnv('development'), providerInstance.createDevServer(...args)),
|
|
6201
6205
|
...pick(pluginManager, [
|
|
6202
6206
|
'addPlugins',
|
|
6203
6207
|
'getPlugins',
|
|
@@ -6269,7 +6273,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6269
6273
|
alias: {},
|
|
6270
6274
|
boolean: []
|
|
6271
6275
|
};
|
|
6272
|
-
for (let [index, option] of options.entries())option.names.length > 1 && (result.alias[option.names[0]] = option.names.slice(1)), option.isBoolean && (option.negated
|
|
6276
|
+
for (let [index, option] of options.entries())option.names.length > 1 && (result.alias[option.names[0]] = option.names.slice(1)), option.isBoolean && (option.negated && options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required) || result.boolean.push(option.names[0]));
|
|
6273
6277
|
return result;
|
|
6274
6278
|
}, findLongest = (arr)=>arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0], padRight = (str, length)=>str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`, camelcase = (input)=>input.replace(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase()), setDotProp = (obj, keys, val)=>{
|
|
6275
6279
|
let x, i = 0, length = keys.length, t = obj;
|
|
@@ -6361,7 +6365,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6361
6365
|
...this.options,
|
|
6362
6366
|
...globalOptions || []
|
|
6363
6367
|
];
|
|
6364
|
-
if (
|
|
6368
|
+
if (this.isGlobalCommand || this.isDefaultCommand || (options = options.filter((option)=>"version" !== option.name)), options.length > 0) {
|
|
6365
6369
|
let longestOptionName = findLongest(options.map((option)=>option.rawName));
|
|
6366
6370
|
sections.push({
|
|
6367
6371
|
title: "Options",
|
|
@@ -6444,7 +6448,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6444
6448
|
this.matchedCommand = void 0, this.matchedCommandName = void 0;
|
|
6445
6449
|
}
|
|
6446
6450
|
parse(argv = processArgs, { run = !0 } = {}) {
|
|
6447
|
-
this.rawArgs = argv,
|
|
6451
|
+
this.rawArgs = argv, this.name || (this.name = argv[1] ? getFileName(argv[1]) : "cli");
|
|
6448
6452
|
let shouldParse = !0;
|
|
6449
6453
|
for (let command of this.commands){
|
|
6450
6454
|
let parsed = this.mri(argv.slice(2), command), commandName = parsed.args[0];
|
|
@@ -6571,12 +6575,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6571
6575
|
}
|
|
6572
6576
|
}(), process.title = 'rsbuild-node';
|
|
6573
6577
|
let { npm_execpath } = process.env;
|
|
6574
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.0-
|
|
6578
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.0-beta.1\n`);
|
|
6575
6579
|
}();
|
|
6576
6580
|
try {
|
|
6577
6581
|
!function() {
|
|
6578
6582
|
let cli = cac_dist('rsbuild');
|
|
6579
|
-
cli.help(), cli.version("1.2.0-
|
|
6583
|
+
cli.help(), cli.version("1.2.0-beta.1"), applyCommonOptions(cli);
|
|
6580
6584
|
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');
|
|
6581
6585
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6582
6586
|
try {
|
|
@@ -6627,7 +6631,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6627
6631
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
6628
6632
|
}
|
|
6629
6633
|
}
|
|
6630
|
-
let src_rslib_entry_version = "1.2.0-
|
|
6634
|
+
let src_rslib_entry_version = "1.2.0-beta.1";
|
|
6631
6635
|
})();
|
|
6632
6636
|
var __webpack_export_target__ = exports;
|
|
6633
6637
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|