@rsbuild/core 1.4.6 → 1.4.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 +20 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/index.cjs +145 -106
- package/dist/index.js +147 -108
- package/dist-types/index.d.ts +1 -1
- package/dist-types/loadEnv.d.ts +4 -4
- package/dist-types/pluginManager.d.ts +8 -5
- package/dist-types/types/config.d.ts +6 -0
- package/dist-types/types/plugin.d.ts +10 -2
- package/dist-types/types/rsbuild.d.ts +15 -12
- package/package.json +5 -5
- package/types.d.ts +18 -1
package/dist/index.cjs
CHANGED
|
@@ -1607,47 +1607,6 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
1607
1607
|
}), actionArgs.push(options), command.commandAction.apply(this, actionArgs);
|
|
1608
1608
|
}
|
|
1609
1609
|
}
|
|
1610
|
-
let RSBUILD_ALL_ENVIRONMENT_SYMBOL = 'RSBUILD_ALL_ENVIRONMENT_SYMBOL', isPluginMatchEnvironment = (pluginEnvironment, currentEnvironment)=>pluginEnvironment === currentEnvironment || pluginEnvironment === RSBUILD_ALL_ENVIRONMENT_SYMBOL;
|
|
1611
|
-
async function initPlugins({ getPluginAPI, pluginManager }) {
|
|
1612
|
-
index_js_namespaceObject.logger.debug('init plugins');
|
|
1613
|
-
let plugins = ((plugins)=>{
|
|
1614
|
-
let allLines = [];
|
|
1615
|
-
function getPlugin(name) {
|
|
1616
|
-
let targets = plugins.filter((item)=>item.instance.name === name);
|
|
1617
|
-
if (!targets.length) throw Error(`${picocolors_index_js_default().dim('[rsbuild:plugin]')} Plugin "${picocolors_index_js_default().yellow(name)}" not existed`);
|
|
1618
|
-
return targets;
|
|
1619
|
-
}
|
|
1620
|
-
for (let plugin of plugins){
|
|
1621
|
-
if (plugin.instance.pre) for (let pre of plugin.instance.pre)pre && plugins.some((item)=>item.instance.name === pre) && allLines.push([
|
|
1622
|
-
pre,
|
|
1623
|
-
plugin.instance.name
|
|
1624
|
-
]);
|
|
1625
|
-
if (plugin.instance.post) for (let post of plugin.instance.post)post && plugins.some((item)=>item.instance.name === post) && allLines.push([
|
|
1626
|
-
plugin.instance.name,
|
|
1627
|
-
post
|
|
1628
|
-
]);
|
|
1629
|
-
}
|
|
1630
|
-
let zeroEndPoints = plugins.filter((item)=>!allLines.find((l)=>l[1] === item.instance.name)), sortedPoint = [];
|
|
1631
|
-
for(; zeroEndPoints.length;){
|
|
1632
|
-
let zep = zeroEndPoints.shift();
|
|
1633
|
-
sortedPoint.push(...getPlugin(zep.instance.name)), allLines = allLines.filter((l)=>l[0] !== getPlugin(zep.instance.name)[0].instance.name), zeroEndPoints = plugins.filter((item)=>!sortedPoint.find((sp)=>sp.instance.name === item.instance.name)).filter((item)=>!allLines.find((l)=>l[1] === item.instance.name));
|
|
1634
|
-
}
|
|
1635
|
-
if (allLines.length) {
|
|
1636
|
-
let restInRingPoints = {};
|
|
1637
|
-
for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
|
|
1638
|
-
throw Error(`${picocolors_index_js_default().dim('[rsbuild:plugin]')} Plugins dependencies has loop: ${picocolors_index_js_default().yellow(Object.keys(restInRingPoints).join(','))}`);
|
|
1639
|
-
}
|
|
1640
|
-
return sortedPoint;
|
|
1641
|
-
})(pluginManager.getAllPluginsWithMeta()), removedPlugins = plugins.reduce((ret, plugin)=>(plugin.instance.remove && (ret[plugin.environment] ??= [], ret[plugin.environment].push(...plugin.instance.remove)), ret), {});
|
|
1642
|
-
for (let plugin of plugins){
|
|
1643
|
-
var _removedPlugins_plugin_environment, _removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL;
|
|
1644
|
-
let isGlobalPlugin = 'RSBUILD_ALL_ENVIRONMENT_SYMBOL' === plugin.environment;
|
|
1645
|
-
if ((null == (_removedPlugins_plugin_environment = removedPlugins[plugin.environment]) ? void 0 : _removedPlugins_plugin_environment.includes(plugin.instance.name)) || !isGlobalPlugin && (null == (_removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL = removedPlugins[RSBUILD_ALL_ENVIRONMENT_SYMBOL]) ? void 0 : _removedPlugins_RSBUILD_ALL_ENVIRONMENT_SYMBOL.includes(plugin.instance.name))) continue;
|
|
1646
|
-
let { instance, environment } = plugin;
|
|
1647
|
-
await instance.setup(getPluginAPI(environment));
|
|
1648
|
-
}
|
|
1649
|
-
index_js_namespaceObject.logger.debug('init plugins done');
|
|
1650
|
-
}
|
|
1651
1610
|
function createEnvironmentAsyncHook() {
|
|
1652
1611
|
let preGroup = [], postGroup = [], defaultGroup = [], tapEnvironment = ({ environment, handler: cb })=>{
|
|
1653
1612
|
isFunction(cb) ? defaultGroup.push({
|
|
@@ -1675,7 +1634,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
1675
1634
|
...defaultGroup,
|
|
1676
1635
|
...postGroup
|
|
1677
1636
|
]){
|
|
1678
|
-
if (
|
|
1637
|
+
if (environment && callback.environment && callback.environment !== environment) continue;
|
|
1679
1638
|
let result = await callback.handler(...params);
|
|
1680
1639
|
void 0 !== result && (params[0] = result);
|
|
1681
1640
|
}
|
|
@@ -1688,7 +1647,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
1688
1647
|
...defaultGroup,
|
|
1689
1648
|
...postGroup
|
|
1690
1649
|
]){
|
|
1691
|
-
if (
|
|
1650
|
+
if (environment && callback.environment && callback.environment !== environment) continue;
|
|
1692
1651
|
let result = await callback.handler(...params);
|
|
1693
1652
|
results.push(result);
|
|
1694
1653
|
}
|
|
@@ -2131,6 +2090,57 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2131
2090
|
}
|
|
2132
2091
|
}
|
|
2133
2092
|
}
|
|
2093
|
+
let isEnvironmentMatch = (pluginEnvironment, specifiedEnvironment)=>pluginEnvironment === specifiedEnvironment || void 0 === pluginEnvironment;
|
|
2094
|
+
async function initPlugins({ context, pluginManager }) {
|
|
2095
|
+
index_js_namespaceObject.logger.debug('init plugins');
|
|
2096
|
+
let plugins = ((plugins)=>{
|
|
2097
|
+
let allLines = [];
|
|
2098
|
+
function getPlugin(name) {
|
|
2099
|
+
let targets = plugins.filter((item)=>item.instance.name === name);
|
|
2100
|
+
if (!targets.length) throw Error(`${picocolors_index_js_default().dim('[rsbuild:plugin]')} Plugin "${picocolors_index_js_default().yellow(name)}" not existed`);
|
|
2101
|
+
return targets;
|
|
2102
|
+
}
|
|
2103
|
+
for (let plugin of plugins){
|
|
2104
|
+
if (plugin.instance.pre) for (let pre of plugin.instance.pre)pre && plugins.some((item)=>item.instance.name === pre) && allLines.push([
|
|
2105
|
+
pre,
|
|
2106
|
+
plugin.instance.name
|
|
2107
|
+
]);
|
|
2108
|
+
if (plugin.instance.post) for (let post of plugin.instance.post)post && plugins.some((item)=>item.instance.name === post) && allLines.push([
|
|
2109
|
+
plugin.instance.name,
|
|
2110
|
+
post
|
|
2111
|
+
]);
|
|
2112
|
+
}
|
|
2113
|
+
let zeroEndPoints = plugins.filter((item)=>!allLines.find((l)=>l[1] === item.instance.name)), sortedPoint = [];
|
|
2114
|
+
for(; zeroEndPoints.length;){
|
|
2115
|
+
let zep = zeroEndPoints.shift();
|
|
2116
|
+
sortedPoint.push(...getPlugin(zep.instance.name)), allLines = allLines.filter((l)=>l[0] !== getPlugin(zep.instance.name)[0].instance.name), zeroEndPoints = plugins.filter((item)=>!sortedPoint.find((sp)=>sp.instance.name === item.instance.name)).filter((item)=>!allLines.find((l)=>l[1] === item.instance.name));
|
|
2117
|
+
}
|
|
2118
|
+
if (allLines.length) {
|
|
2119
|
+
let restInRingPoints = {};
|
|
2120
|
+
for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
|
|
2121
|
+
throw Error(`${picocolors_index_js_default().dim('[rsbuild:plugin]')} Plugins dependencies has loop: ${picocolors_index_js_default().yellow(Object.keys(restInRingPoints).join(','))}`);
|
|
2122
|
+
}
|
|
2123
|
+
return sortedPoint;
|
|
2124
|
+
})(pluginManager.getAllPluginsWithMeta()), removedPlugins = new Set(), removedEnvPlugins = {};
|
|
2125
|
+
for (let { environment, instance } of plugins)if (instance.remove) if (environment) for (let item of (removedEnvPlugins[environment] ??= new Set(), instance.remove))removedEnvPlugins[environment].add(item);
|
|
2126
|
+
else for (let item of instance.remove)removedPlugins.add(item);
|
|
2127
|
+
for (let { instance, environment } of plugins){
|
|
2128
|
+
var _removedEnvPlugins_environment;
|
|
2129
|
+
let { name, setup } = instance;
|
|
2130
|
+
if (!(removedPlugins.has(name) || environment && (null == (_removedEnvPlugins_environment = removedEnvPlugins[environment]) ? void 0 : _removedEnvPlugins_environment.has(name)))) {
|
|
2131
|
+
if (instance.apply && context.action) {
|
|
2132
|
+
let expected = {
|
|
2133
|
+
build: 'build',
|
|
2134
|
+
dev: 'serve',
|
|
2135
|
+
preview: 'serve'
|
|
2136
|
+
}[context.action];
|
|
2137
|
+
if (expected && instance.apply !== expected) continue;
|
|
2138
|
+
}
|
|
2139
|
+
await setup(context.getPluginAPI(environment));
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
index_js_namespaceObject.logger.debug('init plugins done');
|
|
2143
|
+
}
|
|
2134
2144
|
let mapProcessAssetsStage = (compiler, stage)=>{
|
|
2135
2145
|
let { Compilation } = compiler.webpack;
|
|
2136
2146
|
switch(stage){
|
|
@@ -2250,7 +2260,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2250
2260
|
async function createContext(options, userConfig) {
|
|
2251
2261
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(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, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
|
|
2252
2262
|
return {
|
|
2253
|
-
version: "1.4.
|
|
2263
|
+
version: "1.4.8",
|
|
2254
2264
|
rootPath,
|
|
2255
2265
|
distPath: '',
|
|
2256
2266
|
cachePath,
|
|
@@ -2640,7 +2650,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2640
2650
|
async function initRsbuildConfig({ context, pluginManager }) {
|
|
2641
2651
|
if (context.normalizedConfig) return context.normalizedConfig;
|
|
2642
2652
|
await initPlugins({
|
|
2643
|
-
|
|
2653
|
+
context,
|
|
2644
2654
|
pluginManager
|
|
2645
2655
|
}), await modifyRsbuildConfig(context);
|
|
2646
2656
|
let normalizedBaseConfig = ((config)=>{
|
|
@@ -2733,7 +2743,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2733
2743
|
}, await updateEnvironmentContext(context, environments);
|
|
2734
2744
|
var context1 = context;
|
|
2735
2745
|
let distPaths = Object.values(context1.environments).map((item)=>item.distPath);
|
|
2736
|
-
context1.distPath = function(paths) {
|
|
2746
|
+
return context1.distPath = function(paths) {
|
|
2737
2747
|
let uniquePaths = [
|
|
2738
2748
|
...new Set(paths)
|
|
2739
2749
|
];
|
|
@@ -2745,14 +2755,20 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2745
2755
|
else break;
|
|
2746
2756
|
}
|
|
2747
2757
|
return common.join(external_node_path_namespaceObject.sep);
|
|
2748
|
-
}(distPaths)
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2758
|
+
}(distPaths), ((config)=>{
|
|
2759
|
+
if (config.server.base && !config.server.base.startsWith('/')) throw Error(`${picocolors_index_js_default().dim('[rsbuild:config]')} The ${picocolors_index_js_default().yellow('"server.base"')} option should start with a slash, for example: "/base"`);
|
|
2760
|
+
if (!config.environments) return;
|
|
2761
|
+
let environmentNames = Object.keys(config.environments), environmentNameRegexp = /^[\w$-]+$/, validTargets = [
|
|
2762
|
+
'web',
|
|
2763
|
+
'node',
|
|
2764
|
+
'web-worker'
|
|
2765
|
+
];
|
|
2766
|
+
for (let name of environmentNames){
|
|
2767
|
+
environmentNameRegexp.test(name) || index_js_namespaceObject.logger.warn(`${picocolors_index_js_default().dim('[rsbuild:config]')} Environment name "${picocolors_index_js_default().yellow(name)}" contains invalid characters. Only letters, numbers, "-", "_", and "$" are allowed.`);
|
|
2768
|
+
let outputConfig = config.environments[name].output;
|
|
2769
|
+
if (outputConfig.target && !validTargets.includes(outputConfig.target)) throw Error(`${picocolors_index_js_default().dim('[rsbuild:config]')} Invalid value of ${picocolors_index_js_default().yellow('output.target')}: ${picocolors_index_js_default().yellow(`"${outputConfig.target}"`)}, valid values are: ${picocolors_index_js_default().yellow(validTargets.join(', '))}`);
|
|
2770
|
+
}
|
|
2771
|
+
})(context.normalizedConfig), context.normalizedConfig;
|
|
2756
2772
|
}
|
|
2757
2773
|
async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
2758
2774
|
let normalizedConfig = await initRsbuildConfig({
|
|
@@ -3227,9 +3243,10 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3227
3243
|
}, formatBasicTag = (tag)=>({
|
|
3228
3244
|
tag: tag.tagName,
|
|
3229
3245
|
attrs: tag.attributes,
|
|
3230
|
-
children: tag.innerHTML
|
|
3246
|
+
children: tag.innerHTML,
|
|
3247
|
+
metadata: tag.meta
|
|
3231
3248
|
}), fromBasicTag = (tag)=>({
|
|
3232
|
-
meta: {},
|
|
3249
|
+
meta: tag.metadata ?? {},
|
|
3233
3250
|
tagName: tag.tag,
|
|
3234
3251
|
attributes: tag.attrs ?? {},
|
|
3235
3252
|
voidTag: VOID_TAGS.includes(tag.tag),
|
|
@@ -3458,7 +3475,24 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3458
3475
|
} catch {
|
|
3459
3476
|
return !1;
|
|
3460
3477
|
}
|
|
3461
|
-
}, is_wsl = external_node_process_namespaceObject.env.__IS_WSL_TEST__ ? isWsl : isWsl()
|
|
3478
|
+
}, is_wsl = external_node_process_namespaceObject.env.__IS_WSL_TEST__ ? isWsl : isWsl(), wslDrivesMountPoint = (()=>{
|
|
3479
|
+
let mountPoint, defaultMountPoint = '/mnt/';
|
|
3480
|
+
return async function() {
|
|
3481
|
+
if (mountPoint) return mountPoint;
|
|
3482
|
+
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
3483
|
+
try {
|
|
3484
|
+
await promises_namespaceObject.access(configFilePath, promises_namespaceObject.constants.F_OK), isConfigFileExists = !0;
|
|
3485
|
+
} catch {}
|
|
3486
|
+
if (!isConfigFileExists) return defaultMountPoint;
|
|
3487
|
+
let configContent = await promises_namespaceObject.readFile(configFilePath, {
|
|
3488
|
+
encoding: 'utf8'
|
|
3489
|
+
}), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
3490
|
+
return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
|
|
3491
|
+
};
|
|
3492
|
+
})(), powerShellPathFromWsl = async ()=>{
|
|
3493
|
+
let mountPoint = await wslDrivesMountPoint();
|
|
3494
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
3495
|
+
}, powerShellPath = async ()=>is_wsl ? powerShellPathFromWsl() : `${external_node_process_namespaceObject.env.SYSTEMROOT || external_node_process_namespaceObject.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
3462
3496
|
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
3463
3497
|
let define = (value)=>Object.defineProperty(object, propertyName, {
|
|
3464
3498
|
value,
|
|
@@ -3577,26 +3611,9 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3577
3611
|
if ('win32' === external_node_process_namespaceObject.platform) return defaultBrowser();
|
|
3578
3612
|
throw Error('Only macOS, Linux, and Windows are supported');
|
|
3579
3613
|
}
|
|
3580
|
-
let execFile = external_node_util_namespaceObject.promisify(external_node_child_process_namespaceObject.execFile), open_dirname = external_node_path_namespaceObject.dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)), localXdgOpenPath = external_node_path_namespaceObject.join(open_dirname, 'xdg-open'), { platform, arch } = external_node_process_namespaceObject
|
|
3581
|
-
let mountPoint, defaultMountPoint = '/mnt/';
|
|
3582
|
-
return async function() {
|
|
3583
|
-
if (mountPoint) return mountPoint;
|
|
3584
|
-
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
3585
|
-
try {
|
|
3586
|
-
await promises_namespaceObject.access(configFilePath, external_node_fs_namespaceObject.constants.F_OK), isConfigFileExists = !0;
|
|
3587
|
-
} catch {}
|
|
3588
|
-
if (!isConfigFileExists) return defaultMountPoint;
|
|
3589
|
-
let configContent = await promises_namespaceObject.readFile(configFilePath, {
|
|
3590
|
-
encoding: 'utf8'
|
|
3591
|
-
}), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
3592
|
-
return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
|
|
3593
|
-
};
|
|
3594
|
-
})(), getPowershellPathFromWsl = async ()=>{
|
|
3595
|
-
let mountPoint = await getWslDrivesMountPoint();
|
|
3596
|
-
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
3597
|
-
};
|
|
3614
|
+
let execFile = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.execFile), open_dirname = external_node_path_namespaceObject.dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)), localXdgOpenPath = external_node_path_namespaceObject.join(open_dirname, 'xdg-open'), { platform, arch } = external_node_process_namespaceObject;
|
|
3598
3615
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
3599
|
-
let powershellPath = await
|
|
3616
|
+
let powershellPath = await powerShellPath(), rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, encodedCommand = external_node_buffer_namespaceObject.Buffer.from(rawCommand, 'utf16le').toString('base64'), { stdout } = await execFile(powershellPath, [
|
|
3600
3617
|
'-NoProfile',
|
|
3601
3618
|
'-NonInteractive',
|
|
3602
3619
|
'-ExecutionPolicy',
|
|
@@ -3607,6 +3624,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3607
3624
|
encoding: 'utf8'
|
|
3608
3625
|
}), progId = stdout.trim(), browserMap = {
|
|
3609
3626
|
ChromeHTML: 'com.google.chrome',
|
|
3627
|
+
BraveHTML: 'com.brave.Browser',
|
|
3610
3628
|
MSEdgeHTM: 'com.microsoft.edge',
|
|
3611
3629
|
FirefoxURL: 'org.mozilla.firefox'
|
|
3612
3630
|
};
|
|
@@ -3648,6 +3666,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3648
3666
|
let ids = {
|
|
3649
3667
|
'com.google.chrome': 'chrome',
|
|
3650
3668
|
'google-chrome.desktop': 'chrome',
|
|
3669
|
+
'com.brave.Browser': 'brave',
|
|
3651
3670
|
'org.mozilla.firefox': 'firefox',
|
|
3652
3671
|
'firefox.desktop': 'firefox',
|
|
3653
3672
|
'com.microsoft.msedge': 'edge',
|
|
@@ -3659,6 +3678,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3659
3678
|
let browserName = ids[browser.id];
|
|
3660
3679
|
return 'browserPrivate' === app && appArguments.push({
|
|
3661
3680
|
chrome: '--incognito',
|
|
3681
|
+
brave: '--incognito',
|
|
3662
3682
|
firefox: '--private-window',
|
|
3663
3683
|
edge: '--inPrivate'
|
|
3664
3684
|
}[browserName]), baseOpen({
|
|
@@ -3684,7 +3704,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3684
3704
|
}
|
|
3685
3705
|
appArguments.length > 0 && cliArguments.push(...appArguments), options.wait || (childProcessOptions.stdio = 'ignore', childProcessOptions.detached = !0);
|
|
3686
3706
|
} else {
|
|
3687
|
-
command =
|
|
3707
|
+
command = await powerShellPath(), cliArguments.push('-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand'), is_wsl || (childProcessOptions.windowsVerbatimArguments = !0);
|
|
3688
3708
|
let encodedArguments = [
|
|
3689
3709
|
'Start'
|
|
3690
3710
|
];
|
|
@@ -3727,9 +3747,24 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3727
3747
|
'/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'
|
|
3728
3748
|
]
|
|
3729
3749
|
}
|
|
3750
|
+
})), defineLazyProperty(apps, 'brave', ()=>detectPlatformBinary({
|
|
3751
|
+
darwin: 'brave browser',
|
|
3752
|
+
win32: 'brave',
|
|
3753
|
+
linux: [
|
|
3754
|
+
'brave-browser',
|
|
3755
|
+
'brave'
|
|
3756
|
+
]
|
|
3757
|
+
}, {
|
|
3758
|
+
wsl: {
|
|
3759
|
+
ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
3760
|
+
x64: [
|
|
3761
|
+
'/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe',
|
|
3762
|
+
'/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'
|
|
3763
|
+
]
|
|
3764
|
+
}
|
|
3730
3765
|
})), defineLazyProperty(apps, 'firefox', ()=>detectPlatformBinary({
|
|
3731
3766
|
darwin: 'firefox',
|
|
3732
|
-
win32:
|
|
3767
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
3733
3768
|
linux: 'firefox'
|
|
3734
3769
|
}, {
|
|
3735
3770
|
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
|
|
@@ -3784,13 +3819,13 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3784
3819
|
if (routes.length <= 1) {
|
|
3785
3820
|
let pathname = routes.length ? routes[0].pathname : '';
|
|
3786
3821
|
return urls.map(({ label, url })=>{
|
|
3787
|
-
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `\u{279C}
|
|
3822
|
+
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `\u{279C} ${picocolors_index_js_default().dim(label.padEnd(10))}`;
|
|
3788
3823
|
return ` ${prefix}${picocolors_index_js_default().cyan(normalizedPathname)}\n`;
|
|
3789
3824
|
}).join('');
|
|
3790
3825
|
}
|
|
3791
3826
|
let message = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
|
|
3792
3827
|
return urls.forEach(({ label, url }, index)=>{
|
|
3793
|
-
for (let r of (index > 0 && (message += '\n'), message += ` ${`\u{279C}
|
|
3828
|
+
for (let r of (index > 0 && (message += '\n'), message += ` ${`\u{279C} ${label}`}\n`, routes))message += ` ${picocolors_index_js_default().dim('-')} ${picocolors_index_js_default().dim(r.entryName.padEnd(maxNameLength + 4))}${picocolors_index_js_default().cyan(normalizeUrl(`${url}${r.pathname}`))}\n`;
|
|
3794
3829
|
}), message;
|
|
3795
3830
|
}(urls, routes);
|
|
3796
3831
|
return !1 === trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), index_js_namespaceObject.logger.log(message), message;
|
|
@@ -4309,7 +4344,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4309
4344
|
}
|
|
4310
4345
|
].filter(Boolean);
|
|
4311
4346
|
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error(`${picocolors_index_js_default().dim('[rsbuild:config]')} ${picocolors_index_js_default().yellow('dev.cliShortcuts')} option must return an array of shortcuts.`);
|
|
4312
|
-
help && index_js_namespaceObject.logger.log(!0 === help ? ` \u{279C}
|
|
4347
|
+
help && index_js_namespaceObject.logger.log(!0 === help ? ` \u{279C} ${picocolors_index_js_default().dim('press')} ${picocolors_index_js_default().bold('h + enter')} ${picocolors_index_js_default().dim('to show shortcuts')}\n` : ` \u{279C} ${help}\n`);
|
|
4313
4348
|
let { createInterface } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:readline")), rl = createInterface({
|
|
4314
4349
|
input: process.stdin
|
|
4315
4350
|
});
|
|
@@ -5467,15 +5502,22 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5467
5502
|
port: port1,
|
|
5468
5503
|
https
|
|
5469
5504
|
};
|
|
5470
|
-
let
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5505
|
+
let waitLastCompileDoneResolve = null, waitLastCompileDone = new Promise((resolve)=>{
|
|
5506
|
+
waitLastCompileDoneResolve = resolve;
|
|
5507
|
+
});
|
|
5508
|
+
context.hooks.onDevCompileDone.tap(({ stats })=>{
|
|
5509
|
+
lastStats = 'stats' in stats ? stats.stats : [
|
|
5510
|
+
stats
|
|
5511
|
+
], waitLastCompileDoneResolve && (waitLastCompileDoneResolve(), waitLastCompileDoneResolve = null);
|
|
5512
|
+
});
|
|
5513
|
+
let startCompile = async ()=>{
|
|
5477
5514
|
let compiler = customCompiler || await createCompiler();
|
|
5478
5515
|
if (!compiler) throw Error(`${picocolors_index_js_default().dim('[rsbuild:server]')} Failed to get compiler instance.`);
|
|
5516
|
+
null == compiler || compiler.hooks.watchRun.tap('rsbuild:watchRun', ()=>{
|
|
5517
|
+
lastStats && (waitLastCompileDoneResolve && (waitLastCompileDoneResolve(), waitLastCompileDoneResolve = null), waitLastCompileDone = new Promise((resolve)=>{
|
|
5518
|
+
waitLastCompileDoneResolve = resolve;
|
|
5519
|
+
}));
|
|
5520
|
+
});
|
|
5479
5521
|
let publicPaths = helpers_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
|
|
5480
5522
|
getPublicPathFromCompiler(compiler)
|
|
5481
5523
|
], compilationManager = new CompilationManager({
|
|
@@ -5533,19 +5575,19 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5533
5575
|
{
|
|
5534
5576
|
getStats: async ()=>{
|
|
5535
5577
|
if (!compilationManager) throw Error(`${picocolors_index_js_default().dim('[rsbuild:server]')} Can not call ${picocolors_index_js_default().yellow('getStats')} when ${picocolors_index_js_default().yellow('runCompile')} is false`);
|
|
5536
|
-
return await
|
|
5578
|
+
return await waitLastCompileDone, lastStats[environment.index];
|
|
5537
5579
|
},
|
|
5538
5580
|
context: environment,
|
|
5539
5581
|
loadBundle: async (entryName)=>{
|
|
5540
5582
|
if (!compilationManager) throw Error(`${picocolors_index_js_default().dim('[rsbuild:server]')} Can not call ${picocolors_index_js_default().yellow('loadBundle')} when ${picocolors_index_js_default().yellow('runCompile')} is false`);
|
|
5541
|
-
return await
|
|
5583
|
+
return await waitLastCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
|
|
5542
5584
|
readFileSync: compilationManager.readFileSync,
|
|
5543
5585
|
environment
|
|
5544
5586
|
});
|
|
5545
5587
|
},
|
|
5546
5588
|
getTransformedHtml: async (entryName)=>{
|
|
5547
5589
|
if (!compilationManager) throw Error(`${picocolors_index_js_default().dim('[rsbuild:server]')} Can not call ${picocolors_index_js_default().yellow('getTransformedHtml')} when ${picocolors_index_js_default().yellow('runCompile')} is false`);
|
|
5548
|
-
return await
|
|
5590
|
+
return await waitLastCompileDone, cacheableTransformedHtml(lastStats[environment.index], entryName, {
|
|
5549
5591
|
readFileSync: compilationManager.readFileSync,
|
|
5550
5592
|
environment
|
|
5551
5593
|
});
|
|
@@ -5902,7 +5944,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5902
5944
|
buildDependencies
|
|
5903
5945
|
});
|
|
5904
5946
|
}), api.onAfterCreateCompiler(()=>{
|
|
5905
|
-
cacheEnabled && 'rspack' === api.context.bundlerType && index_js_namespaceObject.logger.
|
|
5947
|
+
cacheEnabled && 'rspack' === api.context.bundlerType && index_js_namespaceObject.logger.debug('Rspack persistent cache enabled');
|
|
5906
5948
|
});
|
|
5907
5949
|
}
|
|
5908
5950
|
},
|
|
@@ -7214,10 +7256,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7214
7256
|
},
|
|
7215
7257
|
{
|
|
7216
7258
|
name: 'rsbuild:lazy-compilation',
|
|
7259
|
+
apply: 'serve',
|
|
7217
7260
|
setup (api) {
|
|
7218
|
-
api.modifyBundlerChain((chain, { environment,
|
|
7261
|
+
api.modifyBundlerChain((chain, { environment, target })=>{
|
|
7219
7262
|
var _config_dev;
|
|
7220
|
-
if (
|
|
7263
|
+
if ('web' !== target) return;
|
|
7221
7264
|
let { config } = environment, options = null == (_config_dev = config.dev) ? void 0 : _config_dev.lazyCompilation;
|
|
7222
7265
|
if (options) {
|
|
7223
7266
|
if (!0 === options && Object.keys(chain.entryPoints.entries() || {}).length <= 1) return void chain.experiments({
|
|
@@ -7334,12 +7377,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7334
7377
|
...options,
|
|
7335
7378
|
rsbuildConfig: config
|
|
7336
7379
|
}, pluginManager = (plugins = [], {
|
|
7337
|
-
getPlugins: (options = {
|
|
7338
|
-
environment: RSBUILD_ALL_ENVIRONMENT_SYMBOL
|
|
7339
|
-
})=>plugins.filter((p)=>isPluginMatchEnvironment(p.environment, options.environment)).map((p)=>p.instance),
|
|
7380
|
+
getPlugins: (options = {})=>plugins.filter((plugin)=>isEnvironmentMatch(plugin.environment, options.environment)).map(({ instance })=>instance),
|
|
7340
7381
|
getAllPluginsWithMeta: ()=>plugins,
|
|
7341
7382
|
addPlugins: (newPlugins, options)=>{
|
|
7342
|
-
let { before, environment
|
|
7383
|
+
let { before, environment } = options || {};
|
|
7343
7384
|
for (let newPlugin of newPlugins)if (newPlugin) {
|
|
7344
7385
|
var plugin = newPlugin;
|
|
7345
7386
|
let type = typeof plugin;
|
|
@@ -7381,9 +7422,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7381
7422
|
removePlugins: (pluginNames, options = {})=>{
|
|
7382
7423
|
plugins = plugins.filter((plugin)=>!(pluginNames.includes(plugin.instance.name) && (!options.environment || plugin.environment === options.environment)));
|
|
7383
7424
|
},
|
|
7384
|
-
isPluginExists: (pluginName, options = {
|
|
7385
|
-
environment: RSBUILD_ALL_ENVIRONMENT_SYMBOL
|
|
7386
|
-
})=>!!plugins.find((plugin)=>plugin.instance.name === pluginName && isPluginMatchEnvironment(plugin.environment, options.environment))
|
|
7425
|
+
isPluginExists: (pluginName, options = {})=>plugins.some((plugin)=>plugin.instance.name === pluginName && isEnvironmentMatch(plugin.environment, options.environment))
|
|
7387
7426
|
}), context = await createContext(resolvedOptions, config), getPluginAPI = function({ context, pluginManager }) {
|
|
7388
7427
|
let { hooks } = context, publicContext = function(context) {
|
|
7389
7428
|
let exposedKeys = [
|
|
@@ -7437,7 +7476,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7437
7476
|
let pluginName = 'RsbuildCorePlugin';
|
|
7438
7477
|
chain.plugin(pluginName).use(class {
|
|
7439
7478
|
apply(compiler) {
|
|
7440
|
-
for (let { handler, environment: pluginEnvironment } of (compiler.__rsbuildTransformer = transformer, resolveFns))(!pluginEnvironment ||
|
|
7479
|
+
for (let { handler, environment: pluginEnvironment } of (compiler.__rsbuildTransformer = transformer, resolveFns))(!pluginEnvironment || isEnvironmentMatch(pluginEnvironment, environment.name)) && compiler.hooks.compilation.tap(pluginName, (compilation, { normalModuleFactory })=>{
|
|
7441
7480
|
normalModuleFactory.hooks.resolve.tapPromise(pluginName, async (resolveData)=>handler({
|
|
7442
7481
|
compiler,
|
|
7443
7482
|
compilation,
|
|
@@ -7450,7 +7489,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7450
7489
|
childCompiler.__rsbuildTransformer = transformer;
|
|
7451
7490
|
});
|
|
7452
7491
|
let { sources } = compiler.webpack;
|
|
7453
|
-
for (let { descriptor, handler, environment: pluginEnvironment } of processAssetsFns)(!descriptor.targets || descriptor.targets.includes(target)) && (!descriptor.environments || descriptor.environments.includes(environment.name)) && (!pluginEnvironment ||
|
|
7492
|
+
for (let { descriptor, handler, environment: pluginEnvironment } of processAssetsFns)(!descriptor.targets || descriptor.targets.includes(target)) && (!descriptor.environments || descriptor.environments.includes(environment.name)) && (!pluginEnvironment || isEnvironmentMatch(pluginEnvironment, environment.name)) && compilation.hooks.processAssets.tapPromise({
|
|
7454
7493
|
name: pluginName,
|
|
7455
7494
|
stage: mapProcessAssetsStage(compiler, descriptor.stage)
|
|
7456
7495
|
}, async (assets)=>handler({
|
|
@@ -7864,11 +7903,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7864
7903
|
].includes(level) && (index_js_namespaceObject.logger.level = level);
|
|
7865
7904
|
}
|
|
7866
7905
|
let { npm_execpath } = process.env;
|
|
7867
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && index_js_namespaceObject.logger.log(), index_js_namespaceObject.logger.greet(` Rsbuild v1.4.
|
|
7906
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && index_js_namespaceObject.logger.log(), index_js_namespaceObject.logger.greet(` Rsbuild v1.4.8\n`);
|
|
7868
7907
|
try {
|
|
7869
7908
|
!function() {
|
|
7870
7909
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
7871
|
-
cli.help(), cli.version("1.4.
|
|
7910
|
+
cli.help(), cli.version("1.4.8"), 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`', {
|
|
7872
7911
|
default: 'jiti'
|
|
7873
7912
|
}).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('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
7874
7913
|
type: [
|
|
@@ -7926,7 +7965,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7926
7965
|
index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), index_js_namespaceObject.logger.error(err);
|
|
7927
7966
|
}
|
|
7928
7967
|
}
|
|
7929
|
-
let src_version = "1.4.
|
|
7968
|
+
let src_version = "1.4.8";
|
|
7930
7969
|
})(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
|
|
7931
7970
|
"PLUGIN_CSS_NAME",
|
|
7932
7971
|
"PLUGIN_SWC_NAME",
|