@rslib/core 0.6.6 → 0.6.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/dist/index.js +118 -111
- package/dist/libCssExtractLoader.js +8 -8
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__ from "../compiled/rslog/index.js";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__ from "../compiled/picocolors/index.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__ from "../compiled/commander/index.js";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
10
|
+
import * as __WEBPACK_EXTERNAL_MODULE_module__ from "module";
|
|
11
11
|
const nodeBuiltInModules = [
|
|
12
12
|
'assert',
|
|
13
13
|
'assert/strict',
|
|
@@ -68,7 +68,7 @@ const nodeBuiltInModules = [
|
|
|
68
68
|
];
|
|
69
69
|
async function calcLongestCommonPath(absPaths) {
|
|
70
70
|
if (0 === absPaths.length) return null;
|
|
71
|
-
const sep =
|
|
71
|
+
const sep = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep;
|
|
72
72
|
const splitPaths = absPaths.map((p)=>p.split(sep));
|
|
73
73
|
let lcaFragments = splitPaths[0];
|
|
74
74
|
for(let i = 1; i < splitPaths.length; i++){
|
|
@@ -79,20 +79,20 @@ async function calcLongestCommonPath(absPaths) {
|
|
|
79
79
|
lcaFragments = lcaFragments.slice(0, j);
|
|
80
80
|
}
|
|
81
81
|
let lca = lcaFragments.length > 0 ? lcaFragments.join(sep) : sep;
|
|
82
|
-
const stats = await
|
|
83
|
-
if (stats?.isFile()) lca =
|
|
82
|
+
const stats = await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].stat(lca);
|
|
83
|
+
if (stats?.isFile()) lca = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(lca);
|
|
84
84
|
return lca;
|
|
85
85
|
}
|
|
86
86
|
function getAbsolutePath(base, filepath) {
|
|
87
|
-
return isAbsolute(filepath) ? filepath : join(base, filepath);
|
|
87
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(filepath) ? filepath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(base, filepath);
|
|
88
88
|
}
|
|
89
89
|
const readPackageJson = (rootPath)=>{
|
|
90
|
-
const pkgJsonPath =
|
|
91
|
-
if (!
|
|
90
|
+
const pkgJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(rootPath, './package.json');
|
|
91
|
+
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(pkgJsonPath)) return void __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`The \`package.json\` file does not exist in the ${rootPath} directory`);
|
|
92
92
|
try {
|
|
93
|
-
return JSON.parse(
|
|
93
|
+
return JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(pkgJsonPath, 'utf8'));
|
|
94
94
|
} catch (err) {
|
|
95
|
-
logger.warn(`Failed to parse ${pkgJsonPath}, it might not be valid JSON`);
|
|
95
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Failed to parse ${pkgJsonPath}, it might not be valid JSON`);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -124,7 +124,7 @@ function checkMFPlugin(config, sharedPlugins) {
|
|
|
124
124
|
...config.plugins || []
|
|
125
125
|
]);
|
|
126
126
|
if (!added) {
|
|
127
|
-
logger.warn(`${
|
|
127
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green('format: "mf"')} should be used with ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue('@module-federation/rsbuild-plugin')}", consider installing and adding it to plugins. Check the documentation (https://module-federation.io/guide/basic/rsbuild.html#rslib-module) to get started with "mf" output.`);
|
|
128
128
|
process.exit(1);
|
|
129
129
|
}
|
|
130
130
|
return added;
|
|
@@ -154,7 +154,7 @@ const isDebug = ()=>{
|
|
|
154
154
|
'*'
|
|
155
155
|
].some((key)=>values.includes(key));
|
|
156
156
|
};
|
|
157
|
-
if (isDebug()) logger.level = 'verbose';
|
|
157
|
+
if (isDebug()) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level = 'verbose';
|
|
158
158
|
function getTime() {
|
|
159
159
|
const now = new Date();
|
|
160
160
|
const hours = String(now.getHours()).padStart(2, '0');
|
|
@@ -162,11 +162,11 @@ function getTime() {
|
|
|
162
162
|
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
163
163
|
return `${hours}:${minutes}:${seconds}`;
|
|
164
164
|
}
|
|
165
|
-
logger.override({
|
|
165
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.override({
|
|
166
166
|
debug: (message, ...args)=>{
|
|
167
|
-
if ('verbose' !== logger.level) return;
|
|
168
|
-
const time =
|
|
169
|
-
console.log(` ${
|
|
167
|
+
if ('verbose' !== __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level) return;
|
|
168
|
+
const time = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].gray(`${getTime()}`);
|
|
169
|
+
console.log(` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green('rslib')} ${time} ${message}`, ...args);
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
function initNodeEnv() {
|
|
@@ -181,7 +181,7 @@ function prepareCli() {
|
|
|
181
181
|
initNodeEnv();
|
|
182
182
|
const { npm_execpath } = process.env;
|
|
183
183
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
184
|
-
logger.greet(` Rslib v0.6.
|
|
184
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.6.8\n`);
|
|
185
185
|
}
|
|
186
186
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
187
187
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -418,7 +418,7 @@ class LibCssExtractPlugin {
|
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
|
-
const cssConfig_require = createRequire(import.meta.url);
|
|
421
|
+
const cssConfig_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
422
422
|
const RSLIB_CSS_ENTRY_FLAG = '__rslib_css__';
|
|
423
423
|
function isCssFile(filepath) {
|
|
424
424
|
return CSS_EXTENSIONS_PATTERN.test(filepath);
|
|
@@ -434,7 +434,7 @@ function parsePathQueryFragment(str) {
|
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
function cssConfig_isCssModulesFile(filepath, auto) {
|
|
437
|
-
const filename =
|
|
437
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath);
|
|
438
438
|
if (true === auto) return CSS_MODULE_REG.test(filename);
|
|
439
439
|
if (auto instanceof RegExp) return auto.test(filepath);
|
|
440
440
|
if ('function' == typeof auto) {
|
|
@@ -516,7 +516,7 @@ const composeCssConfig = (rootDir, auto, bundle = true, banner, footer)=>{
|
|
|
516
516
|
}
|
|
517
517
|
};
|
|
518
518
|
};
|
|
519
|
-
const EntryChunkPlugin_require = createRequire(import.meta.url);
|
|
519
|
+
const EntryChunkPlugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
520
520
|
const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
|
|
521
521
|
const EntryChunkPlugin_LOADER_NAME = 'rsbuild:lib-entry-module';
|
|
522
522
|
const IMPORT_META_URL_SHIM = `const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
@@ -620,7 +620,7 @@ class EntryChunkPlugin {
|
|
|
620
620
|
});
|
|
621
621
|
});
|
|
622
622
|
compiler.hooks.assetEmitted.tap(EntryChunkPlugin_PLUGIN_NAME, (file, { targetPath })=>{
|
|
623
|
-
if (this.shebangInjectedAssets.has(file)) chmodSync(targetPath, this.shebangChmod);
|
|
623
|
+
if (this.shebangInjectedAssets.has(file)) (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.chmodSync)(targetPath, this.shebangChmod);
|
|
624
624
|
});
|
|
625
625
|
}
|
|
626
626
|
}
|
|
@@ -685,7 +685,7 @@ const getDefaultExtension = (options)=>{
|
|
|
685
685
|
dtsExtension
|
|
686
686
|
};
|
|
687
687
|
if (!pkgJson) {
|
|
688
|
-
logger.warn('The `autoExtension` configuration will not be applied due to read package.json failed');
|
|
688
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The `autoExtension` configuration will not be applied due to read package.json failed');
|
|
689
689
|
return {
|
|
690
690
|
jsExtension,
|
|
691
691
|
dtsExtension
|
|
@@ -870,8 +870,8 @@ function transformSyntaxToBrowserslist(syntax, target) {
|
|
|
870
870
|
if (Array.isArray(syntax)) return syntax.flatMap(handleSyntaxItem);
|
|
871
871
|
return handleSyntaxItem(syntax);
|
|
872
872
|
}
|
|
873
|
-
const POSIX_SEP_RE = new RegExp('\\' +
|
|
874
|
-
const NATIVE_SEP_RE = new RegExp('\\' +
|
|
873
|
+
const POSIX_SEP_RE = new RegExp('\\' + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep, 'g');
|
|
874
|
+
const NATIVE_SEP_RE = new RegExp('\\' + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep, 'g');
|
|
875
875
|
const PATTERN_REGEX_CACHE = new Map();
|
|
876
876
|
const GLOB_ALL_PATTERN = "**/*";
|
|
877
877
|
const TS_EXTENSIONS = [
|
|
@@ -889,7 +889,7 @@ const util_JS_EXTENSIONS = [
|
|
|
889
889
|
const TSJS_EXTENSIONS = TS_EXTENSIONS.concat(util_JS_EXTENSIONS);
|
|
890
890
|
const TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
891
891
|
const TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
892
|
-
const IS_POSIX =
|
|
892
|
+
const IS_POSIX = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
893
893
|
function util_makePromise() {
|
|
894
894
|
let resolve, reject;
|
|
895
895
|
const promise = new Promise((res, rej)=>{
|
|
@@ -903,22 +903,22 @@ function util_makePromise() {
|
|
|
903
903
|
};
|
|
904
904
|
}
|
|
905
905
|
async function util_resolveTSConfigJson(filename, cache) {
|
|
906
|
-
if ('.json' !==
|
|
907
|
-
const tsconfig =
|
|
906
|
+
if ('.json' !== __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(filename)) return;
|
|
907
|
+
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename);
|
|
908
908
|
if (cache && (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename))) return tsconfig;
|
|
909
|
-
return promises.stat(tsconfig).then((stat)=>{
|
|
909
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.stat(tsconfig).then((stat)=>{
|
|
910
910
|
if (stat.isFile() || stat.isFIFO()) return tsconfig;
|
|
911
911
|
throw new Error(`${filename} exists but is not a regular file.`);
|
|
912
912
|
});
|
|
913
913
|
}
|
|
914
914
|
const util_isInNodeModules = IS_POSIX ? (dir)=>dir.includes('/node_modules/') : (dir)=>dir.match(/[/\\]node_modules[/\\]/);
|
|
915
|
-
const posix2native = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(POSIX_SEP_RE,
|
|
916
|
-
const util_native2posix = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(NATIVE_SEP_RE,
|
|
917
|
-
const resolve2posix = IS_POSIX ? (dir, filename)=>dir ?
|
|
915
|
+
const posix2native = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(POSIX_SEP_RE, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep);
|
|
916
|
+
const util_native2posix = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(NATIVE_SEP_RE, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep);
|
|
917
|
+
const resolve2posix = IS_POSIX ? (dir, filename)=>dir ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(dir, filename) : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename) : (dir, filename)=>util_native2posix(dir ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(posix2native(dir), posix2native(filename)) : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(posix2native(filename)));
|
|
918
918
|
function util_resolveReferencedTSConfigFiles(result, options) {
|
|
919
|
-
const dir =
|
|
919
|
+
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile);
|
|
920
920
|
return result.tsconfig.references.map((ref)=>{
|
|
921
|
-
const refPath = ref.path.endsWith('.json') ? ref.path :
|
|
921
|
+
const refPath = ref.path.endsWith('.json') ? ref.path : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(ref.path, options?.configName ?? 'tsconfig.json');
|
|
922
922
|
return resolve2posix(dir, refPath);
|
|
923
923
|
});
|
|
924
924
|
}
|
|
@@ -932,7 +932,7 @@ function util_resolveSolutionTSConfig(filename, result) {
|
|
|
932
932
|
return result;
|
|
933
933
|
}
|
|
934
934
|
function util_isIncluded(filename, result) {
|
|
935
|
-
const dir = util_native2posix(
|
|
935
|
+
const dir = util_native2posix(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile));
|
|
936
936
|
const files = (result.tsconfig.files || []).map((file)=>resolve2posix(dir, file));
|
|
937
937
|
const absoluteFilename = resolve2posix(null, filename);
|
|
938
938
|
if (files.includes(filename)) return true;
|
|
@@ -1020,16 +1020,16 @@ function pattern2regex(resolvedPattern, allowJs) {
|
|
|
1020
1020
|
return new RegExp(regexStr);
|
|
1021
1021
|
}
|
|
1022
1022
|
function util_replaceTokens(result) {
|
|
1023
|
-
if (result.tsconfig) result.tsconfig = JSON.parse(JSON.stringify(result.tsconfig).replaceAll(/"\${configDir}/g, `"${util_native2posix(
|
|
1023
|
+
if (result.tsconfig) result.tsconfig = JSON.parse(JSON.stringify(result.tsconfig).replaceAll(/"\${configDir}/g, `"${util_native2posix(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile))}`));
|
|
1024
1024
|
}
|
|
1025
1025
|
async function find(filename, options) {
|
|
1026
|
-
let dir =
|
|
1026
|
+
let dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename));
|
|
1027
1027
|
if (options?.ignoreNodeModules && util_isInNodeModules(dir)) return null;
|
|
1028
1028
|
const cache = options?.cache;
|
|
1029
1029
|
const configName = options?.configName ?? 'tsconfig.json';
|
|
1030
1030
|
if (cache?.hasConfigPath(dir, configName)) return cache.getConfigPath(dir, configName);
|
|
1031
1031
|
const { promise, resolve, reject } = util_makePromise();
|
|
1032
|
-
if (options?.root && !
|
|
1032
|
+
if (options?.root && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(options.root)) options.root = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(options.root);
|
|
1033
1033
|
findUp(dir, {
|
|
1034
1034
|
promise,
|
|
1035
1035
|
resolve,
|
|
@@ -1050,13 +1050,13 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
1050
1050
|
if (cached?.then) cached.then(resolve).catch(reject);
|
|
1051
1051
|
else resolve(cached);
|
|
1052
1052
|
} else cache.setConfigPath(dir, promise, configName);
|
|
1053
|
-
const tsconfig =
|
|
1054
|
-
|
|
1053
|
+
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, options?.configName ?? 'tsconfig.json');
|
|
1054
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].stat(tsconfig, (err, stats)=>{
|
|
1055
1055
|
if (stats && (stats.isFile() || stats.isFIFO())) resolve(tsconfig);
|
|
1056
1056
|
else if (err?.code !== 'ENOENT') reject(err);
|
|
1057
1057
|
else {
|
|
1058
1058
|
let parent;
|
|
1059
|
-
if (root === dir || (parent =
|
|
1059
|
+
if (root === dir || (parent = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(dir)) === dir) resolve(null);
|
|
1060
1060
|
else findUp(parent, {
|
|
1061
1061
|
promise,
|
|
1062
1062
|
resolve,
|
|
@@ -1065,7 +1065,7 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
});
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1068
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
1069
1069
|
function toJson(tsconfigJson) {
|
|
1070
1070
|
const stripped = stripDanglingComma(stripJsonComments(stripBom(tsconfigJson)));
|
|
1071
1071
|
if ('' === stripped.trim()) return '{}';
|
|
@@ -1206,12 +1206,12 @@ async function getParsedDeep(filename, cache, options) {
|
|
|
1206
1206
|
}
|
|
1207
1207
|
async function parseFile(tsconfigFile, cache, skipCache) {
|
|
1208
1208
|
if (!skipCache && cache?.hasParseResult(tsconfigFile) && !cache.getParseResult(tsconfigFile)._isRootFile_) return cache.getParseResult(tsconfigFile);
|
|
1209
|
-
const promise = promises.readFile(tsconfigFile, 'utf-8').then(toJson).then((json)=>{
|
|
1209
|
+
const promise = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.readFile(tsconfigFile, 'utf-8').then(toJson).then((json)=>{
|
|
1210
1210
|
const parsed = JSON.parse(json);
|
|
1211
1211
|
applyDefaults(parsed, tsconfigFile);
|
|
1212
1212
|
return {
|
|
1213
1213
|
tsconfigFile,
|
|
1214
|
-
tsconfig: normalizeTSConfig(parsed,
|
|
1214
|
+
tsconfig: normalizeTSConfig(parsed, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(tsconfigFile))
|
|
1215
1215
|
};
|
|
1216
1216
|
}).catch((e)=>{
|
|
1217
1217
|
throw new TSConfckParseError(`parsing ${tsconfigFile} failed: ${e}`, 'PARSE_FILE', tsconfigFile, e);
|
|
@@ -1221,7 +1221,7 @@ async function parseFile(tsconfigFile, cache, skipCache) {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
function normalizeTSConfig(tsconfig, dir) {
|
|
1223
1223
|
const baseUrl = tsconfig.compilerOptions?.baseUrl;
|
|
1224
|
-
if (baseUrl && !baseUrl.startsWith('${') && !
|
|
1224
|
+
if (baseUrl && !baseUrl.startsWith('${') && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(baseUrl)) tsconfig.compilerOptions.baseUrl = resolve2posix(dir, baseUrl);
|
|
1225
1225
|
return tsconfig;
|
|
1226
1226
|
}
|
|
1227
1227
|
async function parseReferences(result, options) {
|
|
@@ -1274,14 +1274,14 @@ async function parseExtends(result, cache) {
|
|
|
1274
1274
|
}
|
|
1275
1275
|
function resolveExtends(extended, from) {
|
|
1276
1276
|
if ('..' === extended) extended = '../tsconfig.json';
|
|
1277
|
-
const req =
|
|
1277
|
+
const req = (0, __WEBPACK_EXTERNAL_MODULE_module__.createRequire)(from);
|
|
1278
1278
|
let error;
|
|
1279
1279
|
try {
|
|
1280
1280
|
return req.resolve(extended);
|
|
1281
1281
|
} catch (e) {
|
|
1282
1282
|
error = e;
|
|
1283
1283
|
}
|
|
1284
|
-
if ('.' !== extended[0] && !
|
|
1284
|
+
if ('.' !== extended[0] && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(extended)) try {
|
|
1285
1285
|
return req.resolve(`${extended}/tsconfig.json`);
|
|
1286
1286
|
} catch (e) {
|
|
1287
1287
|
error = e;
|
|
@@ -1301,7 +1301,7 @@ const EXTENDABLE_KEYS = [
|
|
|
1301
1301
|
function extendTSConfig(extending, extended) {
|
|
1302
1302
|
const extendingConfig = extending.tsconfig;
|
|
1303
1303
|
const extendedConfig = extended.tsconfig;
|
|
1304
|
-
const relativePath = util_native2posix(
|
|
1304
|
+
const relativePath = util_native2posix(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(extending.tsconfigFile), __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(extended.tsconfigFile)));
|
|
1305
1305
|
for (const key of Object.keys(extendedConfig).filter((key)=>EXTENDABLE_KEYS.includes(key)))if ('compilerOptions' === key) {
|
|
1306
1306
|
if (!extendingConfig.compilerOptions) extendingConfig.compilerOptions = {};
|
|
1307
1307
|
for (const option of Object.keys(extendedConfig.compilerOptions))if (!Object.prototype.hasOwnProperty.call(extendingConfig.compilerOptions, option)) extendingConfig.compilerOptions[option] = rebaseRelative(option, extendedConfig.compilerOptions[option], relativePath);
|
|
@@ -1330,8 +1330,8 @@ function rebaseRelative(key, value, prependPath) {
|
|
|
1330
1330
|
return rebasePath(value, prependPath);
|
|
1331
1331
|
}
|
|
1332
1332
|
function rebasePath(value, prependPath) {
|
|
1333
|
-
if (
|
|
1334
|
-
return
|
|
1333
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(value) || value.startsWith('${configDir}')) return value;
|
|
1334
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.join(prependPath, value));
|
|
1335
1335
|
}
|
|
1336
1336
|
class TSConfckParseError extends Error {
|
|
1337
1337
|
code;
|
|
@@ -1360,12 +1360,12 @@ const DEFAULT_JSCONFIG_COMPILER_OPTIONS = {
|
|
|
1360
1360
|
noEmit: true
|
|
1361
1361
|
};
|
|
1362
1362
|
function isJSConfig(configFileName) {
|
|
1363
|
-
return 'jsconfig.json' ===
|
|
1363
|
+
return 'jsconfig.json' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(configFileName);
|
|
1364
1364
|
}
|
|
1365
1365
|
async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
1366
|
-
const tsconfigFileName = await find(join(root, tsconfigPath), {
|
|
1366
|
+
const tsconfigFileName = await find((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, tsconfigPath), {
|
|
1367
1367
|
root,
|
|
1368
|
-
configName: basename(tsconfigPath)
|
|
1368
|
+
configName: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.basename)(tsconfigPath)
|
|
1369
1369
|
});
|
|
1370
1370
|
if (tsconfigFileName) {
|
|
1371
1371
|
const { tsconfig } = await parse(tsconfigFileName);
|
|
@@ -1376,21 +1376,21 @@ async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
|
1376
1376
|
function defineConfig(config) {
|
|
1377
1377
|
return config;
|
|
1378
1378
|
}
|
|
1379
|
-
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(
|
|
1379
|
+
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync);
|
|
1380
1380
|
const resolveConfigPath = (root, customConfig)=>{
|
|
1381
1381
|
if (customConfig) {
|
|
1382
|
-
const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
|
|
1383
|
-
if (
|
|
1384
|
-
logger.warn(`Cannot find config file: ${
|
|
1382
|
+
const customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
|
|
1383
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
1384
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Cannot find config file: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].dim(customConfigPath)}\n`);
|
|
1385
1385
|
}
|
|
1386
|
-
const configFilePath = findConfig(join(root, DEFAULT_CONFIG_NAME));
|
|
1386
|
+
const configFilePath = findConfig((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, DEFAULT_CONFIG_NAME));
|
|
1387
1387
|
if (configFilePath) return configFilePath;
|
|
1388
1388
|
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
1389
1389
|
};
|
|
1390
1390
|
async function loadConfig({ cwd = process.cwd(), path, envMode }) {
|
|
1391
1391
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
1392
1392
|
const { content } = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadConfig)({
|
|
1393
|
-
cwd: dirname(configFilePath),
|
|
1393
|
+
cwd: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(configFilePath),
|
|
1394
1394
|
path: configFilePath,
|
|
1395
1395
|
envMode
|
|
1396
1396
|
});
|
|
@@ -1462,7 +1462,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1462
1462
|
};
|
|
1463
1463
|
if (contextInfo.issuer && 'commonjs' === dependencyType) {
|
|
1464
1464
|
matchUserExternals(externals, request, _callback);
|
|
1465
|
-
if (shouldWarn) logger.warn(composeModuleImportWarn(request, contextInfo.issuer));
|
|
1465
|
+
if (shouldWarn) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request, contextInfo.issuer));
|
|
1466
1466
|
}
|
|
1467
1467
|
callback();
|
|
1468
1468
|
}
|
|
@@ -1477,7 +1477,7 @@ const composeAutoExternalConfig = (options)=>{
|
|
|
1477
1477
|
const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
|
|
1478
1478
|
if (false === autoExternal) return {};
|
|
1479
1479
|
if (!pkgJson) {
|
|
1480
|
-
logger.warn('The `autoExternal` configuration will not be applied due to read package.json failed');
|
|
1480
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The `autoExternal` configuration will not be applied due to read package.json failed');
|
|
1481
1481
|
return {};
|
|
1482
1482
|
}
|
|
1483
1483
|
const userExternalKeys = userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];
|
|
@@ -1668,6 +1668,9 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1668
1668
|
esm: {
|
|
1669
1669
|
importMeta: false,
|
|
1670
1670
|
importDynamic: false
|
|
1671
|
+
},
|
|
1672
|
+
others: {
|
|
1673
|
+
worker: false
|
|
1671
1674
|
}
|
|
1672
1675
|
};
|
|
1673
1676
|
switch(format){
|
|
@@ -1679,7 +1682,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1679
1682
|
parser: {
|
|
1680
1683
|
javascript: {
|
|
1681
1684
|
...jsParserOptions.esm,
|
|
1682
|
-
...jsParserOptions.cjs
|
|
1685
|
+
...jsParserOptions.cjs,
|
|
1686
|
+
...jsParserOptions.others
|
|
1683
1687
|
}
|
|
1684
1688
|
}
|
|
1685
1689
|
},
|
|
@@ -1712,7 +1716,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1712
1716
|
parser: {
|
|
1713
1717
|
javascript: {
|
|
1714
1718
|
...jsParserOptions.esm,
|
|
1715
|
-
...jsParserOptions.cjs
|
|
1719
|
+
...jsParserOptions.cjs,
|
|
1720
|
+
...jsParserOptions.others
|
|
1716
1721
|
}
|
|
1717
1722
|
}
|
|
1718
1723
|
},
|
|
@@ -1785,8 +1790,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1785
1790
|
throw new Error(`Unsupported format: ${format}`);
|
|
1786
1791
|
}
|
|
1787
1792
|
};
|
|
1788
|
-
const
|
|
1789
|
-
name: 'rsbuild:
|
|
1793
|
+
const disableUrlParseRsbuildPlugin = ()=>({
|
|
1794
|
+
name: 'rsbuild:disable-url-parse',
|
|
1790
1795
|
setup (api) {
|
|
1791
1796
|
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
1792
1797
|
config.module.rule(CHAIN_ID.RULE.JS).parser({
|
|
@@ -1830,14 +1835,15 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1830
1835
|
},
|
|
1831
1836
|
plugins: [
|
|
1832
1837
|
resolvedShims.esm.require && pluginEsmRequireShim(),
|
|
1833
|
-
|
|
1838
|
+
disableUrlParseRsbuildPlugin()
|
|
1834
1839
|
].filter(Boolean)
|
|
1835
1840
|
};
|
|
1836
1841
|
break;
|
|
1837
1842
|
case 'cjs':
|
|
1838
1843
|
rsbuildConfig = {
|
|
1839
1844
|
plugins: [
|
|
1840
|
-
resolvedShims.cjs['import.meta.url'] && pluginCjsImportMetaUrlShim()
|
|
1845
|
+
resolvedShims.cjs['import.meta.url'] && pluginCjsImportMetaUrlShim(),
|
|
1846
|
+
disableUrlParseRsbuildPlugin()
|
|
1841
1847
|
].filter(Boolean)
|
|
1842
1848
|
};
|
|
1843
1849
|
break;
|
|
@@ -1852,7 +1858,7 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1852
1858
|
enabledShims
|
|
1853
1859
|
};
|
|
1854
1860
|
};
|
|
1855
|
-
const composeModuleImportWarn = (request, issuer)=>`The externalized commonjs request ${
|
|
1861
|
+
const composeModuleImportWarn = (request, issuer)=>`The externalized commonjs request ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(`"${request}"`)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(issuer)} will use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue('"module"')} external type in ESM format. If you want to specify other external type, consider setting the request and type with ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue('"output.externals"')}.`;
|
|
1856
1862
|
const composeExternalsConfig = (format, externals)=>{
|
|
1857
1863
|
const externalsTypeMap = {
|
|
1858
1864
|
esm: 'module-import',
|
|
@@ -1893,7 +1899,7 @@ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
|
1893
1899
|
const hash = getHash();
|
|
1894
1900
|
const defaultJsFilename = `[name]${hash}${jsExtension}`;
|
|
1895
1901
|
const userJsFilename = config.output?.filename?.js;
|
|
1896
|
-
const finalJsExtension = 'string' == typeof userJsFilename && userJsFilename ? extname(userJsFilename) : jsExtension;
|
|
1902
|
+
const finalJsExtension = 'string' == typeof userJsFilename && userJsFilename ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(userJsFilename) : jsExtension;
|
|
1897
1903
|
const finalConfig = userJsFilename ? {} : {
|
|
1898
1904
|
output: {
|
|
1899
1905
|
filename: {
|
|
@@ -1944,7 +1950,7 @@ const traverseEntryQuery = (entry, callback)=>{
|
|
|
1944
1950
|
}
|
|
1945
1951
|
return newEntry;
|
|
1946
1952
|
};
|
|
1947
|
-
const resolveEntryPath = (entries, root)=>traverseEntryQuery(entries, (item)=>
|
|
1953
|
+
const resolveEntryPath = (entries, root)=>traverseEntryQuery(entries, (item)=>__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, item));
|
|
1948
1954
|
const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOutBase)=>{
|
|
1949
1955
|
let entries = rawEntry;
|
|
1950
1956
|
if (!entries) {
|
|
@@ -1956,18 +1962,18 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
1956
1962
|
index: 'src/**'
|
|
1957
1963
|
};
|
|
1958
1964
|
}
|
|
1959
|
-
if ('object' != typeof entries) throw new Error(`The ${
|
|
1965
|
+
if ('object' != typeof entries) throw new Error(`The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan('source.entry')} configuration should be an object, but received ${typeof entries}: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(entries)}. Checkout ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green('https://lib.rsbuild.dev/config/rsbuild/source#sourceentry')} for more details.`);
|
|
1960
1966
|
if (false !== bundle) {
|
|
1961
1967
|
const entryErrorReasons = [];
|
|
1962
1968
|
traverseEntryQuery(entries, (entry)=>{
|
|
1963
|
-
const entryAbsPath =
|
|
1964
|
-
const isDirLike = '' ===
|
|
1965
|
-
const dirError = `Glob pattern ${
|
|
1966
|
-
if (
|
|
1967
|
-
const stats =
|
|
1969
|
+
const entryAbsPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(entry) ? entry : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, entry);
|
|
1970
|
+
const isDirLike = '' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(entryAbsPath);
|
|
1971
|
+
const dirError = `Glob pattern ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(`"${entry}"`)} is not supported when "bundle" is "true", considering "bundle" to "false" to use bundleless mode, or specify a file entry to bundle. See ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green('https://lib.rsbuild.dev/guide/basic/output-structure')} for more details.`;
|
|
1972
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(entryAbsPath)) {
|
|
1973
|
+
const stats = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].statSync(entryAbsPath);
|
|
1968
1974
|
if (!stats.isFile()) entryErrorReasons.push(dirError);
|
|
1969
1975
|
} else if (isDirLike) entryErrorReasons.push(dirError);
|
|
1970
|
-
else entryErrorReasons.push(`Can't resolve the entry ${
|
|
1976
|
+
else entryErrorReasons.push(`Can't resolve the entry ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(`"${entry}"`)} at the location ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(`${entryAbsPath}`)}. Please ensure that the file exists.`);
|
|
1971
1977
|
return entry;
|
|
1972
1978
|
});
|
|
1973
1979
|
if (entryErrorReasons.length) throw new AggregateError(entryErrorReasons.map((reason)=>new Error(reason)));
|
|
@@ -1983,7 +1989,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
1983
1989
|
const scanGlobEntries = async (tryResolveOutBase)=>{
|
|
1984
1990
|
const resolvedEntries = {};
|
|
1985
1991
|
const resolveOutBase = async (resolvedEntryFiles)=>{
|
|
1986
|
-
if (void 0 !== userOutBase) return
|
|
1992
|
+
if (void 0 !== userOutBase) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(userOutBase) ? userOutBase : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, userOutBase);
|
|
1987
1993
|
const lcp = await calcLongestCommonPath(resolvedEntryFiles) ?? root;
|
|
1988
1994
|
return lcp;
|
|
1989
1995
|
};
|
|
@@ -1993,7 +1999,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
1993
1999
|
entry
|
|
1994
2000
|
] : null;
|
|
1995
2001
|
if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
|
|
1996
|
-
const globEntryFiles = await glob(entryFiles, {
|
|
2002
|
+
const globEntryFiles = await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)(entryFiles, {
|
|
1997
2003
|
cwd: root,
|
|
1998
2004
|
absolute: true
|
|
1999
2005
|
});
|
|
@@ -2001,14 +2007,14 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
2001
2007
|
if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
|
|
2002
2008
|
const outBase = await resolveOutBase(resolvedEntryFiles);
|
|
2003
2009
|
function getEntryName(file) {
|
|
2004
|
-
const { dir, name } =
|
|
2005
|
-
const entryFileName =
|
|
2010
|
+
const { dir, name } = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(outBase, file));
|
|
2011
|
+
const entryFileName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, name);
|
|
2006
2012
|
if (isCssGlobalFile(file, cssModulesAuto)) return `${RSLIB_CSS_ENTRY_FLAG}/${entryFileName}`;
|
|
2007
2013
|
return entryFileName;
|
|
2008
2014
|
}
|
|
2009
2015
|
for (const file of resolvedEntryFiles){
|
|
2010
2016
|
const entryName = getEntryName(file);
|
|
2011
|
-
if (resolvedEntries[entryName]) tryResolveOutBase && logger.warn(`Duplicate entry ${
|
|
2017
|
+
if (resolvedEntries[entryName]) tryResolveOutBase && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Duplicate entry ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(entryName)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file))} and ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, resolvedEntries[entryName]))}, which may lead to the incorrect output, please rename the file.`);
|
|
2012
2018
|
resolvedEntries[entryName] = file;
|
|
2013
2019
|
}
|
|
2014
2020
|
}
|
|
@@ -2070,13 +2076,13 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
2070
2076
|
if ('string' != typeof outBase) throw new Error(`outBase expect to be a string in bundleless mode, but got ${outBase}`);
|
|
2071
2077
|
const isSubpath = normalizeSlash(resolvedRequest).startsWith(`${normalizeSlash(outBase)}/`);
|
|
2072
2078
|
if (isSubpath) {
|
|
2073
|
-
resolvedRequest = normalizeSlash(
|
|
2079
|
+
resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(issuer), resolvedRequest));
|
|
2074
2080
|
if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
|
|
2075
2081
|
return resolvedRequest;
|
|
2076
2082
|
}
|
|
2077
2083
|
return;
|
|
2078
2084
|
} catch (e) {
|
|
2079
|
-
logger.debug(`Failed to resolve module ${
|
|
2085
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`Failed to resolve module ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(`"${request}"`)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`);
|
|
2080
2086
|
return request;
|
|
2081
2087
|
}
|
|
2082
2088
|
}
|
|
@@ -2090,7 +2096,7 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
2090
2096
|
resolvedRequest = redirectedPath;
|
|
2091
2097
|
}
|
|
2092
2098
|
if (resolvedRequest.startsWith('.')) {
|
|
2093
|
-
const ext = extname(resolvedRequest);
|
|
2099
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(resolvedRequest);
|
|
2094
2100
|
if (ext) {
|
|
2095
2101
|
if (JS_EXTENSIONS_PATTERN.test(resolvedRequest)) {
|
|
2096
2102
|
if (jsRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
@@ -2188,7 +2194,7 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
2188
2194
|
...Object.keys(pkgJson?.devDependencies ?? [])
|
|
2189
2195
|
];
|
|
2190
2196
|
if (!deps.includes(SWC_HELPERS)) {
|
|
2191
|
-
logger.error(`${
|
|
2197
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green('externalHelpers')} is enabled, but the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue(SWC_HELPERS)} dependency declaration was not found in package.json.`);
|
|
2192
2198
|
process.exit(1);
|
|
2193
2199
|
}
|
|
2194
2200
|
defaultConfig = Object.assign(defaultConfig, {
|
|
@@ -2244,7 +2250,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2244
2250
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
2245
2251
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
2246
2252
|
const { lib: libConfigsArray, mode, root, plugins: sharedPlugins, dev, server, ...sharedRsbuildConfig } = rslibConfig;
|
|
2247
|
-
if (!Array.isArray(libConfigsArray) || 0 === libConfigsArray.length) throw new Error(`Expect "lib" field to be a non-empty array, but got: ${
|
|
2253
|
+
if (!Array.isArray(libConfigsArray) || 0 === libConfigsArray.length) throw new Error(`Expect "lib" field to be a non-empty array, but got: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(JSON.stringify(libConfigsArray))}.`);
|
|
2248
2254
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
2249
2255
|
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
2250
2256
|
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, root, sharedPlugins);
|
|
@@ -2344,9 +2350,9 @@ const clearConsole = ()=>{
|
|
|
2344
2350
|
const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
2345
2351
|
if (clear) clearConsole();
|
|
2346
2352
|
if (filePath) {
|
|
2347
|
-
const filename =
|
|
2348
|
-
logger.info(`restart because ${
|
|
2349
|
-
} else logger.info('restarting...\n');
|
|
2353
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
2354
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restart because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].yellow(filename)} is changed.\n`);
|
|
2355
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('restarting...\n');
|
|
2350
2356
|
for (const cleaner of cleaners)await cleaner();
|
|
2351
2357
|
cleaners = [];
|
|
2352
2358
|
};
|
|
@@ -2370,7 +2376,7 @@ async function build(config, options = {}) {
|
|
|
2370
2376
|
return rsbuildInstance;
|
|
2371
2377
|
}
|
|
2372
2378
|
const getEnvDir = (cwd, envDir)=>{
|
|
2373
|
-
if (envDir) return
|
|
2379
|
+
if (envDir) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(cwd, envDir);
|
|
2374
2380
|
return cwd;
|
|
2375
2381
|
};
|
|
2376
2382
|
async function init(options) {
|
|
@@ -2455,10 +2461,10 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2455
2461
|
value
|
|
2456
2462
|
]);
|
|
2457
2463
|
function runCli() {
|
|
2458
|
-
program.name('rslib').usage('<command> [options]').version("0.6.
|
|
2459
|
-
const buildCommand = program.command('build');
|
|
2460
|
-
const inspectCommand = program.command('inspect');
|
|
2461
|
-
const mfDevCommand = program.command('mf-dev');
|
|
2464
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.6.8");
|
|
2465
|
+
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2466
|
+
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2467
|
+
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
2462
2468
|
[
|
|
2463
2469
|
buildCommand,
|
|
2464
2470
|
inspectCommand,
|
|
@@ -2475,9 +2481,9 @@ function runCli() {
|
|
|
2475
2481
|
};
|
|
2476
2482
|
await cliBuild();
|
|
2477
2483
|
} catch (err) {
|
|
2478
|
-
logger.error('Failed to build.');
|
|
2479
|
-
if (err instanceof AggregateError) for (const error of err.errors)logger.error(error);
|
|
2480
|
-
else logger.error(err);
|
|
2484
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to build.');
|
|
2485
|
+
if (err instanceof AggregateError) for (const error of err.errors)__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(error);
|
|
2486
|
+
else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2481
2487
|
process.exit(1);
|
|
2482
2488
|
}
|
|
2483
2489
|
});
|
|
@@ -2491,8 +2497,8 @@ function runCli() {
|
|
|
2491
2497
|
verbose: options.verbose
|
|
2492
2498
|
});
|
|
2493
2499
|
} catch (err) {
|
|
2494
|
-
logger.error('Failed to inspect config.');
|
|
2495
|
-
logger.error(err);
|
|
2500
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to inspect config.');
|
|
2501
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2496
2502
|
process.exit(1);
|
|
2497
2503
|
}
|
|
2498
2504
|
});
|
|
@@ -2509,13 +2515,14 @@ function runCli() {
|
|
|
2509
2515
|
};
|
|
2510
2516
|
await cliMfDev();
|
|
2511
2517
|
} catch (err) {
|
|
2512
|
-
logger.error('Failed to start mf-dev.');
|
|
2513
|
-
logger.error(err);
|
|
2518
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start mf-dev.');
|
|
2519
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2514
2520
|
process.exit(1);
|
|
2515
2521
|
}
|
|
2516
2522
|
});
|
|
2517
|
-
program.parse();
|
|
2523
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2518
2524
|
}
|
|
2519
|
-
const src_version = "0.6.
|
|
2525
|
+
const src_version = "0.6.8";
|
|
2526
|
+
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2520
2527
|
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
2521
|
-
export { build, defineConfig, inspect, loadConfig,
|
|
2528
|
+
export { build, defineConfig, inspect, loadConfig, prepareCli, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ as rsbuild, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
2
3
|
import "@rsbuild/core";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
4
|
const DTS_EXTENSIONS = [
|
|
5
5
|
'd.ts',
|
|
6
6
|
'd.mts',
|
|
@@ -31,7 +31,7 @@ const CSS_EXTENSIONS = [
|
|
|
31
31
|
new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
32
32
|
new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
|
|
33
33
|
new RegExp(`\\.(${DTS_EXTENSIONS.join('|')})$`);
|
|
34
|
-
createRequire(import.meta.url);
|
|
34
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
35
35
|
const CSS_MODULE_REG = /\.module\.\w+$/i;
|
|
36
36
|
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
|
|
37
37
|
function parsePathQueryFragment(str) {
|
|
@@ -43,7 +43,7 @@ function parsePathQueryFragment(str) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
function cssConfig_isCssModulesFile(filepath, auto) {
|
|
46
|
-
const filename =
|
|
46
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath);
|
|
47
47
|
if (true === auto) return CSS_MODULE_REG.test(filename);
|
|
48
48
|
if (auto instanceof RegExp) return auto.test(filepath);
|
|
49
49
|
if ('function' == typeof auto) {
|
|
@@ -152,17 +152,17 @@ const libCssExtractLoader_pitch = function(request, _, _data) {
|
|
|
152
152
|
let resultSource = `// extracted by ${libCssExtractLoader_LOADER_NAME}`;
|
|
153
153
|
let importCssFiles = '';
|
|
154
154
|
function getRelativePath(from, to) {
|
|
155
|
-
let relativePath =
|
|
156
|
-
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !
|
|
155
|
+
let relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(from, to);
|
|
156
|
+
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(relativePath)) relativePath = `./${relativePath}`;
|
|
157
157
|
return relativePath;
|
|
158
158
|
}
|
|
159
159
|
const m = new Map();
|
|
160
160
|
for (const { content, filepath, sourceMap } of dependencies){
|
|
161
161
|
let distFilepath = getRelativePath(rootDir, filepath);
|
|
162
|
-
const ext = extname(distFilepath);
|
|
162
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(distFilepath);
|
|
163
163
|
if ('css' !== ext) distFilepath = distFilepath.replace(ext, '.css');
|
|
164
164
|
if (cssConfig_isCssModulesFile(filepath, auto)) distFilepath = distFilepath.replace(/\.module\.css/, '_module.css');
|
|
165
|
-
const cssFilename =
|
|
165
|
+
const cssFilename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(distFilepath);
|
|
166
166
|
if (content.trim()) {
|
|
167
167
|
m.get(distFilepath) ? m.set(distFilepath, `${m.get(distFilepath) + content}\n`) : m.set(distFilepath, `${content}\n`);
|
|
168
168
|
importCssFiles += '\n';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "1.3.
|
|
39
|
+
"@rsbuild/core": "1.3.14",
|
|
40
40
|
"tinyglobby": "^0.2.13",
|
|
41
|
-
"rsbuild-plugin-dts": "0.6.
|
|
41
|
+
"rsbuild-plugin-dts": "0.6.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.13.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.13.1",
|
|
45
45
|
"@types/fs-extra": "^11.0.4",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
47
47
|
"commander": "^13.1.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"memfs": "^4.17.0",
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
51
|
"prebundle": "1.3.3",
|
|
52
|
-
"rsbuild-plugin-publint": "^0.3.
|
|
53
|
-
"rslib": "npm:@rslib/core@0.6.
|
|
52
|
+
"rsbuild-plugin-publint": "^0.3.1",
|
|
53
|
+
"rslib": "npm:@rslib/core@0.6.7",
|
|
54
54
|
"rslog": "^1.2.3",
|
|
55
55
|
"tsconfck": "3.1.5",
|
|
56
56
|
"typescript": "^5.8.3",
|