@rslib/core 0.3.0 → 0.3.2
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.js +21 -21
- package/compiled/commander/index.js +30 -30
- package/compiled/picocolors/index.js +2 -2
- package/dist/entryModuleLoader.js +3 -3
- package/dist/index.js +160 -155
- package/dist/libCssExtractLoader.js +5 -5
- package/dist-types/config.d.ts +1 -0
- package/dist-types/types/config.d.ts +83 -7
- package/dist-types/utils/syntax.d.ts +1 -1
- package/package.json +11 -10
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
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
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
9
|
-
import * as
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_module__ from "module";
|
|
11
11
|
const nodeBuiltInModules = [
|
|
12
12
|
'assert',
|
|
@@ -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,23 +79,23 @@ 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 (0,
|
|
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 (!
|
|
92
|
-
|
|
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)) {
|
|
92
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`package.json does not exist in the ${rootPath} directory`);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
try {
|
|
96
|
-
return JSON.parse(
|
|
96
|
+
return JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(pkgJsonPath, 'utf8'));
|
|
97
97
|
} catch (err) {
|
|
98
|
-
|
|
98
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Failed to parse ${pkgJsonPath}, it might not be valid JSON`);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
};
|
|
@@ -127,7 +127,7 @@ function checkMFPlugin(config, sharedPlugins) {
|
|
|
127
127
|
...config.plugins || []
|
|
128
128
|
]);
|
|
129
129
|
if (!added) {
|
|
130
|
-
|
|
130
|
+
__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.`);
|
|
131
131
|
process.exit(1);
|
|
132
132
|
}
|
|
133
133
|
return added;
|
|
@@ -147,7 +147,7 @@ const windowsSlashRegex = /\\/g;
|
|
|
147
147
|
function normalizeSlash(p) {
|
|
148
148
|
return p.replace(windowsSlashRegex, '/');
|
|
149
149
|
}
|
|
150
|
-
if (process.env.DEBUG)
|
|
150
|
+
if (process.env.DEBUG) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level = 'verbose';
|
|
151
151
|
function initNodeEnv() {
|
|
152
152
|
if (!process.env.NODE_ENV) {
|
|
153
153
|
const command = process.argv[2] ?? '';
|
|
@@ -160,16 +160,14 @@ function prepareCli() {
|
|
|
160
160
|
initNodeEnv();
|
|
161
161
|
const { npm_execpath } = process.env;
|
|
162
162
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
163
|
-
|
|
163
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.3.2\n`);
|
|
164
164
|
}
|
|
165
165
|
const composeAssetConfig = (bundle, format)=>{
|
|
166
|
-
if ('esm' === format || 'cjs' === format) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
172
|
-
}
|
|
166
|
+
if ('esm' === format || 'cjs' === format) return {
|
|
167
|
+
output: {
|
|
168
|
+
dataUriLimit: 0
|
|
169
|
+
}
|
|
170
|
+
};
|
|
173
171
|
return {};
|
|
174
172
|
};
|
|
175
173
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
@@ -190,9 +188,9 @@ const JS_EXTENSIONS = [
|
|
|
190
188
|
'js',
|
|
191
189
|
'mjs',
|
|
192
190
|
'jsx',
|
|
193
|
-
'(
|
|
194
|
-
'(
|
|
195
|
-
'(
|
|
191
|
+
'(?<!\\.d\\.)ts',
|
|
192
|
+
'(?<!\\.d\\.)mts',
|
|
193
|
+
'(?<!\\.d\\.)cts',
|
|
196
194
|
'tsx',
|
|
197
195
|
'cjs',
|
|
198
196
|
'cjsx',
|
|
@@ -255,7 +253,7 @@ class LibCssExtractPlugin {
|
|
|
255
253
|
const chunkAsset = Object.keys(assets).filter((name)=>/\.css/.test(name));
|
|
256
254
|
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
257
255
|
const oldSource = old.source().toString();
|
|
258
|
-
const replaceSource = new
|
|
256
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
259
257
|
function replace(searchValue, replaceValue) {
|
|
260
258
|
let start = oldSource.indexOf(searchValue);
|
|
261
259
|
while(-1 !== start){
|
|
@@ -273,7 +271,7 @@ class LibCssExtractPlugin {
|
|
|
273
271
|
});
|
|
274
272
|
}
|
|
275
273
|
}
|
|
276
|
-
const cssConfig_require = (0,
|
|
274
|
+
const cssConfig_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
277
275
|
const RSLIB_CSS_ENTRY_FLAG = '__rslib_css__';
|
|
278
276
|
function isCssFile(filepath) {
|
|
279
277
|
return CSS_EXTENSIONS_PATTERN.test(filepath);
|
|
@@ -289,7 +287,7 @@ function parsePathQueryFragment(str) {
|
|
|
289
287
|
};
|
|
290
288
|
}
|
|
291
289
|
function isCssModulesFile(filepath, auto) {
|
|
292
|
-
const filename =
|
|
290
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath);
|
|
293
291
|
if (true === auto) return CSS_MODULE_REG.test(filename);
|
|
294
292
|
if (auto instanceof RegExp) return auto.test(filepath);
|
|
295
293
|
if ('function' == typeof auto) {
|
|
@@ -387,16 +385,16 @@ const pluginEsmRequireShim = ()=>({
|
|
|
387
385
|
setup (api) {
|
|
388
386
|
api.modifyRspackConfig((config)=>{
|
|
389
387
|
config.plugins ??= [];
|
|
390
|
-
config.plugins.push(new
|
|
388
|
+
config.plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
391
389
|
banner: requireShim,
|
|
392
|
-
stage:
|
|
390
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
|
|
393
391
|
raw: true,
|
|
394
392
|
include: /\.(js|cjs)$/
|
|
395
393
|
}));
|
|
396
394
|
});
|
|
397
395
|
}
|
|
398
396
|
});
|
|
399
|
-
const EntryChunkPlugin_require = (0,
|
|
397
|
+
const EntryChunkPlugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
400
398
|
const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
|
|
401
399
|
const EntryChunkPlugin_LOADER_NAME = 'rsbuild:lib-entry-module';
|
|
402
400
|
const matchFirstLine = (source, regex)=>{
|
|
@@ -466,7 +464,7 @@ class EntryChunkPlugin {
|
|
|
466
464
|
const chunkAsset = Object.keys(assets).filter((name)=>JS_EXTENSIONS_PATTERN.test(name));
|
|
467
465
|
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
468
466
|
const oldSource = old.source().toString();
|
|
469
|
-
const replaceSource = new
|
|
467
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
470
468
|
if (oldSource.startsWith('use strict;') || oldSource.startsWith('"use strict";')) replaceSource.replace(0, 11, `"use strict";\n${importMetaUrlShim}`);
|
|
471
469
|
else replaceSource.insert(0, importMetaUrlShim);
|
|
472
470
|
return replaceSource;
|
|
@@ -474,14 +472,14 @@ class EntryChunkPlugin {
|
|
|
474
472
|
});
|
|
475
473
|
compilation.hooks.processAssets.tap({
|
|
476
474
|
name: EntryChunkPlugin_PLUGIN_NAME,
|
|
477
|
-
stage:
|
|
475
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1
|
|
478
476
|
}, (assets)=>{
|
|
479
477
|
const chunkAsset = Object.keys(assets);
|
|
480
478
|
for (const name of chunkAsset){
|
|
481
479
|
const shebangValue = this.shebangEntries[name];
|
|
482
480
|
const reactDirectiveValue = this.reactDirectives[name];
|
|
483
481
|
if (shebangValue || reactDirectiveValue) compilation.updateAsset(name, (old)=>{
|
|
484
|
-
const replaceSource = new
|
|
482
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
485
483
|
if (shebangValue) {
|
|
486
484
|
replaceSource.insert(0, `${shebangValue}\n`);
|
|
487
485
|
this.shebangInjectedAssets.add(name);
|
|
@@ -493,7 +491,7 @@ class EntryChunkPlugin {
|
|
|
493
491
|
});
|
|
494
492
|
});
|
|
495
493
|
compiler.hooks.assetEmitted.tap(EntryChunkPlugin_PLUGIN_NAME, (file, { targetPath })=>{
|
|
496
|
-
if (this.shebangInjectedAssets.has(file)) (0,
|
|
494
|
+
if (this.shebangInjectedAssets.has(file)) (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.chmodSync)(targetPath, this.shebangChmod);
|
|
497
495
|
});
|
|
498
496
|
}
|
|
499
497
|
}
|
|
@@ -529,7 +527,7 @@ const getDefaultExtension = (options)=>{
|
|
|
529
527
|
dtsExtension
|
|
530
528
|
};
|
|
531
529
|
if (!pkgJson) {
|
|
532
|
-
|
|
530
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExtension configuration will not be applied due to read package.json failed');
|
|
533
531
|
return {
|
|
534
532
|
jsExtension,
|
|
535
533
|
dtsExtension
|
|
@@ -714,8 +712,8 @@ function transformSyntaxToBrowserslist(syntax, target) {
|
|
|
714
712
|
if (Array.isArray(syntax)) return syntax.flatMap(handleSyntaxItem);
|
|
715
713
|
return handleSyntaxItem(syntax);
|
|
716
714
|
}
|
|
717
|
-
const POSIX_SEP_RE = new RegExp('\\' +
|
|
718
|
-
const NATIVE_SEP_RE = new RegExp('\\' +
|
|
715
|
+
const POSIX_SEP_RE = new RegExp('\\' + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep, 'g');
|
|
716
|
+
const NATIVE_SEP_RE = new RegExp('\\' + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep, 'g');
|
|
719
717
|
const PATTERN_REGEX_CACHE = new Map();
|
|
720
718
|
const GLOB_ALL_PATTERN = "**/*";
|
|
721
719
|
const TS_EXTENSIONS = [
|
|
@@ -733,7 +731,7 @@ const util_JS_EXTENSIONS = [
|
|
|
733
731
|
const TSJS_EXTENSIONS = TS_EXTENSIONS.concat(util_JS_EXTENSIONS);
|
|
734
732
|
const TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
735
733
|
const TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
736
|
-
const IS_POSIX =
|
|
734
|
+
const IS_POSIX = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
737
735
|
function util_makePromise() {
|
|
738
736
|
let resolve, reject;
|
|
739
737
|
const promise = new Promise((res, rej)=>{
|
|
@@ -747,22 +745,22 @@ function util_makePromise() {
|
|
|
747
745
|
};
|
|
748
746
|
}
|
|
749
747
|
async function util_resolveTSConfigJson(filename, cache) {
|
|
750
|
-
if ('.json' !==
|
|
751
|
-
const tsconfig =
|
|
748
|
+
if ('.json' !== __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(filename)) return;
|
|
749
|
+
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename);
|
|
752
750
|
if (cache && (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename))) return tsconfig;
|
|
753
|
-
return
|
|
751
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.stat(tsconfig).then((stat)=>{
|
|
754
752
|
if (stat.isFile() || stat.isFIFO()) return tsconfig;
|
|
755
753
|
throw new Error(`${filename} exists but is not a regular file.`);
|
|
756
754
|
});
|
|
757
755
|
}
|
|
758
756
|
const util_isInNodeModules = IS_POSIX ? (dir)=>dir.includes('/node_modules/') : (dir)=>dir.match(/[/\\]node_modules[/\\]/);
|
|
759
|
-
const posix2native = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(POSIX_SEP_RE,
|
|
760
|
-
const util_native2posix = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(NATIVE_SEP_RE,
|
|
761
|
-
const resolve2posix = IS_POSIX ? (dir, filename)=>dir ?
|
|
757
|
+
const posix2native = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(POSIX_SEP_RE, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep);
|
|
758
|
+
const util_native2posix = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(NATIVE_SEP_RE, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep);
|
|
759
|
+
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)));
|
|
762
760
|
function util_resolveReferencedTSConfigFiles(result, options) {
|
|
763
|
-
const dir =
|
|
761
|
+
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile);
|
|
764
762
|
return result.tsconfig.references.map((ref)=>{
|
|
765
|
-
const refPath = ref.path.endsWith('.json') ? ref.path :
|
|
763
|
+
const refPath = ref.path.endsWith('.json') ? ref.path : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(ref.path, options?.configName ?? 'tsconfig.json');
|
|
766
764
|
return resolve2posix(dir, refPath);
|
|
767
765
|
});
|
|
768
766
|
}
|
|
@@ -776,7 +774,7 @@ function util_resolveSolutionTSConfig(filename, result) {
|
|
|
776
774
|
return result;
|
|
777
775
|
}
|
|
778
776
|
function util_isIncluded(filename, result) {
|
|
779
|
-
const dir = util_native2posix(
|
|
777
|
+
const dir = util_native2posix(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile));
|
|
780
778
|
const files = (result.tsconfig.files || []).map((file)=>resolve2posix(dir, file));
|
|
781
779
|
const absoluteFilename = resolve2posix(null, filename);
|
|
782
780
|
if (files.includes(filename)) return true;
|
|
@@ -867,13 +865,13 @@ function util_replaceTokens(tsconfig, configDir) {
|
|
|
867
865
|
return JSON.parse(JSON.stringify(tsconfig).replaceAll(/"\${configDir}/g, `"${util_native2posix(configDir)}`));
|
|
868
866
|
}
|
|
869
867
|
async function find(filename, options) {
|
|
870
|
-
let dir =
|
|
868
|
+
let dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename));
|
|
871
869
|
if (options?.ignoreNodeModules && util_isInNodeModules(dir)) return null;
|
|
872
870
|
const cache = options?.cache;
|
|
873
871
|
const configName = options?.configName ?? 'tsconfig.json';
|
|
874
872
|
if (cache?.hasConfigPath(dir, configName)) return cache.getConfigPath(dir, configName);
|
|
875
873
|
const { promise, resolve, reject } = util_makePromise();
|
|
876
|
-
if (options?.root && !
|
|
874
|
+
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);
|
|
877
875
|
findUp(dir, {
|
|
878
876
|
promise,
|
|
879
877
|
resolve,
|
|
@@ -896,13 +894,13 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
896
894
|
else resolve(cached);
|
|
897
895
|
} else cache.setConfigPath(dir, promise, configName);
|
|
898
896
|
}
|
|
899
|
-
const tsconfig =
|
|
900
|
-
|
|
897
|
+
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, options?.configName ?? 'tsconfig.json');
|
|
898
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].stat(tsconfig, (err, stats)=>{
|
|
901
899
|
if (stats && (stats.isFile() || stats.isFIFO())) resolve(tsconfig);
|
|
902
900
|
else if (err?.code !== 'ENOENT') reject(err);
|
|
903
901
|
else {
|
|
904
902
|
let parent;
|
|
905
|
-
if (root === dir || (parent =
|
|
903
|
+
if (root === dir || (parent = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(dir)) === dir) resolve(null);
|
|
906
904
|
else findUp(parent, {
|
|
907
905
|
promise,
|
|
908
906
|
resolve,
|
|
@@ -911,7 +909,7 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
911
909
|
}
|
|
912
910
|
});
|
|
913
911
|
}
|
|
914
|
-
|
|
912
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
915
913
|
function toJson(tsconfigJson) {
|
|
916
914
|
const stripped = stripDanglingComma(stripJsonComments(stripBom(tsconfigJson)));
|
|
917
915
|
if ('' === stripped.trim()) return '{}';
|
|
@@ -972,34 +970,36 @@ function stripJsonComments(jsonString) {
|
|
|
972
970
|
const escaped = isEscaped(jsonString, index);
|
|
973
971
|
if (!escaped) isInsideString = !isInsideString;
|
|
974
972
|
}
|
|
975
|
-
if (!isInsideString)
|
|
976
|
-
if (isInsideComment
|
|
977
|
-
|
|
978
|
-
isInsideComment = false;
|
|
979
|
-
result += strip(jsonString, offset, index);
|
|
980
|
-
offset = index;
|
|
981
|
-
} else if (isInsideComment === singleComment && '\n' === currentCharacter) {
|
|
982
|
-
isInsideComment = false;
|
|
983
|
-
result += strip(jsonString, offset, index);
|
|
984
|
-
offset = index;
|
|
985
|
-
} else if (isInsideComment || currentCharacter + nextCharacter !== '/*') {
|
|
986
|
-
if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
973
|
+
if (!isInsideString) {
|
|
974
|
+
if (isInsideComment || currentCharacter + nextCharacter !== '//') {
|
|
975
|
+
if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
|
|
987
976
|
index++;
|
|
988
977
|
isInsideComment = false;
|
|
989
|
-
result += strip(jsonString, offset, index
|
|
990
|
-
offset = index
|
|
978
|
+
result += strip(jsonString, offset, index);
|
|
979
|
+
offset = index;
|
|
980
|
+
} else if (isInsideComment === singleComment && '\n' === currentCharacter) {
|
|
981
|
+
isInsideComment = false;
|
|
982
|
+
result += strip(jsonString, offset, index);
|
|
983
|
+
offset = index;
|
|
984
|
+
} else if (isInsideComment || currentCharacter + nextCharacter !== '/*') {
|
|
985
|
+
if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
986
|
+
index++;
|
|
987
|
+
isInsideComment = false;
|
|
988
|
+
result += strip(jsonString, offset, index + 1);
|
|
989
|
+
offset = index + 1;
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
result += jsonString.slice(offset, index);
|
|
993
|
+
offset = index;
|
|
994
|
+
isInsideComment = multiComment;
|
|
995
|
+
index++;
|
|
991
996
|
}
|
|
992
997
|
} else {
|
|
993
998
|
result += jsonString.slice(offset, index);
|
|
994
999
|
offset = index;
|
|
995
|
-
isInsideComment =
|
|
1000
|
+
isInsideComment = singleComment;
|
|
996
1001
|
index++;
|
|
997
1002
|
}
|
|
998
|
-
} else {
|
|
999
|
-
result += jsonString.slice(offset, index);
|
|
1000
|
-
offset = index;
|
|
1001
|
-
isInsideComment = singleComment;
|
|
1002
|
-
index++;
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
1005
|
return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
|
|
@@ -1032,7 +1032,7 @@ async function parse(filename, options) {
|
|
|
1032
1032
|
parseReferences(result, options)
|
|
1033
1033
|
]);
|
|
1034
1034
|
}
|
|
1035
|
-
result.tsconfig = util_replaceTokens(result.tsconfig,
|
|
1035
|
+
result.tsconfig = util_replaceTokens(result.tsconfig, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(tsconfigFile));
|
|
1036
1036
|
resolve(util_resolveSolutionTSConfig(filename, result));
|
|
1037
1037
|
} catch (e) {
|
|
1038
1038
|
reject(e);
|
|
@@ -1053,12 +1053,12 @@ async function getParsedDeep(filename, cache, options) {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
async function parseFile(tsconfigFile, cache, skipCache) {
|
|
1055
1055
|
if (!skipCache && cache?.hasParseResult(tsconfigFile) && !cache.getParseResult(tsconfigFile)._isRootFile_) return cache.getParseResult(tsconfigFile);
|
|
1056
|
-
const promise =
|
|
1056
|
+
const promise = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.readFile(tsconfigFile, 'utf-8').then(toJson).then((json)=>{
|
|
1057
1057
|
const parsed = JSON.parse(json);
|
|
1058
1058
|
applyDefaults(parsed, tsconfigFile);
|
|
1059
1059
|
return {
|
|
1060
1060
|
tsconfigFile,
|
|
1061
|
-
tsconfig: normalizeTSConfig(parsed,
|
|
1061
|
+
tsconfig: normalizeTSConfig(parsed, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(tsconfigFile))
|
|
1062
1062
|
};
|
|
1063
1063
|
}).catch((e)=>{
|
|
1064
1064
|
throw new TSConfckParseError(`parsing ${tsconfigFile} failed: ${e}`, 'PARSE_FILE', tsconfigFile, e);
|
|
@@ -1068,7 +1068,7 @@ async function parseFile(tsconfigFile, cache, skipCache) {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
function normalizeTSConfig(tsconfig, dir) {
|
|
1070
1070
|
const baseUrl = tsconfig.compilerOptions?.baseUrl;
|
|
1071
|
-
if (baseUrl && !baseUrl.startsWith('${') && !
|
|
1071
|
+
if (baseUrl && !baseUrl.startsWith('${') && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(baseUrl)) tsconfig.compilerOptions.baseUrl = resolve2posix(dir, baseUrl);
|
|
1072
1072
|
return tsconfig;
|
|
1073
1073
|
}
|
|
1074
1074
|
async function parseReferences(result, options) {
|
|
@@ -1127,7 +1127,7 @@ function resolveExtends(extended, from) {
|
|
|
1127
1127
|
} catch (e) {
|
|
1128
1128
|
error = e;
|
|
1129
1129
|
}
|
|
1130
|
-
if ('.' !== extended[0] && !
|
|
1130
|
+
if ('.' !== extended[0] && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(extended)) try {
|
|
1131
1131
|
return req.resolve(`${extended}/tsconfig.json`);
|
|
1132
1132
|
} catch (e) {
|
|
1133
1133
|
error = e;
|
|
@@ -1147,12 +1147,10 @@ const EXTENDABLE_KEYS = [
|
|
|
1147
1147
|
function extendTSConfig(extending, extended) {
|
|
1148
1148
|
const extendingConfig = extending.tsconfig;
|
|
1149
1149
|
const extendedConfig = extended.tsconfig;
|
|
1150
|
-
const relativePath = util_native2posix(
|
|
1150
|
+
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)));
|
|
1151
1151
|
for (const key of Object.keys(extendedConfig).filter((key)=>EXTENDABLE_KEYS.includes(key)))if ('compilerOptions' === key) {
|
|
1152
1152
|
if (!extendingConfig.compilerOptions) extendingConfig.compilerOptions = {};
|
|
1153
|
-
for (const option of Object.keys(extendedConfig.compilerOptions))
|
|
1154
|
-
if (!Object.prototype.hasOwnProperty.call(extendingConfig.compilerOptions, option)) extendingConfig.compilerOptions[option] = rebaseRelative(option, extendedConfig.compilerOptions[option], relativePath);
|
|
1155
|
-
}
|
|
1153
|
+
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);
|
|
1156
1154
|
} else if (void 0 === extendingConfig[key]) {
|
|
1157
1155
|
if ('watchOptions' === key) {
|
|
1158
1156
|
extendingConfig.watchOptions = {};
|
|
@@ -1180,8 +1178,8 @@ function rebaseRelative(key, value, prependPath) {
|
|
|
1180
1178
|
return rebasePath(value, prependPath);
|
|
1181
1179
|
}
|
|
1182
1180
|
function rebasePath(value, prependPath) {
|
|
1183
|
-
if (
|
|
1184
|
-
return
|
|
1181
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(value) || value.startsWith('${configDir}')) return value;
|
|
1182
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.join(prependPath, value));
|
|
1185
1183
|
}
|
|
1186
1184
|
class TSConfckParseError extends Error {
|
|
1187
1185
|
code;
|
|
@@ -1210,12 +1208,12 @@ const DEFAULT_JSCONFIG_COMPILER_OPTIONS = {
|
|
|
1210
1208
|
noEmit: true
|
|
1211
1209
|
};
|
|
1212
1210
|
function isJSConfig(configFileName) {
|
|
1213
|
-
return 'jsconfig.json' ===
|
|
1211
|
+
return 'jsconfig.json' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(configFileName);
|
|
1214
1212
|
}
|
|
1215
1213
|
async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
1216
|
-
const tsconfigFileName = await find((0,
|
|
1214
|
+
const tsconfigFileName = await find((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, tsconfigPath), {
|
|
1217
1215
|
root,
|
|
1218
|
-
configName: (0,
|
|
1216
|
+
configName: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.basename)(tsconfigPath)
|
|
1219
1217
|
});
|
|
1220
1218
|
if (tsconfigFileName) {
|
|
1221
1219
|
const { tsconfig } = await parse(tsconfigFileName);
|
|
@@ -1226,21 +1224,21 @@ async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
|
1226
1224
|
function defineConfig(config) {
|
|
1227
1225
|
return config;
|
|
1228
1226
|
}
|
|
1229
|
-
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(
|
|
1227
|
+
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync);
|
|
1230
1228
|
const resolveConfigPath = (root, customConfig)=>{
|
|
1231
1229
|
if (customConfig) {
|
|
1232
|
-
const customConfigPath = (0,
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1230
|
+
const customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
|
|
1231
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
1232
|
+
__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`);
|
|
1235
1233
|
}
|
|
1236
|
-
const configFilePath = findConfig((0,
|
|
1234
|
+
const configFilePath = findConfig((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, DEFAULT_CONFIG_NAME));
|
|
1237
1235
|
if (configFilePath) return configFilePath;
|
|
1238
1236
|
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
1239
1237
|
};
|
|
1240
1238
|
async function loadConfig({ cwd = process.cwd(), path, envMode }) {
|
|
1241
1239
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
1242
|
-
const { content } = await (0,
|
|
1243
|
-
cwd: (0,
|
|
1240
|
+
const { content } = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadConfig)({
|
|
1241
|
+
cwd: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(configFilePath),
|
|
1244
1242
|
path: configFilePath,
|
|
1245
1243
|
envMode
|
|
1246
1244
|
});
|
|
@@ -1307,7 +1305,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1307
1305
|
};
|
|
1308
1306
|
if (contextInfo.issuer && 'commonjs' === dependencyType) {
|
|
1309
1307
|
matchUserExternals(externals, request, _callback);
|
|
1310
|
-
if (externalized)
|
|
1308
|
+
if (externalized) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request));
|
|
1311
1309
|
}
|
|
1312
1310
|
callback();
|
|
1313
1311
|
}
|
|
@@ -1322,7 +1320,7 @@ const composeAutoExternalConfig = (options)=>{
|
|
|
1322
1320
|
const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
|
|
1323
1321
|
if (false === autoExternal) return {};
|
|
1324
1322
|
if (!pkgJson) {
|
|
1325
|
-
|
|
1323
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExternal configuration will not be applied due to read package.json failed');
|
|
1326
1324
|
return {};
|
|
1327
1325
|
}
|
|
1328
1326
|
const userExternalKeys = userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];
|
|
@@ -1393,30 +1391,30 @@ function composeBannerFooterConfig(banner, footer) {
|
|
|
1393
1391
|
if (isEmptyObject(bannerConfig) && isEmptyObject(footerConfig)) return {};
|
|
1394
1392
|
const plugins = [];
|
|
1395
1393
|
if (!isEmptyObject(bannerConfig)) {
|
|
1396
|
-
if (bannerConfig.js) plugins.push(new
|
|
1394
|
+
if (bannerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1397
1395
|
banner: bannerConfig.js,
|
|
1398
|
-
stage:
|
|
1396
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1399
1397
|
raw: true,
|
|
1400
1398
|
include: /\.(js|mjs|cjs)$/
|
|
1401
1399
|
}));
|
|
1402
|
-
if (bannerConfig.css) plugins.push(new
|
|
1400
|
+
if (bannerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1403
1401
|
banner: bannerConfig.css,
|
|
1404
|
-
stage:
|
|
1402
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1405
1403
|
raw: true,
|
|
1406
1404
|
include: /\.(css)$/
|
|
1407
1405
|
}));
|
|
1408
1406
|
}
|
|
1409
1407
|
if (!isEmptyObject(footerConfig)) {
|
|
1410
|
-
if (footerConfig.js) plugins.push(new
|
|
1408
|
+
if (footerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1411
1409
|
banner: footerConfig.js,
|
|
1412
|
-
stage:
|
|
1410
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1413
1411
|
raw: true,
|
|
1414
1412
|
footer: true,
|
|
1415
1413
|
include: /\.(js|mjs|cjs)$/
|
|
1416
1414
|
}));
|
|
1417
|
-
if (footerConfig.css) plugins.push(new
|
|
1415
|
+
if (footerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1418
1416
|
banner: footerConfig.css,
|
|
1419
|
-
stage:
|
|
1417
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1420
1418
|
raw: true,
|
|
1421
1419
|
footer: true,
|
|
1422
1420
|
include: /\.(css)$/
|
|
@@ -1441,7 +1439,7 @@ function composeDecoratorsConfig(compilerOptions, version) {
|
|
|
1441
1439
|
};
|
|
1442
1440
|
}
|
|
1443
1441
|
async function createConstantRsbuildConfig() {
|
|
1444
|
-
return (0,
|
|
1442
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.defineConfig)({
|
|
1445
1443
|
dev: {
|
|
1446
1444
|
progressBar: false
|
|
1447
1445
|
},
|
|
@@ -1697,7 +1695,7 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1697
1695
|
enabledShims
|
|
1698
1696
|
};
|
|
1699
1697
|
};
|
|
1700
|
-
const composeModuleImportWarn = (request)=>`The externalized commonjs request ${
|
|
1698
|
+
const composeModuleImportWarn = (request)=>`The externalized commonjs request ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(`"${request}"`)} 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"')}.`;
|
|
1701
1699
|
const composeExternalsConfig = (format, externals)=>{
|
|
1702
1700
|
const externalsTypeMap = {
|
|
1703
1701
|
esm: 'module-import',
|
|
@@ -1738,7 +1736,7 @@ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
|
1738
1736
|
}
|
|
1739
1737
|
}
|
|
1740
1738
|
};
|
|
1741
|
-
const updatedJsExtension = 'string' == typeof updatedConfig.output?.filename?.js && updatedConfig.output?.filename?.js ? (0,
|
|
1739
|
+
const updatedJsExtension = 'string' == typeof updatedConfig.output?.filename?.js && updatedConfig.output?.filename?.js ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(updatedConfig.output.filename.js) : jsExtension;
|
|
1742
1740
|
return {
|
|
1743
1741
|
config: updatedConfig,
|
|
1744
1742
|
jsExtension: updatedJsExtension,
|
|
@@ -1783,6 +1781,7 @@ const traverseEntryQuery = (entry, callback)=>{
|
|
|
1783
1781
|
return newEntry;
|
|
1784
1782
|
};
|
|
1785
1783
|
const appendEntryQuery = (entries)=>traverseEntryQuery(entries, (item)=>`${item}?${RSLIB_ENTRY_QUERY}`);
|
|
1784
|
+
const resolveEntryPath = (entries, root)=>traverseEntryQuery(entries, (item)=>__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, item));
|
|
1786
1785
|
const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
1787
1786
|
let entries = rawEntry;
|
|
1788
1787
|
if (!entries) {
|
|
@@ -1794,21 +1793,25 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1794
1793
|
index: 'src/**'
|
|
1795
1794
|
};
|
|
1796
1795
|
}
|
|
1796
|
+
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.`);
|
|
1797
1797
|
if (false !== bundle) {
|
|
1798
|
-
|
|
1798
|
+
const entryErrorReasons = [];
|
|
1799
1799
|
traverseEntryQuery(entries, (entry)=>{
|
|
1800
|
-
const entryAbsPath =
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1800
|
+
const entryAbsPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(entry) ? entry : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, entry);
|
|
1801
|
+
const isDirLike = '' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(entryAbsPath);
|
|
1802
|
+
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.`;
|
|
1803
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(entryAbsPath)) {
|
|
1804
|
+
const stats = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].statSync(entryAbsPath);
|
|
1805
|
+
if (!stats.isFile()) entryErrorReasons.push(dirError);
|
|
1806
|
+
} else if (isDirLike) entryErrorReasons.push(dirError);
|
|
1807
|
+
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.`);
|
|
1805
1808
|
return entry;
|
|
1806
1809
|
});
|
|
1807
|
-
if (
|
|
1810
|
+
if (entryErrorReasons.length) throw new AggregateError(entryErrorReasons.map((reason)=>new Error(reason)));
|
|
1808
1811
|
return {
|
|
1809
1812
|
entryConfig: {
|
|
1810
1813
|
source: {
|
|
1811
|
-
entry: appendEntryQuery(entries)
|
|
1814
|
+
entry: appendEntryQuery(resolveEntryPath(entries, root))
|
|
1812
1815
|
}
|
|
1813
1816
|
},
|
|
1814
1817
|
lcp: null
|
|
@@ -1831,14 +1834,14 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1831
1834
|
const lcp = await calcLongestCommonPath(resolvedEntryFiles);
|
|
1832
1835
|
const outBase = null === lcp ? root : lcp;
|
|
1833
1836
|
function getEntryName(file) {
|
|
1834
|
-
const { dir, name } =
|
|
1835
|
-
const entryFileName =
|
|
1837
|
+
const { dir, name } = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(outBase, file));
|
|
1838
|
+
const entryFileName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, name);
|
|
1836
1839
|
if (isCssGlobalFile(file, cssModulesAuto)) return `${RSLIB_CSS_ENTRY_FLAG}/${entryFileName}`;
|
|
1837
1840
|
return entryFileName;
|
|
1838
1841
|
}
|
|
1839
1842
|
for (const file of resolvedEntryFiles){
|
|
1840
1843
|
const entryName = getEntryName(file);
|
|
1841
|
-
if (resolvedEntries[entryName])
|
|
1844
|
+
if (resolvedEntries[entryName]) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`duplicate entry: ${entryName}, this may lead to the incorrect output, please rename the file`);
|
|
1842
1845
|
resolvedEntries[entryName] = file;
|
|
1843
1846
|
}
|
|
1844
1847
|
}
|
|
@@ -1870,7 +1873,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
|
1870
1873
|
lcp
|
|
1871
1874
|
};
|
|
1872
1875
|
};
|
|
1873
|
-
const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto, bundle)=>{
|
|
1876
|
+
const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto, bundle, rootPath)=>{
|
|
1874
1877
|
if (bundle) return {
|
|
1875
1878
|
config: {}
|
|
1876
1879
|
};
|
|
@@ -1896,14 +1899,15 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1896
1899
|
try {
|
|
1897
1900
|
let resolvedRequest = request;
|
|
1898
1901
|
resolvedRequest = await resolver(context, resolvedRequest);
|
|
1899
|
-
|
|
1900
|
-
|
|
1902
|
+
const isSubpath = resolvedRequest.startsWith(rootPath + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep);
|
|
1903
|
+
if (isSubpath) {
|
|
1904
|
+
resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(issuer), resolvedRequest));
|
|
1901
1905
|
if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
|
|
1902
1906
|
return resolvedRequest;
|
|
1903
1907
|
}
|
|
1904
1908
|
return;
|
|
1905
1909
|
} catch (e) {
|
|
1906
|
-
|
|
1910
|
+
__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.`);
|
|
1907
1911
|
return request;
|
|
1908
1912
|
}
|
|
1909
1913
|
}
|
|
@@ -1917,7 +1921,7 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1917
1921
|
resolvedRequest = redirectedPath;
|
|
1918
1922
|
}
|
|
1919
1923
|
if (jsRedirectExtension && resolvedRequest.startsWith('.')) {
|
|
1920
|
-
const ext = (0,
|
|
1924
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(resolvedRequest);
|
|
1921
1925
|
if (ext) {
|
|
1922
1926
|
if (!JS_EXTENSIONS_PATTERN.test(resolvedRequest)) return callback();
|
|
1923
1927
|
resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
@@ -2013,7 +2017,7 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
2013
2017
|
...Object.keys(pkgJson?.devDependencies ?? [])
|
|
2014
2018
|
];
|
|
2015
2019
|
if (!deps.includes(SWC_HELPERS)) {
|
|
2016
|
-
|
|
2020
|
+
__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.`);
|
|
2017
2021
|
process.exit(1);
|
|
2018
2022
|
}
|
|
2019
2023
|
defaultConfig = Object.assign(defaultConfig, {
|
|
@@ -2042,7 +2046,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2042
2046
|
const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
|
|
2043
2047
|
const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
2044
2048
|
const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(config, autoExtension, pkgJson);
|
|
2045
|
-
const { config: bundlelessExternalConfig } = composeBundlelessExternalConfig(jsExtension, redirect, cssModulesAuto, bundle);
|
|
2049
|
+
const { config: bundlelessExternalConfig } = composeBundlelessExternalConfig(jsExtension, redirect, cssModulesAuto, bundle, rootPath);
|
|
2046
2050
|
const { config: targetConfig, externalsConfig: targetExternalsConfig, target } = composeTargetConfig(config.output?.target, format);
|
|
2047
2051
|
const syntaxConfig = composeSyntaxConfig(target, config?.syntax);
|
|
2048
2052
|
const autoExternalConfig = composeAutoExternalConfig({
|
|
@@ -2064,14 +2068,14 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2064
2068
|
const minifyConfig = composeMinifyConfig(config);
|
|
2065
2069
|
const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
|
|
2066
2070
|
const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
|
|
2067
|
-
return (0,
|
|
2071
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(formatConfig, shimsConfig, syntaxConfig, externalHelpersConfig, autoExtensionConfig, targetConfig, externalsWarnConfig, userExternalsConfig, autoExternalConfig, targetExternalsConfig, bundlelessExternalConfig, entryConfig, cssConfig, assetConfig, entryChunkConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig);
|
|
2068
2072
|
}
|
|
2069
2073
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
2070
2074
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
2071
2075
|
const { lib: libConfigsArray, mode, root, plugins: sharedPlugins, dev, server, ...sharedRsbuildConfig } = rslibConfig;
|
|
2072
2076
|
if (!libConfigsArray) throw new Error(`Expect lib field to be an array, but got ${libConfigsArray}.`);
|
|
2073
2077
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
2074
|
-
const userConfig = (0,
|
|
2078
|
+
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
2075
2079
|
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, root, sharedPlugins);
|
|
2076
2080
|
userConfig.source ??= {};
|
|
2077
2081
|
userConfig.source.entry = {};
|
|
@@ -2079,7 +2083,7 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
2079
2083
|
delete userConfig.output.externals;
|
|
2080
2084
|
const config = {
|
|
2081
2085
|
format: libConfig.format,
|
|
2082
|
-
config: (0,
|
|
2086
|
+
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
2083
2087
|
id: true,
|
|
2084
2088
|
bundle: true,
|
|
2085
2089
|
format: true,
|
|
@@ -2168,15 +2172,15 @@ const clearConsole = ()=>{
|
|
|
2168
2172
|
const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
2169
2173
|
if (clear) clearConsole();
|
|
2170
2174
|
if (filePath) {
|
|
2171
|
-
const filename =
|
|
2172
|
-
|
|
2173
|
-
} else
|
|
2175
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
2176
|
+
__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`);
|
|
2177
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('Restarting...\n');
|
|
2174
2178
|
for (const cleaner of cleaners)await cleaner();
|
|
2175
2179
|
cleaners = [];
|
|
2176
2180
|
};
|
|
2177
2181
|
async function build(config, options = {}) {
|
|
2178
2182
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2179
|
-
const rsbuildInstance = await (0,
|
|
2183
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2180
2184
|
rsbuildConfig: {
|
|
2181
2185
|
mode: 'production',
|
|
2182
2186
|
root: config.root,
|
|
@@ -2194,13 +2198,13 @@ async function build(config, options = {}) {
|
|
|
2194
2198
|
return rsbuildInstance;
|
|
2195
2199
|
}
|
|
2196
2200
|
const getEnvDir = (cwd, envDir)=>{
|
|
2197
|
-
if (envDir) return
|
|
2201
|
+
if (envDir) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(cwd, envDir);
|
|
2198
2202
|
return cwd;
|
|
2199
2203
|
};
|
|
2200
2204
|
async function init(options) {
|
|
2201
2205
|
const cwd = process.cwd();
|
|
2202
2206
|
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
2203
|
-
const envs = (0,
|
|
2207
|
+
const envs = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadEnv)({
|
|
2204
2208
|
cwd: getEnvDir(root, options.envDir),
|
|
2205
2209
|
mode: options.envMode
|
|
2206
2210
|
});
|
|
@@ -2227,7 +2231,7 @@ async function init(options) {
|
|
|
2227
2231
|
}
|
|
2228
2232
|
async function inspect(config, options = {}) {
|
|
2229
2233
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2230
|
-
const rsbuildInstance = await (0,
|
|
2234
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2231
2235
|
rsbuildConfig: {
|
|
2232
2236
|
mode: 'production',
|
|
2233
2237
|
root: config.root,
|
|
@@ -2258,7 +2262,7 @@ async function initMFRsbuild(config, options = {}) {
|
|
|
2258
2262
|
}).map((env)=>env.id);
|
|
2259
2263
|
if (!selectedEnvironmentIds.length) throw new Error(`No mf format found in ${options.lib ? `libs ${options.lib.map((lib)=>`"${lib}"`).join(', ')}` : 'your config'}, please check your config to ensure that the mf format is enabled correctly.`);
|
|
2260
2264
|
const selectedEnvironments = pruneEnvironments(environments, selectedEnvironmentIds);
|
|
2261
|
-
const rsbuildInstance = await (0,
|
|
2265
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2262
2266
|
rsbuildConfig: {
|
|
2263
2267
|
mode: 'development',
|
|
2264
2268
|
root: config.root,
|
|
@@ -2279,10 +2283,10 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2279
2283
|
value
|
|
2280
2284
|
]);
|
|
2281
2285
|
function runCli() {
|
|
2282
|
-
|
|
2283
|
-
const buildCommand =
|
|
2284
|
-
const inspectCommand =
|
|
2285
|
-
const mfDevCommand =
|
|
2286
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.3.2");
|
|
2287
|
+
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2288
|
+
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2289
|
+
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
2286
2290
|
[
|
|
2287
2291
|
buildCommand,
|
|
2288
2292
|
inspectCommand,
|
|
@@ -2299,8 +2303,9 @@ function runCli() {
|
|
|
2299
2303
|
};
|
|
2300
2304
|
await cliBuild();
|
|
2301
2305
|
} catch (err) {
|
|
2302
|
-
|
|
2303
|
-
|
|
2306
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to build.');
|
|
2307
|
+
if (err instanceof AggregateError) for (const error of err.errors)__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(error);
|
|
2308
|
+
else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2304
2309
|
process.exit(1);
|
|
2305
2310
|
}
|
|
2306
2311
|
});
|
|
@@ -2314,8 +2319,8 @@ function runCli() {
|
|
|
2314
2319
|
verbose: options.verbose
|
|
2315
2320
|
});
|
|
2316
2321
|
} catch (err) {
|
|
2317
|
-
|
|
2318
|
-
|
|
2322
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to inspect config.');
|
|
2323
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2319
2324
|
process.exit(1);
|
|
2320
2325
|
}
|
|
2321
2326
|
});
|
|
@@ -2332,13 +2337,13 @@ function runCli() {
|
|
|
2332
2337
|
};
|
|
2333
2338
|
await cliMfDev();
|
|
2334
2339
|
} catch (err) {
|
|
2335
|
-
|
|
2336
|
-
|
|
2340
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start mf-dev.');
|
|
2341
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2337
2342
|
process.exit(1);
|
|
2338
2343
|
}
|
|
2339
2344
|
});
|
|
2340
|
-
|
|
2345
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2341
2346
|
}
|
|
2342
|
-
const src_rslib_entry_version = "0.3.
|
|
2343
|
-
var __webpack_exports__logger =
|
|
2347
|
+
const src_rslib_entry_version = "0.3.2";
|
|
2348
|
+
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2344
2349
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|