@rslib/core 0.2.2 → 0.3.1
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/commander/index.d.ts +88 -12
- package/compiled/commander/index.js +511 -151
- package/compiled/commander/package.json +1 -1
- package/dist/entryModuleLoader.js +3 -3
- package/dist/index.js +290 -215
- package/dist/libCssExtractLoader.js +5 -5
- package/dist-types/config.d.ts +3 -2
- package/dist-types/constant.d.ts +0 -3
- package/dist-types/css/cssConfig.d.ts +1 -1
- package/dist-types/plugins/EntryChunkPlugin.d.ts +2 -1
- package/dist-types/types/config.d.ts +95 -7
- package/package.json +8 -8
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.1\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,14 +188,14 @@ const JS_EXTENSIONS = [
|
|
|
190
188
|
'js',
|
|
191
189
|
'mjs',
|
|
192
190
|
'jsx',
|
|
193
|
-
'ts',
|
|
194
|
-
'mts',
|
|
191
|
+
'(?<!\\.d\\.)ts',
|
|
192
|
+
'(?<!\\.d\\.)mts',
|
|
193
|
+
'(?<!\\.d\\.)cts',
|
|
195
194
|
'tsx',
|
|
196
195
|
'cjs',
|
|
197
196
|
'cjsx',
|
|
198
197
|
'mjsx',
|
|
199
198
|
'mtsx',
|
|
200
|
-
'cts',
|
|
201
199
|
'ctsx'
|
|
202
200
|
];
|
|
203
201
|
const CSS_EXTENSIONS = [
|
|
@@ -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) {
|
|
@@ -304,15 +302,20 @@ function isCssGlobalFile(filepath, auto) {
|
|
|
304
302
|
const isCssModules = isCssModulesFile(filepath, auto);
|
|
305
303
|
return !isCssModules;
|
|
306
304
|
}
|
|
307
|
-
function cssExternalHandler(request, callback, jsExtension, auto,
|
|
308
|
-
const isCssModulesRequest = isCssModulesFile(request, auto);
|
|
305
|
+
async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectPath) {
|
|
309
306
|
if (/compiled\/css-loader\//.test(request)) return callback();
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
307
|
+
let resolvedRequest = request;
|
|
308
|
+
if (styleRedirectPath) {
|
|
309
|
+
const resolved = await redirectPath(resolvedRequest);
|
|
310
|
+
if (resolved) resolvedRequest = resolved;
|
|
314
311
|
}
|
|
315
|
-
return false;
|
|
312
|
+
if (!isCssFile(resolvedRequest)) return false;
|
|
313
|
+
if (styleRedirectExtension) {
|
|
314
|
+
const isCssModulesRequest = isCssModulesFile(resolvedRequest, auto);
|
|
315
|
+
if (isCssModulesRequest) return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, jsExtension));
|
|
316
|
+
return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, '.css'));
|
|
317
|
+
}
|
|
318
|
+
return callback(void 0, resolvedRequest);
|
|
316
319
|
}
|
|
317
320
|
const PLUGIN_NAME = 'rsbuild:lib-css';
|
|
318
321
|
const pluginLibCss = (rootDir)=>({
|
|
@@ -382,16 +385,16 @@ const pluginEsmRequireShim = ()=>({
|
|
|
382
385
|
setup (api) {
|
|
383
386
|
api.modifyRspackConfig((config)=>{
|
|
384
387
|
config.plugins ??= [];
|
|
385
|
-
config.plugins.push(new
|
|
388
|
+
config.plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
386
389
|
banner: requireShim,
|
|
387
|
-
stage:
|
|
390
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
|
|
388
391
|
raw: true,
|
|
389
392
|
include: /\.(js|cjs)$/
|
|
390
393
|
}));
|
|
391
394
|
});
|
|
392
395
|
}
|
|
393
396
|
});
|
|
394
|
-
const EntryChunkPlugin_require = (0,
|
|
397
|
+
const EntryChunkPlugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
395
398
|
const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
|
|
396
399
|
const EntryChunkPlugin_LOADER_NAME = 'rsbuild:lib-entry-module';
|
|
397
400
|
const matchFirstLine = (source, regex)=>{
|
|
@@ -407,19 +410,28 @@ class EntryChunkPlugin {
|
|
|
407
410
|
shebangEntries = {};
|
|
408
411
|
shebangInjectedAssets = new Set();
|
|
409
412
|
enabledImportMetaUrlShim;
|
|
410
|
-
|
|
413
|
+
contextToWatch = null;
|
|
414
|
+
contextWatched = false;
|
|
415
|
+
constructor({ enabledImportMetaUrlShim = true, contextToWatch }){
|
|
411
416
|
this.enabledImportMetaUrlShim = enabledImportMetaUrlShim;
|
|
417
|
+
this.contextToWatch = contextToWatch;
|
|
412
418
|
}
|
|
413
419
|
apply(compiler) {
|
|
414
|
-
compiler.hooks.
|
|
420
|
+
compiler.hooks.afterCompile.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
421
|
+
if (this.contextWatched || null === this.contextToWatch) return;
|
|
422
|
+
const contextDep = compilation.contextDependencies;
|
|
423
|
+
contextDep.add(this.contextToWatch);
|
|
424
|
+
this.contextWatched = true;
|
|
425
|
+
});
|
|
426
|
+
compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
427
|
+
const entries = {};
|
|
428
|
+
for (const [key, value] of compilation.entries){
|
|
429
|
+
const firstDep = value.dependencies[0];
|
|
430
|
+
if (firstDep?.request) entries[key] = firstDep.request;
|
|
431
|
+
}
|
|
415
432
|
for(const name in entries){
|
|
416
|
-
const
|
|
417
|
-
if (!
|
|
418
|
-
let first;
|
|
419
|
-
if (Array.isArray(entry)) first = entry[0];
|
|
420
|
-
else if (Array.isArray(entry.import)) first = entry.import[0];
|
|
421
|
-
else if ('string' == typeof entry) first = entry;
|
|
422
|
-
if ('string' != typeof first) continue;
|
|
433
|
+
const first = entries[name];
|
|
434
|
+
if (!first) continue;
|
|
423
435
|
const filename = first.split('?')[0];
|
|
424
436
|
const isJs = JS_EXTENSIONS_PATTERN.test(filename);
|
|
425
437
|
if (!isJs) continue;
|
|
@@ -434,7 +446,7 @@ class EntryChunkPlugin {
|
|
|
434
446
|
if (reactDirective) this.reactDirectives[name] = reactDirective;
|
|
435
447
|
}
|
|
436
448
|
});
|
|
437
|
-
compiler.hooks.
|
|
449
|
+
compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
438
450
|
compilation.hooks.chunkAsset.tap(EntryChunkPlugin_PLUGIN_NAME, (chunk, filename)=>{
|
|
439
451
|
const isJs = JS_EXTENSIONS_PATTERN.test(filename);
|
|
440
452
|
if (!isJs) return;
|
|
@@ -452,7 +464,7 @@ class EntryChunkPlugin {
|
|
|
452
464
|
const chunkAsset = Object.keys(assets).filter((name)=>JS_EXTENSIONS_PATTERN.test(name));
|
|
453
465
|
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
454
466
|
const oldSource = old.source().toString();
|
|
455
|
-
const replaceSource = new
|
|
467
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
456
468
|
if (oldSource.startsWith('use strict;') || oldSource.startsWith('"use strict";')) replaceSource.replace(0, 11, `"use strict";\n${importMetaUrlShim}`);
|
|
457
469
|
else replaceSource.insert(0, importMetaUrlShim);
|
|
458
470
|
return replaceSource;
|
|
@@ -460,14 +472,14 @@ class EntryChunkPlugin {
|
|
|
460
472
|
});
|
|
461
473
|
compilation.hooks.processAssets.tap({
|
|
462
474
|
name: EntryChunkPlugin_PLUGIN_NAME,
|
|
463
|
-
stage:
|
|
475
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1
|
|
464
476
|
}, (assets)=>{
|
|
465
477
|
const chunkAsset = Object.keys(assets);
|
|
466
478
|
for (const name of chunkAsset){
|
|
467
479
|
const shebangValue = this.shebangEntries[name];
|
|
468
480
|
const reactDirectiveValue = this.reactDirectives[name];
|
|
469
481
|
if (shebangValue || reactDirectiveValue) compilation.updateAsset(name, (old)=>{
|
|
470
|
-
const replaceSource = new
|
|
482
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
471
483
|
if (shebangValue) {
|
|
472
484
|
replaceSource.insert(0, `${shebangValue}\n`);
|
|
473
485
|
this.shebangInjectedAssets.add(name);
|
|
@@ -479,7 +491,7 @@ class EntryChunkPlugin {
|
|
|
479
491
|
});
|
|
480
492
|
});
|
|
481
493
|
compiler.hooks.assetEmitted.tap(EntryChunkPlugin_PLUGIN_NAME, (file, { targetPath })=>{
|
|
482
|
-
if (this.shebangInjectedAssets.has(file)) (0,
|
|
494
|
+
if (this.shebangInjectedAssets.has(file)) (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.chmodSync)(targetPath, this.shebangChmod);
|
|
483
495
|
});
|
|
484
496
|
}
|
|
485
497
|
}
|
|
@@ -491,7 +503,7 @@ const entryModuleLoaderRsbuildPlugin = ()=>({
|
|
|
491
503
|
});
|
|
492
504
|
}
|
|
493
505
|
});
|
|
494
|
-
const composeEntryChunkConfig = ({ enabledImportMetaUrlShim })=>({
|
|
506
|
+
const composeEntryChunkConfig = ({ enabledImportMetaUrlShim, contextToWatch = null })=>({
|
|
495
507
|
plugins: [
|
|
496
508
|
entryModuleLoaderRsbuildPlugin()
|
|
497
509
|
],
|
|
@@ -499,7 +511,8 @@ const composeEntryChunkConfig = ({ enabledImportMetaUrlShim })=>({
|
|
|
499
511
|
rspack: {
|
|
500
512
|
plugins: [
|
|
501
513
|
new EntryChunkPlugin({
|
|
502
|
-
enabledImportMetaUrlShim
|
|
514
|
+
enabledImportMetaUrlShim,
|
|
515
|
+
contextToWatch
|
|
503
516
|
})
|
|
504
517
|
]
|
|
505
518
|
}
|
|
@@ -514,7 +527,7 @@ const getDefaultExtension = (options)=>{
|
|
|
514
527
|
dtsExtension
|
|
515
528
|
};
|
|
516
529
|
if (!pkgJson) {
|
|
517
|
-
|
|
530
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExtension configuration will not be applied due to read package.json failed');
|
|
518
531
|
return {
|
|
519
532
|
jsExtension,
|
|
520
533
|
dtsExtension
|
|
@@ -699,8 +712,8 @@ function transformSyntaxToBrowserslist(syntax, target) {
|
|
|
699
712
|
if (Array.isArray(syntax)) return syntax.flatMap(handleSyntaxItem);
|
|
700
713
|
return handleSyntaxItem(syntax);
|
|
701
714
|
}
|
|
702
|
-
const POSIX_SEP_RE = new RegExp('\\' +
|
|
703
|
-
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');
|
|
704
717
|
const PATTERN_REGEX_CACHE = new Map();
|
|
705
718
|
const GLOB_ALL_PATTERN = "**/*";
|
|
706
719
|
const TS_EXTENSIONS = [
|
|
@@ -718,7 +731,7 @@ const util_JS_EXTENSIONS = [
|
|
|
718
731
|
const TSJS_EXTENSIONS = TS_EXTENSIONS.concat(util_JS_EXTENSIONS);
|
|
719
732
|
const TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
720
733
|
const TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
721
|
-
const IS_POSIX =
|
|
734
|
+
const IS_POSIX = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
722
735
|
function util_makePromise() {
|
|
723
736
|
let resolve, reject;
|
|
724
737
|
const promise = new Promise((res, rej)=>{
|
|
@@ -732,22 +745,22 @@ function util_makePromise() {
|
|
|
732
745
|
};
|
|
733
746
|
}
|
|
734
747
|
async function util_resolveTSConfigJson(filename, cache) {
|
|
735
|
-
if ('.json' !==
|
|
736
|
-
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);
|
|
737
750
|
if (cache && (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename))) return tsconfig;
|
|
738
|
-
return
|
|
751
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.stat(tsconfig).then((stat)=>{
|
|
739
752
|
if (stat.isFile() || stat.isFIFO()) return tsconfig;
|
|
740
753
|
throw new Error(`${filename} exists but is not a regular file.`);
|
|
741
754
|
});
|
|
742
755
|
}
|
|
743
756
|
const util_isInNodeModules = IS_POSIX ? (dir)=>dir.includes('/node_modules/') : (dir)=>dir.match(/[/\\]node_modules[/\\]/);
|
|
744
|
-
const posix2native = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(POSIX_SEP_RE,
|
|
745
|
-
const util_native2posix = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(NATIVE_SEP_RE,
|
|
746
|
-
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)));
|
|
747
760
|
function util_resolveReferencedTSConfigFiles(result, options) {
|
|
748
|
-
const dir =
|
|
761
|
+
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile);
|
|
749
762
|
return result.tsconfig.references.map((ref)=>{
|
|
750
|
-
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');
|
|
751
764
|
return resolve2posix(dir, refPath);
|
|
752
765
|
});
|
|
753
766
|
}
|
|
@@ -761,7 +774,7 @@ function util_resolveSolutionTSConfig(filename, result) {
|
|
|
761
774
|
return result;
|
|
762
775
|
}
|
|
763
776
|
function util_isIncluded(filename, result) {
|
|
764
|
-
const dir = util_native2posix(
|
|
777
|
+
const dir = util_native2posix(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile));
|
|
765
778
|
const files = (result.tsconfig.files || []).map((file)=>resolve2posix(dir, file));
|
|
766
779
|
const absoluteFilename = resolve2posix(null, filename);
|
|
767
780
|
if (files.includes(filename)) return true;
|
|
@@ -852,13 +865,13 @@ function util_replaceTokens(tsconfig, configDir) {
|
|
|
852
865
|
return JSON.parse(JSON.stringify(tsconfig).replaceAll(/"\${configDir}/g, `"${util_native2posix(configDir)}`));
|
|
853
866
|
}
|
|
854
867
|
async function find(filename, options) {
|
|
855
|
-
let dir =
|
|
868
|
+
let dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename));
|
|
856
869
|
if (options?.ignoreNodeModules && util_isInNodeModules(dir)) return null;
|
|
857
870
|
const cache = options?.cache;
|
|
858
871
|
const configName = options?.configName ?? 'tsconfig.json';
|
|
859
872
|
if (cache?.hasConfigPath(dir, configName)) return cache.getConfigPath(dir, configName);
|
|
860
873
|
const { promise, resolve, reject } = util_makePromise();
|
|
861
|
-
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);
|
|
862
875
|
findUp(dir, {
|
|
863
876
|
promise,
|
|
864
877
|
resolve,
|
|
@@ -881,13 +894,13 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
881
894
|
else resolve(cached);
|
|
882
895
|
} else cache.setConfigPath(dir, promise, configName);
|
|
883
896
|
}
|
|
884
|
-
const tsconfig =
|
|
885
|
-
|
|
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)=>{
|
|
886
899
|
if (stats && (stats.isFile() || stats.isFIFO())) resolve(tsconfig);
|
|
887
900
|
else if (err?.code !== 'ENOENT') reject(err);
|
|
888
901
|
else {
|
|
889
902
|
let parent;
|
|
890
|
-
if (root === dir || (parent =
|
|
903
|
+
if (root === dir || (parent = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(dir)) === dir) resolve(null);
|
|
891
904
|
else findUp(parent, {
|
|
892
905
|
promise,
|
|
893
906
|
resolve,
|
|
@@ -896,7 +909,7 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
896
909
|
}
|
|
897
910
|
});
|
|
898
911
|
}
|
|
899
|
-
|
|
912
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
900
913
|
function toJson(tsconfigJson) {
|
|
901
914
|
const stripped = stripDanglingComma(stripJsonComments(stripBom(tsconfigJson)));
|
|
902
915
|
if ('' === stripped.trim()) return '{}';
|
|
@@ -957,34 +970,36 @@ function stripJsonComments(jsonString) {
|
|
|
957
970
|
const escaped = isEscaped(jsonString, index);
|
|
958
971
|
if (!escaped) isInsideString = !isInsideString;
|
|
959
972
|
}
|
|
960
|
-
if (!isInsideString)
|
|
961
|
-
if (isInsideComment
|
|
962
|
-
|
|
963
|
-
isInsideComment = false;
|
|
964
|
-
result += strip(jsonString, offset, index);
|
|
965
|
-
offset = index;
|
|
966
|
-
} else if (isInsideComment === singleComment && '\n' === currentCharacter) {
|
|
967
|
-
isInsideComment = false;
|
|
968
|
-
result += strip(jsonString, offset, index);
|
|
969
|
-
offset = index;
|
|
970
|
-
} else if (isInsideComment || currentCharacter + nextCharacter !== '/*') {
|
|
971
|
-
if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
973
|
+
if (!isInsideString) {
|
|
974
|
+
if (isInsideComment || currentCharacter + nextCharacter !== '//') {
|
|
975
|
+
if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
|
|
972
976
|
index++;
|
|
973
977
|
isInsideComment = false;
|
|
974
|
-
result += strip(jsonString, offset, index
|
|
975
|
-
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++;
|
|
976
996
|
}
|
|
977
997
|
} else {
|
|
978
998
|
result += jsonString.slice(offset, index);
|
|
979
999
|
offset = index;
|
|
980
|
-
isInsideComment =
|
|
1000
|
+
isInsideComment = singleComment;
|
|
981
1001
|
index++;
|
|
982
1002
|
}
|
|
983
|
-
} else {
|
|
984
|
-
result += jsonString.slice(offset, index);
|
|
985
|
-
offset = index;
|
|
986
|
-
isInsideComment = singleComment;
|
|
987
|
-
index++;
|
|
988
1003
|
}
|
|
989
1004
|
}
|
|
990
1005
|
return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
|
|
@@ -1017,7 +1032,7 @@ async function parse(filename, options) {
|
|
|
1017
1032
|
parseReferences(result, options)
|
|
1018
1033
|
]);
|
|
1019
1034
|
}
|
|
1020
|
-
result.tsconfig = util_replaceTokens(result.tsconfig,
|
|
1035
|
+
result.tsconfig = util_replaceTokens(result.tsconfig, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(tsconfigFile));
|
|
1021
1036
|
resolve(util_resolveSolutionTSConfig(filename, result));
|
|
1022
1037
|
} catch (e) {
|
|
1023
1038
|
reject(e);
|
|
@@ -1038,12 +1053,12 @@ async function getParsedDeep(filename, cache, options) {
|
|
|
1038
1053
|
}
|
|
1039
1054
|
async function parseFile(tsconfigFile, cache, skipCache) {
|
|
1040
1055
|
if (!skipCache && cache?.hasParseResult(tsconfigFile) && !cache.getParseResult(tsconfigFile)._isRootFile_) return cache.getParseResult(tsconfigFile);
|
|
1041
|
-
const promise =
|
|
1056
|
+
const promise = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.readFile(tsconfigFile, 'utf-8').then(toJson).then((json)=>{
|
|
1042
1057
|
const parsed = JSON.parse(json);
|
|
1043
1058
|
applyDefaults(parsed, tsconfigFile);
|
|
1044
1059
|
return {
|
|
1045
1060
|
tsconfigFile,
|
|
1046
|
-
tsconfig: normalizeTSConfig(parsed,
|
|
1061
|
+
tsconfig: normalizeTSConfig(parsed, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(tsconfigFile))
|
|
1047
1062
|
};
|
|
1048
1063
|
}).catch((e)=>{
|
|
1049
1064
|
throw new TSConfckParseError(`parsing ${tsconfigFile} failed: ${e}`, 'PARSE_FILE', tsconfigFile, e);
|
|
@@ -1053,7 +1068,7 @@ async function parseFile(tsconfigFile, cache, skipCache) {
|
|
|
1053
1068
|
}
|
|
1054
1069
|
function normalizeTSConfig(tsconfig, dir) {
|
|
1055
1070
|
const baseUrl = tsconfig.compilerOptions?.baseUrl;
|
|
1056
|
-
if (baseUrl && !baseUrl.startsWith('${') && !
|
|
1071
|
+
if (baseUrl && !baseUrl.startsWith('${') && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(baseUrl)) tsconfig.compilerOptions.baseUrl = resolve2posix(dir, baseUrl);
|
|
1057
1072
|
return tsconfig;
|
|
1058
1073
|
}
|
|
1059
1074
|
async function parseReferences(result, options) {
|
|
@@ -1112,7 +1127,7 @@ function resolveExtends(extended, from) {
|
|
|
1112
1127
|
} catch (e) {
|
|
1113
1128
|
error = e;
|
|
1114
1129
|
}
|
|
1115
|
-
if ('.' !== extended[0] && !
|
|
1130
|
+
if ('.' !== extended[0] && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(extended)) try {
|
|
1116
1131
|
return req.resolve(`${extended}/tsconfig.json`);
|
|
1117
1132
|
} catch (e) {
|
|
1118
1133
|
error = e;
|
|
@@ -1132,12 +1147,10 @@ const EXTENDABLE_KEYS = [
|
|
|
1132
1147
|
function extendTSConfig(extending, extended) {
|
|
1133
1148
|
const extendingConfig = extending.tsconfig;
|
|
1134
1149
|
const extendedConfig = extended.tsconfig;
|
|
1135
|
-
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)));
|
|
1136
1151
|
for (const key of Object.keys(extendedConfig).filter((key)=>EXTENDABLE_KEYS.includes(key)))if ('compilerOptions' === key) {
|
|
1137
1152
|
if (!extendingConfig.compilerOptions) extendingConfig.compilerOptions = {};
|
|
1138
|
-
for (const option of Object.keys(extendedConfig.compilerOptions))
|
|
1139
|
-
if (!Object.prototype.hasOwnProperty.call(extendingConfig.compilerOptions, option)) extendingConfig.compilerOptions[option] = rebaseRelative(option, extendedConfig.compilerOptions[option], relativePath);
|
|
1140
|
-
}
|
|
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);
|
|
1141
1154
|
} else if (void 0 === extendingConfig[key]) {
|
|
1142
1155
|
if ('watchOptions' === key) {
|
|
1143
1156
|
extendingConfig.watchOptions = {};
|
|
@@ -1165,8 +1178,8 @@ function rebaseRelative(key, value, prependPath) {
|
|
|
1165
1178
|
return rebasePath(value, prependPath);
|
|
1166
1179
|
}
|
|
1167
1180
|
function rebasePath(value, prependPath) {
|
|
1168
|
-
if (
|
|
1169
|
-
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));
|
|
1170
1183
|
}
|
|
1171
1184
|
class TSConfckParseError extends Error {
|
|
1172
1185
|
code;
|
|
@@ -1195,12 +1208,12 @@ const DEFAULT_JSCONFIG_COMPILER_OPTIONS = {
|
|
|
1195
1208
|
noEmit: true
|
|
1196
1209
|
};
|
|
1197
1210
|
function isJSConfig(configFileName) {
|
|
1198
|
-
return 'jsconfig.json' ===
|
|
1211
|
+
return 'jsconfig.json' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(configFileName);
|
|
1199
1212
|
}
|
|
1200
1213
|
async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
1201
|
-
const tsconfigFileName = await find((0,
|
|
1214
|
+
const tsconfigFileName = await find((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, tsconfigPath), {
|
|
1202
1215
|
root,
|
|
1203
|
-
configName: (0,
|
|
1216
|
+
configName: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.basename)(tsconfigPath)
|
|
1204
1217
|
});
|
|
1205
1218
|
if (tsconfigFileName) {
|
|
1206
1219
|
const { tsconfig } = await parse(tsconfigFileName);
|
|
@@ -1211,21 +1224,21 @@ async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
|
1211
1224
|
function defineConfig(config) {
|
|
1212
1225
|
return config;
|
|
1213
1226
|
}
|
|
1214
|
-
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);
|
|
1215
1228
|
const resolveConfigPath = (root, customConfig)=>{
|
|
1216
1229
|
if (customConfig) {
|
|
1217
|
-
const customConfigPath = (0,
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
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`);
|
|
1220
1233
|
}
|
|
1221
|
-
const configFilePath = findConfig((0,
|
|
1234
|
+
const configFilePath = findConfig((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, DEFAULT_CONFIG_NAME));
|
|
1222
1235
|
if (configFilePath) return configFilePath;
|
|
1223
1236
|
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
1224
1237
|
};
|
|
1225
1238
|
async function loadConfig({ cwd = process.cwd(), path, envMode }) {
|
|
1226
1239
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
1227
|
-
const { content } = await (0,
|
|
1228
|
-
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),
|
|
1229
1242
|
path: configFilePath,
|
|
1230
1243
|
envMode
|
|
1231
1244
|
});
|
|
@@ -1292,7 +1305,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1292
1305
|
};
|
|
1293
1306
|
if (contextInfo.issuer && 'commonjs' === dependencyType) {
|
|
1294
1307
|
matchUserExternals(externals, request, _callback);
|
|
1295
|
-
if (externalized)
|
|
1308
|
+
if (externalized) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request));
|
|
1296
1309
|
}
|
|
1297
1310
|
callback();
|
|
1298
1311
|
}
|
|
@@ -1302,11 +1315,12 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1302
1315
|
};
|
|
1303
1316
|
const getAutoExternalDefaultValue = (format, autoExternal)=>autoExternal ?? isIntermediateOutputFormat(format);
|
|
1304
1317
|
const composeAutoExternalConfig = (options)=>{
|
|
1305
|
-
const { format, pkgJson, userExternals } = options;
|
|
1318
|
+
const { bundle, format, pkgJson, userExternals } = options;
|
|
1319
|
+
if (false === bundle) return {};
|
|
1306
1320
|
const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
|
|
1307
1321
|
if (false === autoExternal) return {};
|
|
1308
1322
|
if (!pkgJson) {
|
|
1309
|
-
|
|
1323
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExternal configuration will not be applied due to read package.json failed');
|
|
1310
1324
|
return {};
|
|
1311
1325
|
}
|
|
1312
1326
|
const userExternalKeys = userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];
|
|
@@ -1377,30 +1391,30 @@ function composeBannerFooterConfig(banner, footer) {
|
|
|
1377
1391
|
if (isEmptyObject(bannerConfig) && isEmptyObject(footerConfig)) return {};
|
|
1378
1392
|
const plugins = [];
|
|
1379
1393
|
if (!isEmptyObject(bannerConfig)) {
|
|
1380
|
-
if (bannerConfig.js) plugins.push(new
|
|
1394
|
+
if (bannerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1381
1395
|
banner: bannerConfig.js,
|
|
1382
|
-
stage:
|
|
1396
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1383
1397
|
raw: true,
|
|
1384
1398
|
include: /\.(js|mjs|cjs)$/
|
|
1385
1399
|
}));
|
|
1386
|
-
if (bannerConfig.css) plugins.push(new
|
|
1400
|
+
if (bannerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1387
1401
|
banner: bannerConfig.css,
|
|
1388
|
-
stage:
|
|
1402
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1389
1403
|
raw: true,
|
|
1390
1404
|
include: /\.(css)$/
|
|
1391
1405
|
}));
|
|
1392
1406
|
}
|
|
1393
1407
|
if (!isEmptyObject(footerConfig)) {
|
|
1394
|
-
if (footerConfig.js) plugins.push(new
|
|
1408
|
+
if (footerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1395
1409
|
banner: footerConfig.js,
|
|
1396
|
-
stage:
|
|
1410
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1397
1411
|
raw: true,
|
|
1398
1412
|
footer: true,
|
|
1399
1413
|
include: /\.(js|mjs|cjs)$/
|
|
1400
1414
|
}));
|
|
1401
|
-
if (footerConfig.css) plugins.push(new
|
|
1415
|
+
if (footerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1402
1416
|
banner: footerConfig.css,
|
|
1403
|
-
stage:
|
|
1417
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1404
1418
|
raw: true,
|
|
1405
1419
|
footer: true,
|
|
1406
1420
|
include: /\.(css)$/
|
|
@@ -1425,7 +1439,7 @@ function composeDecoratorsConfig(compilerOptions, version) {
|
|
|
1425
1439
|
};
|
|
1426
1440
|
}
|
|
1427
1441
|
async function createConstantRsbuildConfig() {
|
|
1428
|
-
return (0,
|
|
1442
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.defineConfig)({
|
|
1429
1443
|
dev: {
|
|
1430
1444
|
progressBar: false
|
|
1431
1445
|
},
|
|
@@ -1514,7 +1528,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1514
1528
|
},
|
|
1515
1529
|
optimization: {
|
|
1516
1530
|
concatenateModules: true,
|
|
1517
|
-
sideEffects: 'flag'
|
|
1531
|
+
sideEffects: 'flag',
|
|
1532
|
+
avoidEntryIife: true
|
|
1518
1533
|
},
|
|
1519
1534
|
output: {
|
|
1520
1535
|
module: true,
|
|
@@ -1680,7 +1695,7 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1680
1695
|
enabledShims
|
|
1681
1696
|
};
|
|
1682
1697
|
};
|
|
1683
|
-
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"')}.`;
|
|
1684
1699
|
const composeExternalsConfig = (format, externals)=>{
|
|
1685
1700
|
const externalsTypeMap = {
|
|
1686
1701
|
esm: 'module-import',
|
|
@@ -1721,7 +1736,7 @@ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
|
1721
1736
|
}
|
|
1722
1737
|
}
|
|
1723
1738
|
};
|
|
1724
|
-
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;
|
|
1725
1740
|
return {
|
|
1726
1741
|
config: updatedConfig,
|
|
1727
1742
|
jsExtension: updatedJsExtension,
|
|
@@ -1753,62 +1768,102 @@ const composeSyntaxConfig = (target, syntax)=>{
|
|
|
1753
1768
|
}
|
|
1754
1769
|
};
|
|
1755
1770
|
};
|
|
1756
|
-
const
|
|
1771
|
+
const traverseEntryQuery = (entry, callback)=>{
|
|
1757
1772
|
const newEntry = {};
|
|
1758
1773
|
for (const [key, value] of Object.entries(entry)){
|
|
1759
1774
|
let result = value;
|
|
1760
|
-
result = 'string' == typeof value ?
|
|
1775
|
+
result = 'string' == typeof value ? callback(value) : Array.isArray(value) ? value.map(callback) : {
|
|
1761
1776
|
...value,
|
|
1762
|
-
import: 'string' == typeof value.import ?
|
|
1777
|
+
import: 'string' == typeof value.import ? callback(value.import) : value.import.map(callback)
|
|
1763
1778
|
};
|
|
1764
1779
|
newEntry[key] = result;
|
|
1765
1780
|
}
|
|
1766
1781
|
return newEntry;
|
|
1767
1782
|
};
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
entry
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1783
|
+
const appendEntryQuery = (entries)=>traverseEntryQuery(entries, (item)=>`${item}?${RSLIB_ENTRY_QUERY}`);
|
|
1784
|
+
const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
|
|
1785
|
+
let entries = rawEntry;
|
|
1786
|
+
if (!entries) {
|
|
1787
|
+
if (false !== bundle) return {
|
|
1788
|
+
entryConfig: {},
|
|
1789
|
+
lcp: null
|
|
1790
|
+
};
|
|
1791
|
+
entries = {
|
|
1792
|
+
index: 'src/**'
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
if (false !== bundle) {
|
|
1796
|
+
const entryErrorReasons = [];
|
|
1797
|
+
traverseEntryQuery(entries, (entry)=>{
|
|
1798
|
+
const entryAbsPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(entry) ? entry : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, entry);
|
|
1799
|
+
const isDirLike = '' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(entryAbsPath);
|
|
1800
|
+
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.`;
|
|
1801
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(entryAbsPath)) {
|
|
1802
|
+
const stats = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].statSync(entryAbsPath);
|
|
1803
|
+
if (!stats.isFile()) entryErrorReasons.push(dirError);
|
|
1804
|
+
} else if (isDirLike) entryErrorReasons.push(dirError);
|
|
1805
|
+
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.`);
|
|
1806
|
+
return entry;
|
|
1791
1807
|
});
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1808
|
+
if (entryErrorReasons.length) throw new AggregateError(entryErrorReasons.map((reason)=>new Error(reason)));
|
|
1809
|
+
return {
|
|
1810
|
+
entryConfig: {
|
|
1811
|
+
source: {
|
|
1812
|
+
entry: appendEntryQuery(entries)
|
|
1813
|
+
}
|
|
1814
|
+
},
|
|
1815
|
+
lcp: null
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
const scanGlobEntries = async (calcLcp)=>{
|
|
1819
|
+
const resolvedEntries = {};
|
|
1820
|
+
for (const key of Object.keys(entries)){
|
|
1821
|
+
const entry = entries[key];
|
|
1822
|
+
const entryFiles = Array.isArray(entry) ? entry : 'string' == typeof entry ? [
|
|
1823
|
+
entry
|
|
1824
|
+
] : null;
|
|
1825
|
+
if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
|
|
1826
|
+
const globEntryFiles = await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)(entryFiles, {
|
|
1827
|
+
cwd: root,
|
|
1828
|
+
absolute: true
|
|
1829
|
+
});
|
|
1830
|
+
const resolvedEntryFiles = globEntryFiles.filter((file)=>ENTRY_EXTENSIONS_PATTERN.test(file));
|
|
1831
|
+
if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
|
|
1832
|
+
const lcp = await calcLongestCommonPath(resolvedEntryFiles);
|
|
1833
|
+
const outBase = null === lcp ? root : lcp;
|
|
1834
|
+
function getEntryName(file) {
|
|
1835
|
+
const { dir, name } = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(outBase, file));
|
|
1836
|
+
const entryFileName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, name);
|
|
1837
|
+
if (isCssGlobalFile(file, cssModulesAuto)) return `${RSLIB_CSS_ENTRY_FLAG}/${entryFileName}`;
|
|
1838
|
+
return entryFileName;
|
|
1839
|
+
}
|
|
1840
|
+
for (const file of resolvedEntryFiles){
|
|
1841
|
+
const entryName = getEntryName(file);
|
|
1842
|
+
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`);
|
|
1843
|
+
resolvedEntries[entryName] = file;
|
|
1844
|
+
}
|
|
1801
1845
|
}
|
|
1802
|
-
|
|
1803
|
-
const
|
|
1804
|
-
|
|
1805
|
-
|
|
1846
|
+
if (calcLcp) {
|
|
1847
|
+
const lcp = await calcLongestCommonPath(Object.values(resolvedEntries));
|
|
1848
|
+
return {
|
|
1849
|
+
resolvedEntries,
|
|
1850
|
+
lcp
|
|
1851
|
+
};
|
|
1806
1852
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1853
|
+
return {
|
|
1854
|
+
resolvedEntries,
|
|
1855
|
+
lcp: null
|
|
1856
|
+
};
|
|
1857
|
+
};
|
|
1858
|
+
const { lcp } = await scanGlobEntries(true);
|
|
1809
1859
|
const entryConfig = {
|
|
1810
|
-
|
|
1811
|
-
|
|
1860
|
+
tools: {
|
|
1861
|
+
rspack: {
|
|
1862
|
+
entry: async ()=>{
|
|
1863
|
+
const { resolvedEntries } = await scanGlobEntries(false);
|
|
1864
|
+
return appendEntryQuery(resolvedEntries);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1812
1867
|
}
|
|
1813
1868
|
};
|
|
1814
1869
|
return {
|
|
@@ -1820,7 +1875,8 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1820
1875
|
if (bundle) return {
|
|
1821
1876
|
config: {}
|
|
1822
1877
|
};
|
|
1823
|
-
const
|
|
1878
|
+
const styleRedirectPath = redirect.style?.path ?? true;
|
|
1879
|
+
const styleRedirectExtension = redirect.style?.extension ?? true;
|
|
1824
1880
|
const jsRedirectPath = redirect.js?.path ?? true;
|
|
1825
1881
|
const jsRedirectExtension = redirect.js?.extension ?? true;
|
|
1826
1882
|
let resolver;
|
|
@@ -1835,20 +1891,34 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1835
1891
|
async (data, callback)=>{
|
|
1836
1892
|
const { request, getResolve, context, contextInfo } = data;
|
|
1837
1893
|
if (!request || !getResolve || !context || !contextInfo) return callback();
|
|
1894
|
+
const { issuer } = contextInfo;
|
|
1838
1895
|
if (!resolver) resolver = await getResolve();
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
if (false !== cssExternal) return cssExternal;
|
|
1843
|
-
if (jsRedirectPath) try {
|
|
1896
|
+
async function redirectPath(request) {
|
|
1897
|
+
try {
|
|
1898
|
+
let resolvedRequest = request;
|
|
1844
1899
|
resolvedRequest = await resolver(context, resolvedRequest);
|
|
1845
|
-
|
|
1846
|
-
|
|
1900
|
+
if (!resolvedRequest.includes('node_modules')) {
|
|
1901
|
+
resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(issuer), resolvedRequest));
|
|
1902
|
+
if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
|
|
1903
|
+
return resolvedRequest;
|
|
1904
|
+
}
|
|
1905
|
+
return;
|
|
1847
1906
|
} catch (e) {
|
|
1848
|
-
|
|
1907
|
+
__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.`);
|
|
1908
|
+
return request;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
if (issuer) {
|
|
1912
|
+
let resolvedRequest = request;
|
|
1913
|
+
const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectPath);
|
|
1914
|
+
if (false !== cssExternal) return cssExternal;
|
|
1915
|
+
if (jsRedirectPath) {
|
|
1916
|
+
const redirectedPath = await redirectPath(resolvedRequest);
|
|
1917
|
+
if (void 0 === redirectedPath) return callback(void 0, request);
|
|
1918
|
+
resolvedRequest = redirectedPath;
|
|
1849
1919
|
}
|
|
1850
1920
|
if (jsRedirectExtension && resolvedRequest.startsWith('.')) {
|
|
1851
|
-
const ext = (0,
|
|
1921
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(resolvedRequest);
|
|
1852
1922
|
if (ext) {
|
|
1853
1923
|
if (!JS_EXTENSIONS_PATTERN.test(resolvedRequest)) return callback();
|
|
1854
1924
|
resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
@@ -1944,7 +2014,7 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
1944
2014
|
...Object.keys(pkgJson?.devDependencies ?? [])
|
|
1945
2015
|
];
|
|
1946
2016
|
if (!deps.includes(SWC_HELPERS)) {
|
|
1947
|
-
|
|
2017
|
+
__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.`);
|
|
1948
2018
|
process.exit(1);
|
|
1949
2019
|
}
|
|
1950
2020
|
defaultConfig = Object.assign(defaultConfig, {
|
|
@@ -1977,6 +2047,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
1977
2047
|
const { config: targetConfig, externalsConfig: targetExternalsConfig, target } = composeTargetConfig(config.output?.target, format);
|
|
1978
2048
|
const syntaxConfig = composeSyntaxConfig(target, config?.syntax);
|
|
1979
2049
|
const autoExternalConfig = composeAutoExternalConfig({
|
|
2050
|
+
bundle,
|
|
1980
2051
|
format: format,
|
|
1981
2052
|
autoExternal,
|
|
1982
2053
|
pkgJson,
|
|
@@ -1986,21 +2057,22 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
1986
2057
|
const cssConfig = composeCssConfig(lcp, config.bundle);
|
|
1987
2058
|
const assetConfig = composeAssetConfig(bundle, format);
|
|
1988
2059
|
const entryChunkConfig = composeEntryChunkConfig({
|
|
1989
|
-
enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url']
|
|
2060
|
+
enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url'],
|
|
2061
|
+
contextToWatch: lcp
|
|
1990
2062
|
});
|
|
1991
2063
|
const dtsConfig = await composeDtsConfig(config, dtsExtension);
|
|
1992
2064
|
const externalsWarnConfig = composeExternalsWarnConfig(format, autoExternalConfig?.output?.externals, userExternalsConfig?.output?.externals);
|
|
1993
2065
|
const minifyConfig = composeMinifyConfig(config);
|
|
1994
2066
|
const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
|
|
1995
2067
|
const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
|
|
1996
|
-
return (0,
|
|
2068
|
+
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);
|
|
1997
2069
|
}
|
|
1998
2070
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
1999
2071
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
2000
2072
|
const { lib: libConfigsArray, mode, root, plugins: sharedPlugins, dev, server, ...sharedRsbuildConfig } = rslibConfig;
|
|
2001
2073
|
if (!libConfigsArray) throw new Error(`Expect lib field to be an array, but got ${libConfigsArray}.`);
|
|
2002
2074
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
2003
|
-
const userConfig = (0,
|
|
2075
|
+
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
2004
2076
|
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, root, sharedPlugins);
|
|
2005
2077
|
userConfig.source ??= {};
|
|
2006
2078
|
userConfig.source.entry = {};
|
|
@@ -2008,7 +2080,7 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
2008
2080
|
delete userConfig.output.externals;
|
|
2009
2081
|
const config = {
|
|
2010
2082
|
format: libConfig.format,
|
|
2011
|
-
config: (0,
|
|
2083
|
+
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
2012
2084
|
id: true,
|
|
2013
2085
|
bundle: true,
|
|
2014
2086
|
format: true,
|
|
@@ -2065,7 +2137,9 @@ async function composeRsbuildEnvironments(rslibConfig) {
|
|
|
2065
2137
|
}
|
|
2066
2138
|
const pruneEnvironments = (environments, libs)=>{
|
|
2067
2139
|
if (!libs) return environments;
|
|
2068
|
-
|
|
2140
|
+
const filteredEnvironments = Object.fromEntries(Object.entries(environments).filter(([name])=>libs.includes(name)));
|
|
2141
|
+
if (0 === Object.keys(filteredEnvironments).length) throw new Error(`The following libs are not found: ${libs.map((lib)=>`"${lib}"`).join(', ')}.`);
|
|
2142
|
+
return filteredEnvironments;
|
|
2069
2143
|
};
|
|
2070
2144
|
async function watchFilesForRestart(files, restart) {
|
|
2071
2145
|
if (!files.length) return;
|
|
@@ -2095,15 +2169,15 @@ const clearConsole = ()=>{
|
|
|
2095
2169
|
const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
2096
2170
|
if (clear) clearConsole();
|
|
2097
2171
|
if (filePath) {
|
|
2098
|
-
const filename =
|
|
2099
|
-
|
|
2100
|
-
} else
|
|
2172
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
2173
|
+
__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`);
|
|
2174
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('Restarting...\n');
|
|
2101
2175
|
for (const cleaner of cleaners)await cleaner();
|
|
2102
2176
|
cleaners = [];
|
|
2103
2177
|
};
|
|
2104
2178
|
async function build(config, options = {}) {
|
|
2105
2179
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2106
|
-
const rsbuildInstance = await (0,
|
|
2180
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2107
2181
|
rsbuildConfig: {
|
|
2108
2182
|
mode: 'production',
|
|
2109
2183
|
root: config.root,
|
|
@@ -2121,13 +2195,13 @@ async function build(config, options = {}) {
|
|
|
2121
2195
|
return rsbuildInstance;
|
|
2122
2196
|
}
|
|
2123
2197
|
const getEnvDir = (cwd, envDir)=>{
|
|
2124
|
-
if (envDir) return
|
|
2198
|
+
if (envDir) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(cwd, envDir);
|
|
2125
2199
|
return cwd;
|
|
2126
2200
|
};
|
|
2127
2201
|
async function init(options) {
|
|
2128
2202
|
const cwd = process.cwd();
|
|
2129
2203
|
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
2130
|
-
const envs = (0,
|
|
2204
|
+
const envs = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadEnv)({
|
|
2131
2205
|
cwd: getEnvDir(root, options.envDir),
|
|
2132
2206
|
mode: options.envMode
|
|
2133
2207
|
});
|
|
@@ -2154,7 +2228,7 @@ async function init(options) {
|
|
|
2154
2228
|
}
|
|
2155
2229
|
async function inspect(config, options = {}) {
|
|
2156
2230
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2157
|
-
const rsbuildInstance = await (0,
|
|
2231
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2158
2232
|
rsbuildConfig: {
|
|
2159
2233
|
mode: 'production',
|
|
2160
2234
|
root: config.root,
|
|
@@ -2183,9 +2257,9 @@ async function initMFRsbuild(config, options = {}) {
|
|
|
2183
2257
|
if (!options?.lib) return isMf;
|
|
2184
2258
|
return env.id && options.lib.includes(env.id);
|
|
2185
2259
|
}).map((env)=>env.id);
|
|
2186
|
-
if (!selectedEnvironmentIds.length) throw new Error(
|
|
2260
|
+
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.`);
|
|
2187
2261
|
const selectedEnvironments = pruneEnvironments(environments, selectedEnvironmentIds);
|
|
2188
|
-
const rsbuildInstance = await (0,
|
|
2262
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2189
2263
|
rsbuildConfig: {
|
|
2190
2264
|
mode: 'development',
|
|
2191
2265
|
root: config.root,
|
|
@@ -2206,10 +2280,10 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2206
2280
|
value
|
|
2207
2281
|
]);
|
|
2208
2282
|
function runCli() {
|
|
2209
|
-
|
|
2210
|
-
const buildCommand =
|
|
2211
|
-
const inspectCommand =
|
|
2212
|
-
const mfDevCommand =
|
|
2283
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.3.1");
|
|
2284
|
+
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2285
|
+
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2286
|
+
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
2213
2287
|
[
|
|
2214
2288
|
buildCommand,
|
|
2215
2289
|
inspectCommand,
|
|
@@ -2226,8 +2300,9 @@ function runCli() {
|
|
|
2226
2300
|
};
|
|
2227
2301
|
await cliBuild();
|
|
2228
2302
|
} catch (err) {
|
|
2229
|
-
|
|
2230
|
-
|
|
2303
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to build.');
|
|
2304
|
+
if (err instanceof AggregateError) for (const error of err.errors)__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(error);
|
|
2305
|
+
else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2231
2306
|
process.exit(1);
|
|
2232
2307
|
}
|
|
2233
2308
|
});
|
|
@@ -2241,8 +2316,8 @@ function runCli() {
|
|
|
2241
2316
|
verbose: options.verbose
|
|
2242
2317
|
});
|
|
2243
2318
|
} catch (err) {
|
|
2244
|
-
|
|
2245
|
-
|
|
2319
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to inspect config.');
|
|
2320
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2246
2321
|
process.exit(1);
|
|
2247
2322
|
}
|
|
2248
2323
|
});
|
|
@@ -2259,13 +2334,13 @@ function runCli() {
|
|
|
2259
2334
|
};
|
|
2260
2335
|
await cliMfDev();
|
|
2261
2336
|
} catch (err) {
|
|
2262
|
-
|
|
2263
|
-
|
|
2337
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start mf-dev.');
|
|
2338
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2264
2339
|
process.exit(1);
|
|
2265
2340
|
}
|
|
2266
2341
|
});
|
|
2267
|
-
|
|
2342
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2268
2343
|
}
|
|
2269
|
-
const src_rslib_entry_version = "0.
|
|
2270
|
-
var __webpack_exports__logger =
|
|
2344
|
+
const src_rslib_entry_version = "0.3.1";
|
|
2345
|
+
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2271
2346
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|