@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.cjs
CHANGED
|
@@ -268,10 +268,6 @@ var __webpack_modules__ = {
|
|
|
268
268
|
"use strict";
|
|
269
269
|
module.exports = import("../compiled/http-proxy-middleware/index.js");
|
|
270
270
|
},
|
|
271
|
-
"../compiled/jiti/index.js": function(module) {
|
|
272
|
-
"use strict";
|
|
273
|
-
module.exports = import("../compiled/jiti/index.js");
|
|
274
|
-
},
|
|
275
271
|
"../../compiled/launch-editor-middleware/index.js": function(module) {
|
|
276
272
|
"use strict";
|
|
277
273
|
module.exports = import("../compiled/launch-editor-middleware/index.js");
|
|
@@ -316,6 +312,10 @@ var __webpack_modules__ = {
|
|
|
316
312
|
"use strict";
|
|
317
313
|
module.exports = import("../compiled/ws/index.js");
|
|
318
314
|
},
|
|
315
|
+
jiti: function(module) {
|
|
316
|
+
"use strict";
|
|
317
|
+
module.exports = import("jiti");
|
|
318
|
+
},
|
|
319
319
|
"node:http": function(module) {
|
|
320
320
|
"use strict";
|
|
321
321
|
module.exports = import("node:http");
|
|
@@ -521,11 +521,11 @@ var __webpack_exports__ = {};
|
|
|
521
521
|
withFileTypes: !0
|
|
522
522
|
});
|
|
523
523
|
await Promise.all(entries.map(async (entry)=>{
|
|
524
|
-
let fullPath = external_node_path_default().
|
|
524
|
+
let fullPath = external_node_path_default().join(dir, entry.name);
|
|
525
525
|
!keep.some((reg)=>reg.test(toPosixPath(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));
|
|
526
526
|
}));
|
|
527
527
|
} catch (err) {
|
|
528
|
-
rslog_index_js_namespaceObject.logger.debug(`
|
|
528
|
+
rslog_index_js_namespaceObject.logger.debug(`failed to empty dir: ${dir}`), rslog_index_js_namespaceObject.logger.debug(err);
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
531
|
let hintNodePolyfill = (message)=>{
|
|
@@ -772,10 +772,12 @@ var __webpack_exports__ = {};
|
|
|
772
772
|
if (seconds < 60) return `${format(seconds.toFixed(1))} s`;
|
|
773
773
|
let minutes = seconds / 60;
|
|
774
774
|
return `${format(minutes.toFixed(2))} m`;
|
|
775
|
-
}, isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI
|
|
775
|
+
}, isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI, addCompilationError = (compilation, message)=>{
|
|
776
|
+
compilation.errors.push(new compilation.compiler.webpack.WebpackError(message));
|
|
777
|
+
};
|
|
776
778
|
function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
777
779
|
'PUBLIC_'
|
|
778
|
-
] } = {}) {
|
|
780
|
+
], processEnv = process.env } = {}) {
|
|
779
781
|
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.");
|
|
780
782
|
let filePaths = [
|
|
781
783
|
'.env',
|
|
@@ -783,13 +785,14 @@ var __webpack_exports__ = {};
|
|
|
783
785
|
`.env.${mode}`,
|
|
784
786
|
`.env.${mode}.local`
|
|
785
787
|
].map((filename)=>(0, external_node_path_namespaceObject.join)(cwd, filename)).filter(isFileSync), parsed = {};
|
|
786
|
-
for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(external_node_fs_default().readFileSync(envPath)));
|
|
787
|
-
parsed.NODE_ENV && (
|
|
788
|
-
parsed
|
|
788
|
+
for (let envPath of filePaths)Object.assign(parsed, (0, main.parse)(external_node_fs_default().readFileSync(envPath))), rslog_index_js_namespaceObject.logger.debug('loaded env file:', envPath);
|
|
789
|
+
parsed.NODE_ENV && (processEnv.NODE_ENV = parsed.NODE_ENV), (0, lib_main.expand)({
|
|
790
|
+
parsed,
|
|
791
|
+
processEnv
|
|
789
792
|
});
|
|
790
793
|
let publicVars = {}, rawPublicVars = {};
|
|
791
|
-
for (let key of Object.keys(
|
|
792
|
-
let val =
|
|
794
|
+
for (let key of Object.keys(processEnv))if (prefixes.some((prefix)=>key.startsWith(prefix))) {
|
|
795
|
+
let val = processEnv[key];
|
|
793
796
|
publicVars[`import.meta.env.${key}`] = JSON.stringify(val), publicVars[`process.env.${key}`] = JSON.stringify(val), rawPublicVars[key] = val;
|
|
794
797
|
}
|
|
795
798
|
let cleaned = !1;
|
|
@@ -797,7 +800,7 @@ var __webpack_exports__ = {};
|
|
|
797
800
|
parsed,
|
|
798
801
|
cleanup: ()=>{
|
|
799
802
|
if (!cleaned) {
|
|
800
|
-
for (let key of Object.keys(parsed))'NODE_ENV' !== key &&
|
|
803
|
+
for (let key of Object.keys(parsed))'NODE_ENV' !== key && processEnv[key] === parsed[key] && delete processEnv[key];
|
|
801
804
|
cleaned = !0;
|
|
802
805
|
}
|
|
803
806
|
},
|
|
@@ -915,7 +918,7 @@ var __webpack_exports__ = {};
|
|
|
915
918
|
merged[key] = mergeConfig_merge(x[key], y[key], childPath);
|
|
916
919
|
}
|
|
917
920
|
return merged;
|
|
918
|
-
}, 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 ? external_node_path_default().isAbsolute(envDir) ? envDir : external_node_path_default().
|
|
921
|
+
}, 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 ? external_node_path_default().isAbsolute(envDir) ? envDir : external_node_path_default().join(cwd, envDir) : cwd;
|
|
919
922
|
async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
|
|
920
923
|
cliOptions && (commonOpts = cliOptions);
|
|
921
924
|
try {
|
|
@@ -972,8 +975,8 @@ var __webpack_exports__ = {};
|
|
|
972
975
|
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
973
976
|
if (clear && clearConsole(), filePath) {
|
|
974
977
|
let filename = external_node_path_default().basename(filePath);
|
|
975
|
-
rslog_index_js_namespaceObject.logger.info(`
|
|
976
|
-
} else rslog_index_js_namespaceObject.logger.info(`
|
|
978
|
+
rslog_index_js_namespaceObject.logger.info(`restarting ${id} because ${index_js_default().yellow(filename)} has changed\n`);
|
|
979
|
+
} else rslog_index_js_namespaceObject.logger.info(`restarting ${id}...\n`);
|
|
977
980
|
for (let cleaner of cleaners)await cleaner();
|
|
978
981
|
cleaners = [];
|
|
979
982
|
}, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
|
|
@@ -1080,7 +1083,8 @@ var __webpack_exports__ = {};
|
|
|
1080
1083
|
compress: !0,
|
|
1081
1084
|
printUrls: !0,
|
|
1082
1085
|
strictPort: !1,
|
|
1083
|
-
cors: !1
|
|
1086
|
+
cors: !1,
|
|
1087
|
+
middlewareMode: !1
|
|
1084
1088
|
}), getDefaultSourceConfig = ()=>({
|
|
1085
1089
|
alias: {},
|
|
1086
1090
|
define: {},
|
|
@@ -1250,7 +1254,7 @@ var __webpack_exports__ = {};
|
|
|
1250
1254
|
async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
|
|
1251
1255
|
let configExport;
|
|
1252
1256
|
let configFilePath = resolveConfigPath(cwd, path);
|
|
1253
|
-
if (!configFilePath) return {
|
|
1257
|
+
if (!configFilePath) return rslog_index_js_namespaceObject.logger.debug('no config file found.'), {
|
|
1254
1258
|
content: {},
|
|
1255
1259
|
filePath: configFilePath
|
|
1256
1260
|
};
|
|
@@ -1262,16 +1266,17 @@ var __webpack_exports__ = {};
|
|
|
1262
1266
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
1263
1267
|
} catch (err) {
|
|
1264
1268
|
if ('native' === loader) throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with native loader: ${index_js_default().dim(configFilePath)}`), err;
|
|
1265
|
-
rslog_index_js_namespaceObject.logger.debug(`
|
|
1269
|
+
rslog_index_js_namespaceObject.logger.debug(`failed to load file with dynamic import: ${index_js_default().dim(configFilePath)}`);
|
|
1266
1270
|
}
|
|
1267
1271
|
try {
|
|
1268
1272
|
if (void 0 === configExport) {
|
|
1269
|
-
let {
|
|
1270
|
-
|
|
1271
|
-
esmResolve: !0,
|
|
1272
|
-
requireCache: !1,
|
|
1273
|
+
let { createJiti } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "jiti")), jiti = createJiti(constants_filename, {
|
|
1274
|
+
moduleCache: !1,
|
|
1273
1275
|
interopDefault: !0
|
|
1274
|
-
})
|
|
1276
|
+
});
|
|
1277
|
+
configExport = await jiti.import(configFilePath, {
|
|
1278
|
+
default: !0
|
|
1279
|
+
});
|
|
1275
1280
|
}
|
|
1276
1281
|
} catch (err) {
|
|
1277
1282
|
throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with jiti: ${index_js_default().dim(configFilePath)}`), err;
|
|
@@ -1290,7 +1295,7 @@ var __webpack_exports__ = {};
|
|
|
1290
1295
|
};
|
|
1291
1296
|
}
|
|
1292
1297
|
if (!isObject(configExport)) throw Error(`[rsbuild:loadConfig] The config must be an object or a function that returns an object, get ${index_js_default().yellow(configExport)}`);
|
|
1293
|
-
return {
|
|
1298
|
+
return rslog_index_js_namespaceObject.logger.debug('loaded config file:', configFilePath), {
|
|
1294
1299
|
content: applyMetaInfo(configExport),
|
|
1295
1300
|
filePath: configFilePath
|
|
1296
1301
|
};
|
|
@@ -1330,13 +1335,13 @@ var __webpack_exports__ = {};
|
|
|
1330
1335
|
...rawEnvironmentConfigs.map(({ name, content })=>{
|
|
1331
1336
|
if (1 === rawEnvironmentConfigs.length) return {
|
|
1332
1337
|
path: (0, external_node_path_namespaceObject.join)(outputPath, 'rsbuild.config.mjs'),
|
|
1333
|
-
label: 'Rsbuild
|
|
1338
|
+
label: 'Rsbuild config',
|
|
1334
1339
|
content
|
|
1335
1340
|
};
|
|
1336
1341
|
let outputFile = `rsbuild.config.${name}.mjs`;
|
|
1337
1342
|
return {
|
|
1338
1343
|
path: (0, external_node_path_namespaceObject.join)(outputPath, outputFile),
|
|
1339
|
-
label: `Rsbuild
|
|
1344
|
+
label: `Rsbuild config (${name})`,
|
|
1340
1345
|
content
|
|
1341
1346
|
};
|
|
1342
1347
|
}),
|
|
@@ -1353,7 +1358,7 @@ var __webpack_exports__ = {};
|
|
|
1353
1358
|
recursive: !0
|
|
1354
1359
|
}), await Promise.all(files.map(async (item)=>external_node_fs_default().promises.writeFile(item.path, `export default ${item.content}`)));
|
|
1355
1360
|
let fileInfos = files.map((item)=>` - ${index_js_default().bold(index_js_default().yellow(item.label))}: ${index_js_default().underline(item.path)}`).join('\n');
|
|
1356
|
-
rslog_index_js_namespaceObject.logger.success(`
|
|
1361
|
+
rslog_index_js_namespaceObject.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
1357
1362
|
}
|
|
1358
1363
|
function stringifyConfig(config, verbose) {
|
|
1359
1364
|
return (0, rspack_chain_index_js_default().toString)(config, {
|
|
@@ -1739,7 +1744,7 @@ var __webpack_exports__ = {};
|
|
|
1739
1744
|
async function createContext(options, userConfig, bundlerType) {
|
|
1740
1745
|
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;
|
|
1741
1746
|
return {
|
|
1742
|
-
version: "1.2.
|
|
1747
|
+
version: "1.2.13",
|
|
1743
1748
|
rootPath,
|
|
1744
1749
|
distPath: '',
|
|
1745
1750
|
cachePath,
|
|
@@ -1818,12 +1823,24 @@ var __webpack_exports__ = {};
|
|
|
1818
1823
|
if (!appIcon) return;
|
|
1819
1824
|
let distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>formatIcon(icon, distDir, publicPath)), tags = [];
|
|
1820
1825
|
for (let icon of icons){
|
|
1821
|
-
if ('web-app-manifest' === icon.target && !appIcon.name)
|
|
1826
|
+
if ('web-app-manifest' === icon.target && !appIcon.name) {
|
|
1827
|
+
addCompilationError(compilation, '[rsbuild:app-icon] "appIcon.name" is required when "target" is "web-app-manifest".');
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1822
1830
|
if (!icon.isURL) {
|
|
1823
|
-
if (!compilation.inputFileSystem)
|
|
1824
|
-
|
|
1831
|
+
if (!compilation.inputFileSystem) {
|
|
1832
|
+
addCompilationError(compilation, '[rsbuild:app-icon] Failed to read the icon file as "compilation.inputFileSystem" is not available.');
|
|
1833
|
+
continue;
|
|
1834
|
+
}
|
|
1835
|
+
if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
|
|
1836
|
+
addCompilationError(compilation, `[rsbuild:app-icon] Failed to find the icon file at "${index_js_default().cyan(icon.absolutePath)}".`);
|
|
1837
|
+
continue;
|
|
1838
|
+
}
|
|
1825
1839
|
let source = await (0, external_node_util_namespaceObject.promisify)(compilation.inputFileSystem.readFile)(icon.absolutePath);
|
|
1826
|
-
if (!source)
|
|
1840
|
+
if (!source) {
|
|
1841
|
+
addCompilationError(compilation, `[rsbuild:app-icon] Failed to read the icon file at "${index_js_default().cyan(icon.absolutePath)}".`);
|
|
1842
|
+
continue;
|
|
1843
|
+
}
|
|
1827
1844
|
compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
|
|
1828
1845
|
}
|
|
1829
1846
|
('apple-touch-icon' === icon.target || !icon.target && icon.size < 200) && tags.push({
|
|
@@ -1970,7 +1987,10 @@ var __webpack_exports__ = {};
|
|
|
1970
1987
|
api.modifyBundlerChain((chain, { isProd, environment })=>{
|
|
1971
1988
|
let { config } = environment, getMergedFilename = (assetType)=>{
|
|
1972
1989
|
let distDir = config.output.distPath[assetType], filename = getFilename(config, assetType, isProd);
|
|
1973
|
-
return
|
|
1990
|
+
return 'function' == typeof filename ? (...args)=>{
|
|
1991
|
+
let name = filename(...args);
|
|
1992
|
+
return external_node_path_default().posix.join(distDir, name);
|
|
1993
|
+
} : external_node_path_default().posix.join(distDir, filename);
|
|
1974
1994
|
}, createAssetRule = (assetType, exts, emit)=>{
|
|
1975
1995
|
let regExp = function(exts) {
|
|
1976
1996
|
let matcher = exts.map((ext)=>ext.trim()).map((ext)=>ext.startsWith('.') ? ext.slice(1) : ext).join('|');
|
|
@@ -2037,7 +2057,7 @@ var __webpack_exports__ = {};
|
|
|
2037
2057
|
javascript: {
|
|
2038
2058
|
exportsPresence: 'error'
|
|
2039
2059
|
}
|
|
2040
|
-
}), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), 'development' === env && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(
|
|
2060
|
+
}), 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({
|
|
2041
2061
|
...chain.get('experiments'),
|
|
2042
2062
|
incremental: isDev
|
|
2043
2063
|
});
|
|
@@ -2055,7 +2075,7 @@ var __webpack_exports__ = {};
|
|
|
2055
2075
|
try {
|
|
2056
2076
|
prevBuildDependencies = JSON.parse(rawConfigFile);
|
|
2057
2077
|
} catch (e) {
|
|
2058
|
-
rslog_index_js_namespaceObject.logger.debug('
|
|
2078
|
+
rslog_index_js_namespaceObject.logger.debug('failed to parse the previous buildDependencies.json', e);
|
|
2059
2079
|
}
|
|
2060
2080
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) return;
|
|
2061
2081
|
await external_node_fs_default().promises.rm(cacheDirectory, {
|
|
@@ -2608,16 +2628,25 @@ var __webpack_exports__ = {};
|
|
|
2608
2628
|
class RsbuildHtmlPlugin {
|
|
2609
2629
|
apply(compiler) {
|
|
2610
2630
|
let emitFavicon = async (compilation, favicon)=>{
|
|
2631
|
+
let buffer;
|
|
2611
2632
|
let name = external_node_path_default().basename(favicon);
|
|
2612
2633
|
if (compilation.assets[name]) return name;
|
|
2613
|
-
if (!compilation.inputFileSystem)
|
|
2614
|
-
let filename = external_node_path_default().
|
|
2615
|
-
|
|
2616
|
-
|
|
2634
|
+
if (!compilation.inputFileSystem) return addCompilationError(compilation, '[rsbuild:html] Failed to read the favicon file as "compilation.inputFileSystem" is not available.'), null;
|
|
2635
|
+
let filename = external_node_path_default().isAbsolute(favicon) ? favicon : external_node_path_default().join(compilation.compiler.context, favicon);
|
|
2636
|
+
try {
|
|
2637
|
+
if (!(buffer = await (0, external_node_util_namespaceObject.promisify)(compilation.inputFileSystem.readFile)(filename))) throw Error('Buffer is undefined');
|
|
2638
|
+
} catch (error) {
|
|
2639
|
+
return rslog_index_js_namespaceObject.logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `[rsbuild:html] Failed to read the favicon file at "${index_js_default().cyan(filename)}".`), null;
|
|
2640
|
+
}
|
|
2641
|
+
let source = new compiler.webpack.sources.RawSource(buffer, !1);
|
|
2617
2642
|
return compilation.emitAsset(name, source), name;
|
|
2618
2643
|
}, addFavicon = async (headTags, favicon, compilation, publicPath)=>{
|
|
2619
2644
|
let href = favicon;
|
|
2620
|
-
|
|
2645
|
+
if (!isURL(favicon)) {
|
|
2646
|
+
let name = await emitFavicon(compilation, favicon);
|
|
2647
|
+
if (null === name) return;
|
|
2648
|
+
href = ensureAssetPrefix(name, publicPath);
|
|
2649
|
+
}
|
|
2621
2650
|
let tag = {
|
|
2622
2651
|
tagName: 'link',
|
|
2623
2652
|
voidTag: !0,
|
|
@@ -2670,7 +2699,7 @@ var __webpack_exports__ = {};
|
|
|
2670
2699
|
templatePath: void 0,
|
|
2671
2700
|
templateContent: getDefaultTemplateContent(config.html.mountId)
|
|
2672
2701
|
};
|
|
2673
|
-
let absolutePath = (0, external_node_path_namespaceObject.isAbsolute)(templatePath) ? templatePath : external_node_path_default().
|
|
2702
|
+
let absolutePath = (0, external_node_path_namespaceObject.isAbsolute)(templatePath) ? templatePath : external_node_path_default().join(rootPath, templatePath);
|
|
2674
2703
|
if (!existTemplatePath.has(absolutePath)) {
|
|
2675
2704
|
if (!await isFileExists(absolutePath)) throw Error(`[rsbuild:html] Failed to resolve HTML template, please check if the file exists: ${index_js_default().cyan(absolutePath)}`);
|
|
2676
2705
|
existTemplatePath.add(absolutePath);
|
|
@@ -3265,7 +3294,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3265
3294
|
host,
|
|
3266
3295
|
port: originalPort,
|
|
3267
3296
|
strictPort: config.server.strictPort || !1
|
|
3268
|
-
}), https = !!config.server.https, portTip = port !== originalPort ? `
|
|
3297
|
+
}), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${index_js_default().yellow(`using port ${port}.`)}` : void 0;
|
|
3269
3298
|
return {
|
|
3270
3299
|
port,
|
|
3271
3300
|
host,
|
|
@@ -3366,9 +3395,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3366
3395
|
if (targetBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${targetBrowser}"`, {
|
|
3367
3396
|
cwd: STATIC_PATH
|
|
3368
3397
|
}), !0;
|
|
3369
|
-
rslog_index_js_namespaceObject.logger.debug('
|
|
3398
|
+
rslog_index_js_namespaceObject.logger.debug('failed to find the target browser.');
|
|
3370
3399
|
} catch (err) {
|
|
3371
|
-
rslog_index_js_namespaceObject.logger.debug("
|
|
3400
|
+
rslog_index_js_namespaceObject.logger.debug("failed to open start URL with apple script."), rslog_index_js_namespaceObject.logger.debug(err);
|
|
3372
3401
|
}
|
|
3373
3402
|
try {
|
|
3374
3403
|
let { default: open } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/open/index.js"));
|
|
@@ -3653,7 +3682,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3653
3682
|
}({
|
|
3654
3683
|
href,
|
|
3655
3684
|
file
|
|
3656
|
-
}), 'font' === attributes.as && (attributes.crossorigin = ''), ("script" === attributes.as || 'style' === attributes.as) && crossOriginLoading &&
|
|
3685
|
+
}), 'font' === attributes.as && (attributes.crossorigin = ''), ("script" === attributes.as || 'style' === attributes.as) && crossOriginLoading && ('use-credentials' === crossOriginLoading || '/' !== publicPath) && (attributes.crossorigin = 'anonymous' === crossOriginLoading ? '' : crossOriginLoading)), links.push({
|
|
3657
3686
|
tagName: 'link',
|
|
3658
3687
|
attributes,
|
|
3659
3688
|
voidTag: !0,
|
|
@@ -3799,7 +3828,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
3799
3828
|
}), api.onExit(()=>{
|
|
3800
3829
|
enableProfileTrace && core_default().experiments.globalTrace.cleanup();
|
|
3801
3830
|
let profileDir = external_node_path_default().join(api.context.distPath, profileDirName);
|
|
3802
|
-
stopProfiler(external_node_path_default().join(profileDir, 'jscpuprofile.json'), profileSession), rslog_index_js_namespaceObject.logger.info(`
|
|
3831
|
+
stopProfiler(external_node_path_default().join(profileDir, 'jscpuprofile.json'), profileSession), rslog_index_js_namespaceObject.logger.info(`saved Rspack profile file to ${profileDir}`);
|
|
3803
3832
|
});
|
|
3804
3833
|
}
|
|
3805
3834
|
}), pluginServer = ()=>({
|
|
@@ -4623,24 +4652,26 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4623
4652
|
this.wsServer.emit('connection', connection, req);
|
|
4624
4653
|
});
|
|
4625
4654
|
}
|
|
4655
|
+
clearHeartbeatTimer() {
|
|
4656
|
+
this.heartbeatTimer && (clearInterval(this.heartbeatTimer), this.heartbeatTimer = null);
|
|
4657
|
+
}
|
|
4626
4658
|
async prepare() {
|
|
4627
4659
|
var _this_options_client;
|
|
4660
|
+
this.clearHeartbeatTimer();
|
|
4628
4661
|
let { default: ws } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/ws/index.js"));
|
|
4629
4662
|
this.wsServer = new ws.Server({
|
|
4630
4663
|
noServer: !0,
|
|
4631
4664
|
path: null === (_this_options_client = this.options.client) || void 0 === _this_options_client ? void 0 : _this_options_client.path
|
|
4632
4665
|
}), this.wsServer.on('error', (err)=>{
|
|
4633
4666
|
rslog_index_js_namespaceObject.logger.error(err);
|
|
4634
|
-
}), this.
|
|
4635
|
-
for (let socket of this.wsServer.clients)socket.isAlive ? (socket.isAlive = !1, socket.ping(()=>{})) : socket.terminate();
|
|
4636
|
-
}, 30000), this.wsServer.on('connection', (socket, req)=>{
|
|
4667
|
+
}), this.heartbeatTimer = setTimeout(this.checkSockets, 30000), this.wsServer.on('connection', (socket, req)=>{
|
|
4637
4668
|
let queryStr = req.url ? req.url.split('?')[1] : '';
|
|
4638
4669
|
this.onConnect(socket, queryStr ? (0, external_node_querystring_namespaceObject.parse)(queryStr) : {});
|
|
4639
4670
|
});
|
|
4640
4671
|
}
|
|
4641
4672
|
updateStats(stats) {
|
|
4642
4673
|
let compilationId = getCompilationId(stats.compilation);
|
|
4643
|
-
this.stats[compilationId] = stats, this.sendStats({
|
|
4674
|
+
this.stats[compilationId] = stats, this.sockets.length && this.sendStats({
|
|
4644
4675
|
compilationId
|
|
4645
4676
|
});
|
|
4646
4677
|
}
|
|
@@ -4658,23 +4689,28 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4658
4689
|
compilationId
|
|
4659
4690
|
}));
|
|
4660
4691
|
}
|
|
4661
|
-
close() {
|
|
4692
|
+
async close() {
|
|
4693
|
+
for (let socket of (this.clearHeartbeatTimer(), this.wsServer.removeAllListeners(), this.wsServer.clients))socket.terminate();
|
|
4662
4694
|
for (let socket of this.sockets)socket.close();
|
|
4663
|
-
this.
|
|
4695
|
+
return this.stats = {}, this.initialChunks = {}, this.sockets.length = 0, new Promise((resolve, reject)=>{
|
|
4696
|
+
this.wsServer.close((err)=>{
|
|
4697
|
+
err ? reject(err) : resolve();
|
|
4698
|
+
});
|
|
4699
|
+
});
|
|
4664
4700
|
}
|
|
4665
4701
|
onConnect(socket, params) {
|
|
4666
4702
|
socket.isAlive = !0, socket.on('pong', ()=>{
|
|
4667
4703
|
socket.isAlive = !0;
|
|
4668
|
-
}),
|
|
4669
|
-
let
|
|
4670
|
-
|
|
4704
|
+
}), this.sockets.push(socket), socket.on('close', ()=>{
|
|
4705
|
+
let index = this.sockets.indexOf(socket);
|
|
4706
|
+
index >= 0 && this.sockets.splice(index, 1);
|
|
4671
4707
|
}), (this.options.hmr || this.options.liveReload) && this.singleWrite(socket, {
|
|
4672
4708
|
type: 'hot',
|
|
4673
4709
|
compilationId: params.compilationId
|
|
4674
4710
|
}), this.stats && this.sendStats({
|
|
4675
4711
|
force: !0,
|
|
4676
4712
|
compilationId: params.compilationId
|
|
4677
|
-
})
|
|
4713
|
+
});
|
|
4678
4714
|
}
|
|
4679
4715
|
getStats(name) {
|
|
4680
4716
|
let curStats = this.stats[name];
|
|
@@ -4879,7 +4915,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4879
4915
|
1 === connection.readyState && connection.send(message);
|
|
4880
4916
|
}
|
|
4881
4917
|
constructor(options){
|
|
4882
|
-
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, "
|
|
4918
|
+
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", ()=>{
|
|
4919
|
+
for (let socket of this.wsServer.clients)socket.isAlive ? (socket.isAlive = !1, socket.ping(()=>{})) : socket.terminate();
|
|
4920
|
+
null !== this.heartbeatTimer && (this.heartbeatTimer = setTimeout(this.checkSockets, 30000));
|
|
4921
|
+
}), this.options = options, this.stats = {}, this.initialChunks = {};
|
|
4883
4922
|
}
|
|
4884
4923
|
}
|
|
4885
4924
|
function compilerDevMiddleware_define_property(obj, key, value) {
|
|
@@ -4912,7 +4951,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
4912
4951
|
this.socketServer.upgrade(req, sock, head);
|
|
4913
4952
|
}
|
|
4914
4953
|
async close() {
|
|
4915
|
-
this.socketServer.close(), this.middleware && await new Promise((resolve)=>{
|
|
4954
|
+
await this.socketServer.close(), this.middleware && await new Promise((resolve)=>{
|
|
4916
4955
|
this.middleware.close(()=>{
|
|
4917
4956
|
resolve();
|
|
4918
4957
|
});
|
|
@@ -5543,7 +5582,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5543
5582
|
getPublicPathFromCompiler(compiler)
|
|
5544
5583
|
], compilerDevMiddleware = new CompilerDevMiddleware({
|
|
5545
5584
|
dev: devConfig,
|
|
5546
|
-
server:
|
|
5585
|
+
server: {
|
|
5586
|
+
...config.server,
|
|
5587
|
+
port
|
|
5588
|
+
},
|
|
5547
5589
|
publicPaths: publicPaths,
|
|
5548
5590
|
compiler,
|
|
5549
5591
|
environments: options.context.environments
|
|
@@ -5607,7 +5649,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5607
5649
|
environment
|
|
5608
5650
|
}))
|
|
5609
5651
|
}
|
|
5610
|
-
])), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect(), httpServer = await createHttpServer({
|
|
5652
|
+
])), { default: connect } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/connect/index.js")), middlewares = connect(), httpServer = config.server.middlewareMode ? null : await createHttpServer({
|
|
5611
5653
|
serverConfig: config.server,
|
|
5612
5654
|
middlewares
|
|
5613
5655
|
}), devServerAPI = {
|
|
@@ -5616,6 +5658,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5616
5658
|
environments: environmentAPI,
|
|
5617
5659
|
httpServer,
|
|
5618
5660
|
listen: async ()=>{
|
|
5661
|
+
if (!httpServer) throw Error('[rsbuild:server] Can not listen dev server as `server.middlewareMode` is enabled.');
|
|
5619
5662
|
let serverTerminator = getServerTerminator(httpServer);
|
|
5620
5663
|
return rslog_index_js_namespaceObject.logger.debug('listen dev server'), options.context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
5621
5664
|
httpServer.listen({
|
|
@@ -5671,6 +5714,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5671
5714
|
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
5672
5715
|
return rslog_index_js_namespaceObject.logger.debug('create dev server done'), devServerAPI;
|
|
5673
5716
|
}
|
|
5717
|
+
function cutPath(filePath, root) {
|
|
5718
|
+
let prefix = root.endsWith(external_node_path_namespaceObject.sep) ? root : root + external_node_path_namespaceObject.sep;
|
|
5719
|
+
if (filePath.startsWith(prefix)) return filePath.slice(prefix.length);
|
|
5720
|
+
let parts = filePath.split(external_node_path_namespaceObject.sep).filter(Boolean);
|
|
5721
|
+
return parts.length > 3 ? parts.slice(-3).join(external_node_path_namespaceObject.sep) : parts.join(external_node_path_namespaceObject.sep);
|
|
5722
|
+
}
|
|
5674
5723
|
async function createCompiler_createCompiler(options) {
|
|
5675
5724
|
rslog_index_js_namespaceObject.logger.debug('create compiler');
|
|
5676
5725
|
let { context } = options, { rspackConfigs } = await initConfigs(options);
|
|
@@ -5679,10 +5728,20 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5679
5728
|
environments: context.environments
|
|
5680
5729
|
}), !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)}`);
|
|
5681
5730
|
let compiler = 1 === rspackConfigs.length ? (0, core_namespaceObject.rspack)(rspackConfigs[0]) : (0, core_namespaceObject.rspack)(rspackConfigs), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
5682
|
-
isVersionLogged || (rslog_index_js_namespaceObject.logger.debug(`
|
|
5731
|
+
isVersionLogged || (rslog_index_js_namespaceObject.logger.debug(`use Rspack v${core_namespaceObject.rspack.rspackVersion}`), isVersionLogged = !0);
|
|
5683
5732
|
};
|
|
5684
|
-
compiler.hooks.watchRun.tap('rsbuild:compiling', ()=>{
|
|
5685
|
-
logRspackVersion(), isCompiling
|
|
5733
|
+
compiler.hooks.watchRun.tap('rsbuild:compiling', (compiler)=>{
|
|
5734
|
+
if (logRspackVersion(), !isCompiling) {
|
|
5735
|
+
let changedFiles = compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : [], removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : [];
|
|
5736
|
+
if (changedFiles.length) {
|
|
5737
|
+
let fileInfo = index_js_default().dim(changedFiles.map((file)=>cutPath(file, context.rootPath)).join(', '));
|
|
5738
|
+
rslog_index_js_namespaceObject.logger.start(`building ${fileInfo}`);
|
|
5739
|
+
} else if (removedFiles.length) {
|
|
5740
|
+
let fileInfo = removedFiles.map((file)=>cutPath(file, context.rootPath)).join(', ');
|
|
5741
|
+
rslog_index_js_namespaceObject.logger.start(`building ${index_js_default().dim(`removed ${fileInfo}`)}`);
|
|
5742
|
+
} else rslog_index_js_namespaceObject.logger.start('build started...');
|
|
5743
|
+
}
|
|
5744
|
+
isCompiling = !0;
|
|
5686
5745
|
}), 'build' === context.command && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
|
|
5687
5746
|
let done = (stats)=>{
|
|
5688
5747
|
let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
|
|
@@ -5694,7 +5753,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
5694
5753
|
}), printTime = (c, index)=>{
|
|
5695
5754
|
if (c.time) {
|
|
5696
5755
|
let time = prettyTime(c.time / 1000), { name } = rspackConfigs[index], suffix = name ? index_js_default().gray(` (${name})`) : '';
|
|
5697
|
-
rslog_index_js_namespaceObject.logger.ready(`
|
|
5756
|
+
rslog_index_js_namespaceObject.logger.ready(`built in ${time}${suffix}`);
|
|
5698
5757
|
}
|
|
5699
5758
|
}, hasErrors = stats.hasErrors();
|
|
5700
5759
|
if (!hasErrors) {
|
|
@@ -6147,35 +6206,29 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6147
6206
|
let pluginName = 'RsbuildCorePlugin';
|
|
6148
6207
|
chain.plugin(pluginName).use(class {
|
|
6149
6208
|
apply(compiler) {
|
|
6150
|
-
for (let { handler, environment: pluginEnvironment } of (compiler.__rsbuildTransformer = transformer, resolveFns)){
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
}));
|
|
6159
|
-
});
|
|
6160
|
-
}
|
|
6209
|
+
for (let { handler, environment: pluginEnvironment } of (compiler.__rsbuildTransformer = transformer, resolveFns))(!pluginEnvironment || isPluginMatchEnvironment(pluginEnvironment, environment.name)) && compiler.hooks.compilation.tap(pluginName, (compilation, { normalModuleFactory })=>{
|
|
6210
|
+
normalModuleFactory.hooks.resolve.tapPromise(pluginName, async (resolveData)=>handler({
|
|
6211
|
+
compiler,
|
|
6212
|
+
compilation,
|
|
6213
|
+
environment,
|
|
6214
|
+
resolveData
|
|
6215
|
+
}));
|
|
6216
|
+
});
|
|
6161
6217
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation)=>{
|
|
6162
6218
|
compilation.hooks.childCompiler.tap(pluginName, (childCompiler)=>{
|
|
6163
6219
|
childCompiler.__rsbuildTransformer = transformer;
|
|
6164
6220
|
});
|
|
6165
6221
|
let { sources } = compiler.webpack;
|
|
6166
|
-
for (let { descriptor, handler, environment: pluginEnvironment } of processAssetsFns){
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
sources
|
|
6177
|
-
}));
|
|
6178
|
-
}
|
|
6222
|
+
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({
|
|
6223
|
+
name: pluginName,
|
|
6224
|
+
stage: mapProcessAssetsStage(compiler, descriptor.stage)
|
|
6225
|
+
}, async (assets)=>handler({
|
|
6226
|
+
assets,
|
|
6227
|
+
compiler,
|
|
6228
|
+
compilation,
|
|
6229
|
+
environment,
|
|
6230
|
+
sources
|
|
6231
|
+
}));
|
|
6179
6232
|
});
|
|
6180
6233
|
}
|
|
6181
6234
|
constructor(){
|
|
@@ -6690,12 +6743,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6690
6743
|
}
|
|
6691
6744
|
}(), process.title = 'rsbuild-node';
|
|
6692
6745
|
let { npm_execpath } = process.env;
|
|
6693
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.
|
|
6746
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.2.13\n`);
|
|
6694
6747
|
}();
|
|
6695
6748
|
try {
|
|
6696
6749
|
!function() {
|
|
6697
6750
|
let cli = dist('rsbuild');
|
|
6698
|
-
cli.help(), cli.version("1.2.
|
|
6751
|
+
cli.help(), cli.version("1.2.13"), applyCommonOptions(cli);
|
|
6699
6752
|
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');
|
|
6700
6753
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
6701
6754
|
try {
|
|
@@ -6746,7 +6799,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6746
6799
|
rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
|
|
6747
6800
|
}
|
|
6748
6801
|
}
|
|
6749
|
-
let src_rslib_entry_version = "1.2.
|
|
6802
|
+
let src_rslib_entry_version = "1.2.13";
|
|
6750
6803
|
})();
|
|
6751
6804
|
var __webpack_export_target__ = exports;
|
|
6752
6805
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|