@rsbuild/core 1.2.11 → 1.2.13
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/chokidar/index.d.ts +61 -23
- package/compiled/chokidar/index.js +71 -56
- package/compiled/css-loader/index.js +309 -195
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.d.ts +1 -1
- package/compiled/launch-editor-middleware/index.js +9 -6
- package/compiled/mrmime/index.js +4 -0
- package/compiled/mrmime/package.json +1 -1
- package/compiled/postcss/index.js +194 -194
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-load-config/index.js +11 -11
- package/compiled/postcss-loader/index.js +9 -9
- package/compiled/rsbuild-dev-middleware/index.js +56 -46
- package/compiled/rsbuild-dev-middleware/package.json +1 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/sirv/index.js +8 -4
- package/compiled/sirv/package.json +1 -1
- package/compiled/style-loader/index.js +10 -10
- package/compiled/tinyglobby/index.d.ts +1 -0
- package/compiled/tinyglobby/index.js +266 -142
- package/compiled/tinyglobby/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/index.js +6 -2
- package/compiled/ws/index.js +50 -49
- package/compiled/ws/package.json +1 -1
- package/dist/client/hmr.js +2 -2
- package/dist/index.cjs +146 -93
- package/dist/index.js +142 -89
- package/dist-types/helpers/index.d.ts +4 -3
- package/dist-types/index.d.ts +1 -1
- package/dist-types/loadEnv.d.ts +16 -4
- package/dist-types/logger.d.ts +14 -0
- package/dist-types/server/devServer.d.ts +2 -1
- package/dist-types/server/socketServer.d.ts +4 -2
- package/dist-types/types/config.d.ts +79 -43
- package/dist-types/types/rspack.d.ts +1 -1
- package/package.json +12 -12
- package/compiled/jiti/index.d.ts +0 -1
- package/compiled/jiti/index.js +0 -416
- package/compiled/jiti/license +0 -21
- package/compiled/jiti/package.json +0 -1
package/dist/index.js
CHANGED
|
@@ -434,11 +434,11 @@ async function emptyDir(dir, keep = [], checkExists = !0) {
|
|
|
434
434
|
withFileTypes: !0
|
|
435
435
|
});
|
|
436
436
|
await Promise.all(entries.map(async (entry)=>{
|
|
437
|
-
let fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.
|
|
437
|
+
let fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(dir, entry.name);
|
|
438
438
|
!keep.some((reg)=>reg.test(toPosixPath(fullPath))) && (entry.isDirectory() ? (await emptyDir(fullPath, keep, !1), keep.length || await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.rmdir(fullPath)) : await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.unlink(fullPath));
|
|
439
439
|
}));
|
|
440
440
|
} catch (err) {
|
|
441
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`
|
|
441
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`failed to empty dir: ${dir}`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(err);
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
let hintNodePolyfill = (message)=>{
|
|
@@ -685,10 +685,12 @@ let camelCase = (input)=>input.replace(/[-_](\w)/g, (_, c)=>c.toUpperCase()), pr
|
|
|
685
685
|
if (seconds < 60) return `${format(seconds.toFixed(1))} s`;
|
|
686
686
|
let minutes = seconds / 60;
|
|
687
687
|
return `${format(minutes.toFixed(2))} m`;
|
|
688
|
-
}, isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI
|
|
688
|
+
}, isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI, addCompilationError = (compilation, message)=>{
|
|
689
|
+
compilation.errors.push(new compilation.compiler.webpack.WebpackError(message));
|
|
690
|
+
};
|
|
689
691
|
function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
690
692
|
'PUBLIC_'
|
|
691
|
-
] } = {}) {
|
|
693
|
+
], processEnv = process.env } = {}) {
|
|
692
694
|
if ('local' === mode) throw Error("[rsbuild:loadEnv] 'local' cannot be used as a value for env mode, because \".env.local\" represents a temporary local file. Please use another value.");
|
|
693
695
|
let filePaths = [
|
|
694
696
|
'.env',
|
|
@@ -696,13 +698,14 @@ function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
|
696
698
|
`.env.${mode}`,
|
|
697
699
|
`.env.${mode}.local`
|
|
698
700
|
].map((filename)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cwd, filename)).filter(isFileSync), parsed = {};
|
|
699
|
-
for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readFileSync(envPath)));
|
|
700
|
-
parsed.NODE_ENV && (
|
|
701
|
-
parsed
|
|
701
|
+
for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readFileSync(envPath))), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('loaded env file:', envPath);
|
|
702
|
+
parsed.NODE_ENV && (processEnv.NODE_ENV = parsed.NODE_ENV), (0, lib_main.expand)({
|
|
703
|
+
parsed,
|
|
704
|
+
processEnv
|
|
702
705
|
});
|
|
703
706
|
let publicVars = {}, rawPublicVars = {};
|
|
704
|
-
for (let key of Object.keys(
|
|
705
|
-
let val =
|
|
707
|
+
for (let key of Object.keys(processEnv))if (prefixes.some((prefix)=>key.startsWith(prefix))) {
|
|
708
|
+
let val = processEnv[key];
|
|
706
709
|
publicVars[`import.meta.env.${key}`] = JSON.stringify(val), publicVars[`process.env.${key}`] = JSON.stringify(val), rawPublicVars[key] = val;
|
|
707
710
|
}
|
|
708
711
|
let cleaned = !1;
|
|
@@ -710,7 +713,7 @@ function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
|
710
713
|
parsed,
|
|
711
714
|
cleanup: ()=>{
|
|
712
715
|
if (!cleaned) {
|
|
713
|
-
for (let key of Object.keys(parsed))'NODE_ENV' !== key &&
|
|
716
|
+
for (let key of Object.keys(parsed))'NODE_ENV' !== key && processEnv[key] === parsed[key] && delete processEnv[key];
|
|
714
717
|
cleaned = !0;
|
|
715
718
|
}
|
|
716
719
|
},
|
|
@@ -824,7 +827,7 @@ let configCache = {}, OVERRIDE_PATHS = [
|
|
|
824
827
|
merged[key] = mergeConfig_merge(x[key], y[key], childPath);
|
|
825
828
|
}
|
|
826
829
|
return merged;
|
|
827
|
-
}, mergeRsbuildConfig = (...configs)=>2 === configs.length ? mergeConfig_merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>mergeConfig_merge(result, config), {}), commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.
|
|
830
|
+
}, mergeRsbuildConfig = (...configs)=>2 === configs.length ? mergeConfig_merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>mergeConfig_merge(result, config), {}), commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(cwd, envDir) : cwd;
|
|
828
831
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
829
832
|
cliOptions && (commonOpts = cliOptions);
|
|
830
833
|
try {
|
|
@@ -881,8 +884,8 @@ let cleaners = [], onBeforeRestartServer = (cleaner)=>{
|
|
|
881
884
|
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
882
885
|
if (clear && clearConsole(), filePath) {
|
|
883
886
|
let filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(filePath);
|
|
884
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`
|
|
885
|
-
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`
|
|
887
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restarting ${id} because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(filename)} has changed\n`);
|
|
888
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restarting ${id}...\n`);
|
|
886
889
|
for (let cleaner of cleaners)await cleaner();
|
|
887
890
|
cleaners = [];
|
|
888
891
|
}, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
|
|
@@ -989,7 +992,8 @@ let config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.create
|
|
|
989
992
|
compress: !0,
|
|
990
993
|
printUrls: !0,
|
|
991
994
|
strictPort: !1,
|
|
992
|
-
cors: !1
|
|
995
|
+
cors: !1,
|
|
996
|
+
middlewareMode: !1
|
|
993
997
|
}), getDefaultSourceConfig = ()=>({
|
|
994
998
|
alias: {},
|
|
995
999
|
define: {},
|
|
@@ -1159,7 +1163,7 @@ async function watchFilesForRestart(files, root, isBuildWatch, watchOptions) {
|
|
|
1159
1163
|
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1160
1164
|
let configExport;
|
|
1161
1165
|
let configFilePath = resolveConfigPath(cwd, path);
|
|
1162
|
-
if (!configFilePath) return {
|
|
1166
|
+
if (!configFilePath) return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('no config file found.'), {
|
|
1163
1167
|
content: {},
|
|
1164
1168
|
filePath: configFilePath
|
|
1165
1169
|
};
|
|
@@ -1171,16 +1175,17 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loa
|
|
|
1171
1175
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
1172
1176
|
} catch (err) {
|
|
1173
1177
|
if ('native' === loader) throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with native loader: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
|
|
1174
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`
|
|
1178
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`failed to load file with dynamic import: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`);
|
|
1175
1179
|
}
|
|
1176
1180
|
try {
|
|
1177
1181
|
if (void 0 === configExport) {
|
|
1178
|
-
let {
|
|
1179
|
-
|
|
1180
|
-
esmResolve: !0,
|
|
1181
|
-
requireCache: !1,
|
|
1182
|
+
let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
|
|
1183
|
+
moduleCache: !1,
|
|
1182
1184
|
interopDefault: !0
|
|
1183
|
-
})
|
|
1185
|
+
});
|
|
1186
|
+
configExport = await jiti.import(configFilePath, {
|
|
1187
|
+
default: !0
|
|
1188
|
+
});
|
|
1184
1189
|
}
|
|
1185
1190
|
} catch (err) {
|
|
1186
1191
|
throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with jiti: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
|
|
@@ -1199,7 +1204,7 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loa
|
|
|
1199
1204
|
};
|
|
1200
1205
|
}
|
|
1201
1206
|
if (!isObject(configExport)) throw Error(`[rsbuild:loadConfig] The config must be an object or a function that returns an object, get ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(configExport)}`);
|
|
1202
|
-
return {
|
|
1207
|
+
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('loaded config file:', configFilePath), {
|
|
1203
1208
|
content: applyMetaInfo(configExport),
|
|
1204
1209
|
filePath: configFilePath
|
|
1205
1210
|
};
|
|
@@ -1239,13 +1244,13 @@ async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfi
|
|
|
1239
1244
|
...rawEnvironmentConfigs.map(({ name, content })=>{
|
|
1240
1245
|
if (1 === rawEnvironmentConfigs.length) return {
|
|
1241
1246
|
path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'rsbuild.config.mjs'),
|
|
1242
|
-
label: 'Rsbuild
|
|
1247
|
+
label: 'Rsbuild config',
|
|
1243
1248
|
content
|
|
1244
1249
|
};
|
|
1245
1250
|
let outputFile = `rsbuild.config.${name}.mjs`;
|
|
1246
1251
|
return {
|
|
1247
1252
|
path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile),
|
|
1248
|
-
label: `Rsbuild
|
|
1253
|
+
label: `Rsbuild config (${name})`,
|
|
1249
1254
|
content
|
|
1250
1255
|
};
|
|
1251
1256
|
}),
|
|
@@ -1262,7 +1267,7 @@ async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfi
|
|
|
1262
1267
|
recursive: !0
|
|
1263
1268
|
}), await Promise.all(files.map(async (item)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(item.path, `export default ${item.content}`)));
|
|
1264
1269
|
let fileInfos = files.map((item)=>` - ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(item.label))}: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.underline(item.path)}`).join('\n');
|
|
1265
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.success(`
|
|
1270
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
1266
1271
|
}
|
|
1267
1272
|
function stringifyConfig(config, verbose) {
|
|
1268
1273
|
return (0, __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__.default.toString)(config, {
|
|
@@ -1648,7 +1653,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
1648
1653
|
async function createContext(options, userConfig, bundlerType) {
|
|
1649
1654
|
let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
1650
1655
|
return {
|
|
1651
|
-
version: "1.2.
|
|
1656
|
+
version: "1.2.13",
|
|
1652
1657
|
rootPath,
|
|
1653
1658
|
distPath: '',
|
|
1654
1659
|
cachePath,
|
|
@@ -1727,12 +1732,24 @@ let pluginAppIcon = ()=>({
|
|
|
1727
1732
|
if (!appIcon) return;
|
|
1728
1733
|
let distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>formatIcon(icon, distDir, publicPath)), tags = [];
|
|
1729
1734
|
for (let icon of icons){
|
|
1730
|
-
if ('web-app-manifest' === icon.target && !appIcon.name)
|
|
1735
|
+
if ('web-app-manifest' === icon.target && !appIcon.name) {
|
|
1736
|
+
addCompilationError(compilation, '[rsbuild:app-icon] "appIcon.name" is required when "target" is "web-app-manifest".');
|
|
1737
|
+
continue;
|
|
1738
|
+
}
|
|
1731
1739
|
if (!icon.isURL) {
|
|
1732
|
-
if (!compilation.inputFileSystem)
|
|
1733
|
-
|
|
1740
|
+
if (!compilation.inputFileSystem) {
|
|
1741
|
+
addCompilationError(compilation, '[rsbuild:app-icon] Failed to read the icon file as "compilation.inputFileSystem" is not available.');
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
|
|
1745
|
+
addCompilationError(compilation, `[rsbuild:app-icon] Failed to find the icon file at "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(icon.absolutePath)}".`);
|
|
1746
|
+
continue;
|
|
1747
|
+
}
|
|
1734
1748
|
let source = await (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(compilation.inputFileSystem.readFile)(icon.absolutePath);
|
|
1735
|
-
if (!source)
|
|
1749
|
+
if (!source) {
|
|
1750
|
+
addCompilationError(compilation, `[rsbuild:app-icon] Failed to read the icon file at "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(icon.absolutePath)}".`);
|
|
1751
|
+
continue;
|
|
1752
|
+
}
|
|
1736
1753
|
compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
|
|
1737
1754
|
}
|
|
1738
1755
|
('apple-touch-icon' === icon.target || !icon.target && icon.size < 200) && tags.push({
|
|
@@ -1879,7 +1896,10 @@ let configChain_CHAIN_ID = {
|
|
|
1879
1896
|
api.modifyBundlerChain((chain, { isProd, environment })=>{
|
|
1880
1897
|
let { config } = environment, getMergedFilename = (assetType)=>{
|
|
1881
1898
|
let distDir = config.output.distPath[assetType], filename = getFilename(config, assetType, isProd);
|
|
1882
|
-
return
|
|
1899
|
+
return 'function' == typeof filename ? (...args)=>{
|
|
1900
|
+
let name = filename(...args);
|
|
1901
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.posix.join(distDir, name);
|
|
1902
|
+
} : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.posix.join(distDir, filename);
|
|
1883
1903
|
}, createAssetRule = (assetType, exts, emit)=>{
|
|
1884
1904
|
let regExp = function(exts) {
|
|
1885
1905
|
let matcher = exts.map((ext)=>ext.trim()).map((ext)=>ext.startsWith('.') ? ext.slice(1) : ext).join('|');
|
|
@@ -1946,7 +1966,7 @@ let configChain_CHAIN_ID = {
|
|
|
1946
1966
|
javascript: {
|
|
1947
1967
|
exportsPresence: 'error'
|
|
1948
1968
|
}
|
|
1949
|
-
}), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(
|
|
1969
|
+
}), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)), process.env.RSPACK_CONFIG_VALIDATE ||= 'loose-unrecognized-keys', process.env.WATCHPACK_WATCHER_LIMIT ||= '20', process.env.EXPERIMENTAL_RSPACK_INCREMENTAL && chain.experiments({
|
|
1950
1970
|
...chain.get('experiments'),
|
|
1951
1971
|
incremental: isDev
|
|
1952
1972
|
});
|
|
@@ -1963,7 +1983,7 @@ async function validateWebpackCache(cacheDirectory, buildDependencies) {
|
|
|
1963
1983
|
try {
|
|
1964
1984
|
prevBuildDependencies = JSON.parse(rawConfigFile);
|
|
1965
1985
|
} catch (e) {
|
|
1966
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('
|
|
1986
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('failed to parse the previous buildDependencies.json', e);
|
|
1967
1987
|
}
|
|
1968
1988
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) return;
|
|
1969
1989
|
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.rm(cacheDirectory, {
|
|
@@ -2514,16 +2534,25 @@ let VOID_TAGS = [
|
|
|
2514
2534
|
class RsbuildHtmlPlugin {
|
|
2515
2535
|
apply(compiler) {
|
|
2516
2536
|
let emitFavicon = async (compilation, favicon)=>{
|
|
2537
|
+
let buffer;
|
|
2517
2538
|
let name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(favicon);
|
|
2518
2539
|
if (compilation.assets[name]) return name;
|
|
2519
|
-
if (!compilation.inputFileSystem)
|
|
2520
|
-
let filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.
|
|
2521
|
-
|
|
2522
|
-
|
|
2540
|
+
if (!compilation.inputFileSystem) return addCompilationError(compilation, '[rsbuild:html] Failed to read the favicon file as "compilation.inputFileSystem" is not available.'), null;
|
|
2541
|
+
let filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(favicon) ? favicon : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(compilation.compiler.context, favicon);
|
|
2542
|
+
try {
|
|
2543
|
+
if (!(buffer = await (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(compilation.inputFileSystem.readFile)(filename))) throw Error('Buffer is undefined');
|
|
2544
|
+
} catch (error) {
|
|
2545
|
+
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `[rsbuild:html] Failed to read the favicon file at "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(filename)}".`), null;
|
|
2546
|
+
}
|
|
2547
|
+
let source = new compiler.webpack.sources.RawSource(buffer, !1);
|
|
2523
2548
|
return compilation.emitAsset(name, source), name;
|
|
2524
2549
|
}, addFavicon = async (headTags, favicon, compilation, publicPath)=>{
|
|
2525
2550
|
let href = favicon;
|
|
2526
|
-
|
|
2551
|
+
if (!isURL(favicon)) {
|
|
2552
|
+
let name = await emitFavicon(compilation, favicon);
|
|
2553
|
+
if (null === name) return;
|
|
2554
|
+
href = ensureAssetPrefix(name, publicPath);
|
|
2555
|
+
}
|
|
2527
2556
|
let tag = {
|
|
2528
2557
|
tagName: 'link',
|
|
2529
2558
|
voidTag: !0,
|
|
@@ -2576,7 +2605,7 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
2576
2605
|
templatePath: void 0,
|
|
2577
2606
|
templateContent: getDefaultTemplateContent(config.html.mountId)
|
|
2578
2607
|
};
|
|
2579
|
-
let absolutePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(templatePath) ? templatePath : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.
|
|
2608
|
+
let absolutePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(templatePath) ? templatePath : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(rootPath, templatePath);
|
|
2580
2609
|
if (!existTemplatePath.has(absolutePath)) {
|
|
2581
2610
|
if (!await isFileExists(absolutePath)) throw Error(`[rsbuild:html] Failed to resolve HTML template, please check if the file exists: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(absolutePath)}`);
|
|
2582
2611
|
existTemplatePath.add(absolutePath);
|
|
@@ -3166,7 +3195,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
3166
3195
|
host,
|
|
3167
3196
|
port: originalPort,
|
|
3168
3197
|
strictPort: config.server.strictPort || !1
|
|
3169
|
-
}), https = !!config.server.https, portTip = port !== originalPort ? `
|
|
3198
|
+
}), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`using port ${port}.`)}` : void 0;
|
|
3170
3199
|
return {
|
|
3171
3200
|
port,
|
|
3172
3201
|
host,
|
|
@@ -3267,9 +3296,9 @@ async function openBrowser(url) {
|
|
|
3267
3296
|
if (targetBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${targetBrowser}"`, {
|
|
3268
3297
|
cwd: STATIC_PATH
|
|
3269
3298
|
}), !0;
|
|
3270
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('
|
|
3299
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('failed to find the target browser.');
|
|
3271
3300
|
} catch (err) {
|
|
3272
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug("
|
|
3301
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug("failed to open start URL with apple script."), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(err);
|
|
3273
3302
|
}
|
|
3274
3303
|
try {
|
|
3275
3304
|
let { default: open } = await import("../compiled/open/index.js");
|
|
@@ -3554,7 +3583,7 @@ class HtmlPreloadOrPrefetchPlugin {
|
|
|
3554
3583
|
}({
|
|
3555
3584
|
href,
|
|
3556
3585
|
file
|
|
3557
|
-
}), 'font' === attributes.as && (attributes.crossorigin = ''), ("script" === attributes.as || 'style' === attributes.as) && crossOriginLoading &&
|
|
3586
|
+
}), 'font' === attributes.as && (attributes.crossorigin = ''), ("script" === attributes.as || 'style' === attributes.as) && crossOriginLoading && ('use-credentials' === crossOriginLoading || '/' !== publicPath) && (attributes.crossorigin = 'anonymous' === crossOriginLoading ? '' : crossOriginLoading)), links.push({
|
|
3558
3587
|
tagName: 'link',
|
|
3559
3588
|
attributes,
|
|
3560
3589
|
voidTag: !0,
|
|
@@ -3698,7 +3727,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
|
|
|
3698
3727
|
}), api.onExit(()=>{
|
|
3699
3728
|
enableProfileTrace && __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.globalTrace.cleanup();
|
|
3700
3729
|
let profileDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(api.context.distPath, profileDirName);
|
|
3701
|
-
stopProfiler(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(profileDir, 'jscpuprofile.json'), profileSession), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`
|
|
3730
|
+
stopProfiler(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(profileDir, 'jscpuprofile.json'), profileSession), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`saved Rspack profile file to ${profileDir}`);
|
|
3702
3731
|
});
|
|
3703
3732
|
}
|
|
3704
3733
|
}), pluginServer = ()=>({
|
|
@@ -4517,24 +4546,26 @@ class SocketServer {
|
|
|
4517
4546
|
this.wsServer.emit('connection', connection, req);
|
|
4518
4547
|
});
|
|
4519
4548
|
}
|
|
4549
|
+
clearHeartbeatTimer() {
|
|
4550
|
+
this.heartbeatTimer && (clearInterval(this.heartbeatTimer), this.heartbeatTimer = null);
|
|
4551
|
+
}
|
|
4520
4552
|
async prepare() {
|
|
4521
4553
|
var _this_options_client;
|
|
4554
|
+
this.clearHeartbeatTimer();
|
|
4522
4555
|
let { default: ws } = await import("../compiled/ws/index.js");
|
|
4523
4556
|
this.wsServer = new ws.Server({
|
|
4524
4557
|
noServer: !0,
|
|
4525
4558
|
path: null === (_this_options_client = this.options.client) || void 0 === _this_options_client ? void 0 : _this_options_client.path
|
|
4526
4559
|
}), this.wsServer.on('error', (err)=>{
|
|
4527
4560
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
4528
|
-
}), this.
|
|
4529
|
-
for (let socket of this.wsServer.clients)socket.isAlive ? (socket.isAlive = !1, socket.ping(()=>{})) : socket.terminate();
|
|
4530
|
-
}, 30000), this.wsServer.on('connection', (socket, req)=>{
|
|
4561
|
+
}), this.heartbeatTimer = setTimeout(this.checkSockets, 30000), this.wsServer.on('connection', (socket, req)=>{
|
|
4531
4562
|
let queryStr = req.url ? req.url.split('?')[1] : '';
|
|
4532
4563
|
this.onConnect(socket, queryStr ? (0, __WEBPACK_EXTERNAL_MODULE_node_querystring_aeb3c0b4__.parse)(queryStr) : {});
|
|
4533
4564
|
});
|
|
4534
4565
|
}
|
|
4535
4566
|
updateStats(stats) {
|
|
4536
4567
|
let compilationId = getCompilationId(stats.compilation);
|
|
4537
|
-
this.stats[compilationId] = stats, this.sendStats({
|
|
4568
|
+
this.stats[compilationId] = stats, this.sockets.length && this.sendStats({
|
|
4538
4569
|
compilationId
|
|
4539
4570
|
});
|
|
4540
4571
|
}
|
|
@@ -4552,23 +4583,28 @@ class SocketServer {
|
|
|
4552
4583
|
compilationId
|
|
4553
4584
|
}));
|
|
4554
4585
|
}
|
|
4555
|
-
close() {
|
|
4586
|
+
async close() {
|
|
4587
|
+
for (let socket of (this.clearHeartbeatTimer(), this.wsServer.removeAllListeners(), this.wsServer.clients))socket.terminate();
|
|
4556
4588
|
for (let socket of this.sockets)socket.close();
|
|
4557
|
-
this.
|
|
4589
|
+
return this.stats = {}, this.initialChunks = {}, this.sockets.length = 0, new Promise((resolve, reject)=>{
|
|
4590
|
+
this.wsServer.close((err)=>{
|
|
4591
|
+
err ? reject(err) : resolve();
|
|
4592
|
+
});
|
|
4593
|
+
});
|
|
4558
4594
|
}
|
|
4559
4595
|
onConnect(socket, params) {
|
|
4560
4596
|
socket.isAlive = !0, socket.on('pong', ()=>{
|
|
4561
4597
|
socket.isAlive = !0;
|
|
4562
|
-
}),
|
|
4563
|
-
let
|
|
4564
|
-
|
|
4598
|
+
}), this.sockets.push(socket), socket.on('close', ()=>{
|
|
4599
|
+
let index = this.sockets.indexOf(socket);
|
|
4600
|
+
index >= 0 && this.sockets.splice(index, 1);
|
|
4565
4601
|
}), (this.options.hmr || this.options.liveReload) && this.singleWrite(socket, {
|
|
4566
4602
|
type: 'hot',
|
|
4567
4603
|
compilationId: params.compilationId
|
|
4568
4604
|
}), this.stats && this.sendStats({
|
|
4569
4605
|
force: !0,
|
|
4570
4606
|
compilationId: params.compilationId
|
|
4571
|
-
})
|
|
4607
|
+
});
|
|
4572
4608
|
}
|
|
4573
4609
|
getStats(name) {
|
|
4574
4610
|
let curStats = this.stats[name];
|
|
@@ -4773,7 +4809,10 @@ class SocketServer {
|
|
|
4773
4809
|
1 === connection.readyState && connection.send(message);
|
|
4774
4810
|
}
|
|
4775
4811
|
constructor(options){
|
|
4776
|
-
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, "
|
|
4812
|
+
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, "heartbeatTimer", null), socketServer_define_property(this, "checkSockets", ()=>{
|
|
4813
|
+
for (let socket of this.wsServer.clients)socket.isAlive ? (socket.isAlive = !1, socket.ping(()=>{})) : socket.terminate();
|
|
4814
|
+
null !== this.heartbeatTimer && (this.heartbeatTimer = setTimeout(this.checkSockets, 30000));
|
|
4815
|
+
}), this.options = options, this.stats = {}, this.initialChunks = {};
|
|
4777
4816
|
}
|
|
4778
4817
|
}
|
|
4779
4818
|
function compilerDevMiddleware_define_property(obj, key, value) {
|
|
@@ -4806,7 +4845,7 @@ class CompilerDevMiddleware {
|
|
|
4806
4845
|
this.socketServer.upgrade(req, sock, head);
|
|
4807
4846
|
}
|
|
4808
4847
|
async close() {
|
|
4809
|
-
this.socketServer.close(), this.middleware && await new Promise((resolve)=>{
|
|
4848
|
+
await this.socketServer.close(), this.middleware && await new Promise((resolve)=>{
|
|
4810
4849
|
this.middleware.close(()=>{
|
|
4811
4850
|
resolve();
|
|
4812
4851
|
});
|
|
@@ -5432,7 +5471,10 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5432
5471
|
getPublicPathFromCompiler(compiler)
|
|
5433
5472
|
], compilerDevMiddleware = new CompilerDevMiddleware({
|
|
5434
5473
|
dev: devConfig,
|
|
5435
|
-
server:
|
|
5474
|
+
server: {
|
|
5475
|
+
...config.server,
|
|
5476
|
+
port
|
|
5477
|
+
},
|
|
5436
5478
|
publicPaths: publicPaths,
|
|
5437
5479
|
compiler,
|
|
5438
5480
|
environments: options.context.environments
|
|
@@ -5496,7 +5538,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5496
5538
|
environment
|
|
5497
5539
|
}))
|
|
5498
5540
|
}
|
|
5499
|
-
])), { default: connect } = await import("../compiled/connect/index.js"), middlewares = connect(), httpServer = await createHttpServer({
|
|
5541
|
+
])), { default: connect } = await import("../compiled/connect/index.js"), middlewares = connect(), httpServer = config.server.middlewareMode ? null : await createHttpServer({
|
|
5500
5542
|
serverConfig: config.server,
|
|
5501
5543
|
middlewares
|
|
5502
5544
|
}), devServerAPI = {
|
|
@@ -5505,6 +5547,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5505
5547
|
environments: environmentAPI,
|
|
5506
5548
|
httpServer,
|
|
5507
5549
|
listen: async ()=>{
|
|
5550
|
+
if (!httpServer) throw Error('[rsbuild:server] Can not listen dev server as `server.middlewareMode` is enabled.');
|
|
5508
5551
|
let serverTerminator = getServerTerminator(httpServer);
|
|
5509
5552
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server'), options.context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
5510
5553
|
httpServer.listen({
|
|
@@ -5560,6 +5603,12 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
|
|
|
5560
5603
|
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5561
5604
|
return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create dev server done'), devServerAPI;
|
|
5562
5605
|
}
|
|
5606
|
+
function cutPath(filePath, root) {
|
|
5607
|
+
let prefix = root.endsWith(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep) ? root : root + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep;
|
|
5608
|
+
if (filePath.startsWith(prefix)) return filePath.slice(prefix.length);
|
|
5609
|
+
let parts = filePath.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep).filter(Boolean);
|
|
5610
|
+
return parts.length > 3 ? parts.slice(-3).join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep) : parts.join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep);
|
|
5611
|
+
}
|
|
5563
5612
|
async function createCompiler_createCompiler(options) {
|
|
5564
5613
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('create compiler');
|
|
5565
5614
|
let { context } = options, { rspackConfigs } = await initConfigs(options);
|
|
@@ -5568,10 +5617,20 @@ async function createCompiler_createCompiler(options) {
|
|
|
5568
5617
|
environments: context.environments
|
|
5569
5618
|
}), !await isSatisfyRspackVersion(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(rspackMinVersion)}`);
|
|
5570
5619
|
let compiler = 1 === rspackConfigs.length ? (0, __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack)(rspackConfigs[0]) : (0, __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack)(rspackConfigs), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
5571
|
-
isVersionLogged || (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`
|
|
5620
|
+
isVersionLogged || (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`use Rspack v${__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.rspackVersion}`), isVersionLogged = !0);
|
|
5572
5621
|
};
|
|
5573
|
-
compiler.hooks.watchRun.tap('rsbuild:compiling', ()=>{
|
|
5574
|
-
logRspackVersion(), isCompiling
|
|
5622
|
+
compiler.hooks.watchRun.tap('rsbuild:compiling', (compiler)=>{
|
|
5623
|
+
if (logRspackVersion(), !isCompiling) {
|
|
5624
|
+
let changedFiles = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : [], removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : [];
|
|
5625
|
+
if (changedFiles.length) {
|
|
5626
|
+
let fileInfo = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(changedFiles.map((file)=>cutPath(file, context.rootPath)).join(', '));
|
|
5627
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.start(`building ${fileInfo}`);
|
|
5628
|
+
} else if (removedFiles.length) {
|
|
5629
|
+
let fileInfo = removedFiles.map((file)=>cutPath(file, context.rootPath)).join(', ');
|
|
5630
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.start(`building ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(`removed ${fileInfo}`)}`);
|
|
5631
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.start('build started...');
|
|
5632
|
+
}
|
|
5633
|
+
isCompiling = !0;
|
|
5575
5634
|
}), 'build' === context.command && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
|
|
5576
5635
|
let done = (stats)=>{
|
|
5577
5636
|
let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
|
|
@@ -5583,7 +5642,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
5583
5642
|
}), printTime = (c, index)=>{
|
|
5584
5643
|
if (c.time) {
|
|
5585
5644
|
let time = prettyTime(c.time / 1000), { name } = rspackConfigs[index], suffix = name ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.gray(` (${name})`) : '';
|
|
5586
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.ready(`
|
|
5645
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.ready(`built in ${time}${suffix}`);
|
|
5587
5646
|
}
|
|
5588
5647
|
}, hasErrors = stats.hasErrors();
|
|
5589
5648
|
if (!hasErrors) {
|
|
@@ -6036,35 +6095,29 @@ async function createRsbuild(options = {}) {
|
|
|
6036
6095
|
let pluginName = 'RsbuildCorePlugin';
|
|
6037
6096
|
chain.plugin(pluginName).use(class {
|
|
6038
6097
|
apply(compiler) {
|
|
6039
|
-
for (let { handler, environment: pluginEnvironment } of (compiler.__rsbuildTransformer = transformer, resolveFns)){
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
}));
|
|
6048
|
-
});
|
|
6049
|
-
}
|
|
6098
|
+
for (let { handler, environment: pluginEnvironment } of (compiler.__rsbuildTransformer = transformer, resolveFns))(!pluginEnvironment || isPluginMatchEnvironment(pluginEnvironment, environment.name)) && compiler.hooks.compilation.tap(pluginName, (compilation, { normalModuleFactory })=>{
|
|
6099
|
+
normalModuleFactory.hooks.resolve.tapPromise(pluginName, async (resolveData)=>handler({
|
|
6100
|
+
compiler,
|
|
6101
|
+
compilation,
|
|
6102
|
+
environment,
|
|
6103
|
+
resolveData
|
|
6104
|
+
}));
|
|
6105
|
+
});
|
|
6050
6106
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation)=>{
|
|
6051
6107
|
compilation.hooks.childCompiler.tap(pluginName, (childCompiler)=>{
|
|
6052
6108
|
childCompiler.__rsbuildTransformer = transformer;
|
|
6053
6109
|
});
|
|
6054
6110
|
let { sources } = compiler.webpack;
|
|
6055
|
-
for (let { descriptor, handler, environment: pluginEnvironment } of processAssetsFns){
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
sources
|
|
6066
|
-
}));
|
|
6067
|
-
}
|
|
6111
|
+
for (let { descriptor, handler, environment: pluginEnvironment } of processAssetsFns)(!descriptor.targets || descriptor.targets.includes(target)) && (!descriptor.environments || descriptor.environments.includes(environment.name)) && (!pluginEnvironment || isPluginMatchEnvironment(pluginEnvironment, environment.name)) && compilation.hooks.processAssets.tapPromise({
|
|
6112
|
+
name: pluginName,
|
|
6113
|
+
stage: mapProcessAssetsStage(compiler, descriptor.stage)
|
|
6114
|
+
}, async (assets)=>handler({
|
|
6115
|
+
assets,
|
|
6116
|
+
compiler,
|
|
6117
|
+
compilation,
|
|
6118
|
+
environment,
|
|
6119
|
+
sources
|
|
6120
|
+
}));
|
|
6068
6121
|
});
|
|
6069
6122
|
}
|
|
6070
6123
|
constructor(){
|
|
@@ -6578,12 +6631,12 @@ async function runCLI() {
|
|
|
6578
6631
|
}
|
|
6579
6632
|
}(), process.title = 'rsbuild-node';
|
|
6580
6633
|
let { npm_execpath } = process.env;
|
|
6581
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.2.
|
|
6634
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.2.13\n`);
|
|
6582
6635
|
}();
|
|
6583
6636
|
try {
|
|
6584
6637
|
!function() {
|
|
6585
6638
|
let cli = dist('rsbuild');
|
|
6586
|
-
cli.help(), cli.version("1.2.
|
|
6639
|
+
cli.help(), cli.version("1.2.13"), applyCommonOptions(cli);
|
|
6587
6640
|
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');
|
|
6588
6641
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6589
6642
|
try {
|
|
@@ -6634,6 +6687,6 @@ async function runCLI() {
|
|
|
6634
6687
|
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
6635
6688
|
}
|
|
6636
6689
|
}
|
|
6637
|
-
let src_version = "1.2.
|
|
6690
|
+
let src_version = "1.2.13";
|
|
6638
6691
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
|
|
6639
6692
|
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|
|
@@ -27,9 +27,9 @@ export declare const urlJoin: (base: string, path: string) => string;
|
|
|
27
27
|
export declare const canParse: (url: string) => boolean;
|
|
28
28
|
export declare const parseUrl: (url: string) => URL | null;
|
|
29
29
|
export declare const ensureAssetPrefix: (url: string, assetPrefix?: Rspack.PublicPath) => string;
|
|
30
|
-
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'js', isProd: boolean, isServer?: boolean):
|
|
31
|
-
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'css', isProd: boolean):
|
|
32
|
-
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: Exclude<keyof FilenameConfig, 'js' | 'css'>, isProd: boolean, isServer?: boolean):
|
|
30
|
+
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'js', isProd: boolean, isServer?: boolean): Rspack.Filename;
|
|
31
|
+
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'css', isProd: boolean): Rspack.CssFilename;
|
|
32
|
+
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: Exclude<keyof FilenameConfig, 'js' | 'css'>, isProd: boolean, isServer?: boolean): Rspack.AssetModuleFilename;
|
|
33
33
|
export declare function partition<T>(array: T[], predicate: (value: T) => boolean): [T[], T[]];
|
|
34
34
|
export declare const applyToCompiler: (compiler: Rspack.Compiler | Rspack.MultiCompiler, apply: (c: Rspack.Compiler, index: number) => void) => void;
|
|
35
35
|
export declare const upperFirst: (str: string) => string;
|
|
@@ -45,3 +45,4 @@ export declare const prettyTime: (seconds: number) => string;
|
|
|
45
45
|
* Check if running in a TTY context
|
|
46
46
|
*/
|
|
47
47
|
export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
|
|
48
|
+
export declare const addCompilationError: (compilation: Rspack.Compilation, message: string) => void;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { rspack } from '@rspack/core';
|
|
|
6
6
|
import type * as Rspack from '@rspack/core';
|
|
7
7
|
export { loadEnv } from './loadEnv';
|
|
8
8
|
export { createRsbuild } from './createRsbuild';
|
|
9
|
-
export { loadConfig, defineConfig, type LoadConfigOptions, type LoadConfigResult, } from './config';
|
|
9
|
+
export { loadConfig, defineConfig, type ConfigParams, type LoadConfigOptions, type LoadConfigResult, } from './config';
|
|
10
10
|
export { runCLI } from './cli';
|
|
11
11
|
export declare const version: string;
|
|
12
12
|
export { rspack };
|
package/dist-types/loadEnv.d.ts
CHANGED
|
@@ -14,11 +14,21 @@ export type LoadEnvOptions = {
|
|
|
14
14
|
* @default ['PUBLIC_']
|
|
15
15
|
*/
|
|
16
16
|
prefixes?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Specify a target object to store environment variables.
|
|
19
|
+
* If not provided, variables will be written to `process.env`.
|
|
20
|
+
* @default process.env
|
|
21
|
+
*/
|
|
22
|
+
processEnv?: Record<string, string>;
|
|
17
23
|
};
|
|
18
|
-
export declare function loadEnv({ cwd, mode, prefixes, }?: LoadEnvOptions): {
|
|
19
|
-
/**
|
|
24
|
+
export declare function loadEnv({ cwd, mode, prefixes, processEnv, }?: LoadEnvOptions): {
|
|
25
|
+
/**
|
|
26
|
+
* All env variables in the .env file
|
|
27
|
+
*/
|
|
20
28
|
parsed: Record<string, string>;
|
|
21
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The absolute paths to all env files
|
|
31
|
+
*/
|
|
22
32
|
filePaths: string[];
|
|
23
33
|
/**
|
|
24
34
|
* Env variables that start with prefixes.
|
|
@@ -45,6 +55,8 @@ export declare function loadEnv({ cwd, mode, prefixes, }?: LoadEnvOptions): {
|
|
|
45
55
|
* ```
|
|
46
56
|
**/
|
|
47
57
|
publicVars: Record<string, string>;
|
|
48
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Clear the env variables mounted on `process.env`
|
|
60
|
+
*/
|
|
49
61
|
cleanup: () => void;
|
|
50
62
|
};
|
package/dist-types/logger.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging message case convention:
|
|
3
|
+
*
|
|
4
|
+
* Info, ready, success and debug messages:
|
|
5
|
+
* - Start with lowercase
|
|
6
|
+
* - Example: "info build started..."
|
|
7
|
+
*
|
|
8
|
+
* Errors and warnings:
|
|
9
|
+
* - Start with uppercase
|
|
10
|
+
* - Example: "error Failed to build"
|
|
11
|
+
*
|
|
12
|
+
* This convention helps distinguish between normal operations
|
|
13
|
+
* and important alerts that require attention.
|
|
14
|
+
*/
|
|
1
15
|
import { type Logger, logger } from '../compiled/rslog/index.js';
|
|
2
16
|
export declare const isDebug: () => boolean;
|
|
3
17
|
export { logger };
|