@rslib/core 0.2.0 → 0.2.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/dist/index.js +130 -137
- package/dist/libCssExtractLoader.js +5 -5
- package/package.json +6 -5
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,7 +160,7 @@ 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.2.1\n`);
|
|
164
164
|
}
|
|
165
165
|
const composeAssetConfig = (bundle, format)=>{
|
|
166
166
|
if ('esm' === format || 'cjs' === format) {
|
|
@@ -255,7 +255,7 @@ class LibCssExtractPlugin {
|
|
|
255
255
|
const chunkAsset = Object.keys(assets).filter((name)=>/\.css/.test(name));
|
|
256
256
|
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
257
257
|
const oldSource = old.source().toString();
|
|
258
|
-
const replaceSource = new
|
|
258
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
259
259
|
function replace(searchValue, replaceValue) {
|
|
260
260
|
let start = oldSource.indexOf(searchValue);
|
|
261
261
|
while(-1 !== start){
|
|
@@ -273,7 +273,7 @@ class LibCssExtractPlugin {
|
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
const cssConfig_require = (0,
|
|
276
|
+
const cssConfig_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
277
277
|
const RSLIB_CSS_ENTRY_FLAG = '__rslib_css__';
|
|
278
278
|
function isCssFile(filepath) {
|
|
279
279
|
return CSS_EXTENSIONS_PATTERN.test(filepath);
|
|
@@ -289,7 +289,7 @@ function parsePathQueryFragment(str) {
|
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
291
|
function isCssModulesFile(filepath, auto) {
|
|
292
|
-
const filename =
|
|
292
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath);
|
|
293
293
|
if (true === auto) return CSS_MODULE_REG.test(filename);
|
|
294
294
|
if (auto instanceof RegExp) return auto.test(filepath);
|
|
295
295
|
if ('function' == typeof auto) {
|
|
@@ -382,16 +382,16 @@ const pluginEsmRequireShim = ()=>({
|
|
|
382
382
|
setup (api) {
|
|
383
383
|
api.modifyRspackConfig((config)=>{
|
|
384
384
|
config.plugins ??= [];
|
|
385
|
-
config.plugins.push(new
|
|
385
|
+
config.plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
386
386
|
banner: requireShim,
|
|
387
|
-
stage:
|
|
387
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
|
|
388
388
|
raw: true,
|
|
389
389
|
include: /\.(js|cjs)$/
|
|
390
390
|
}));
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
});
|
|
394
|
-
const EntryChunkPlugin_require = (0,
|
|
394
|
+
const EntryChunkPlugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
395
395
|
const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
|
|
396
396
|
const EntryChunkPlugin_LOADER_NAME = 'rsbuild:lib-entry-module';
|
|
397
397
|
const matchFirstLine = (source, regex)=>{
|
|
@@ -452,7 +452,7 @@ class EntryChunkPlugin {
|
|
|
452
452
|
const chunkAsset = Object.keys(assets).filter((name)=>JS_EXTENSIONS_PATTERN.test(name));
|
|
453
453
|
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
454
454
|
const oldSource = old.source().toString();
|
|
455
|
-
const replaceSource = new
|
|
455
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
456
456
|
if (oldSource.startsWith('use strict;') || oldSource.startsWith('"use strict";')) replaceSource.replace(0, 11, `"use strict";\n${importMetaUrlShim}`);
|
|
457
457
|
else replaceSource.insert(0, importMetaUrlShim);
|
|
458
458
|
return replaceSource;
|
|
@@ -460,14 +460,14 @@ class EntryChunkPlugin {
|
|
|
460
460
|
});
|
|
461
461
|
compilation.hooks.processAssets.tap({
|
|
462
462
|
name: EntryChunkPlugin_PLUGIN_NAME,
|
|
463
|
-
stage:
|
|
463
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1
|
|
464
464
|
}, (assets)=>{
|
|
465
465
|
const chunkAsset = Object.keys(assets);
|
|
466
466
|
for (const name of chunkAsset){
|
|
467
467
|
const shebangValue = this.shebangEntries[name];
|
|
468
468
|
const reactDirectiveValue = this.reactDirectives[name];
|
|
469
469
|
if (shebangValue || reactDirectiveValue) compilation.updateAsset(name, (old)=>{
|
|
470
|
-
const replaceSource = new
|
|
470
|
+
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
471
471
|
if (shebangValue) {
|
|
472
472
|
replaceSource.insert(0, `${shebangValue}\n`);
|
|
473
473
|
this.shebangInjectedAssets.add(name);
|
|
@@ -479,7 +479,7 @@ class EntryChunkPlugin {
|
|
|
479
479
|
});
|
|
480
480
|
});
|
|
481
481
|
compiler.hooks.assetEmitted.tap(EntryChunkPlugin_PLUGIN_NAME, (file, { targetPath })=>{
|
|
482
|
-
if (this.shebangInjectedAssets.has(file)) (0,
|
|
482
|
+
if (this.shebangInjectedAssets.has(file)) (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.chmodSync)(targetPath, this.shebangChmod);
|
|
483
483
|
});
|
|
484
484
|
}
|
|
485
485
|
}
|
|
@@ -514,7 +514,7 @@ const getDefaultExtension = (options)=>{
|
|
|
514
514
|
dtsExtension
|
|
515
515
|
};
|
|
516
516
|
if (!pkgJson) {
|
|
517
|
-
|
|
517
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExtension configuration will not be applied due to read package.json failed');
|
|
518
518
|
return {
|
|
519
519
|
jsExtension,
|
|
520
520
|
dtsExtension
|
|
@@ -699,8 +699,8 @@ function transformSyntaxToBrowserslist(syntax, target) {
|
|
|
699
699
|
if (Array.isArray(syntax)) return syntax.flatMap(handleSyntaxItem);
|
|
700
700
|
return handleSyntaxItem(syntax);
|
|
701
701
|
}
|
|
702
|
-
const POSIX_SEP_RE = new RegExp('\\' +
|
|
703
|
-
const NATIVE_SEP_RE = new RegExp('\\' +
|
|
702
|
+
const POSIX_SEP_RE = new RegExp('\\' + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep, 'g');
|
|
703
|
+
const NATIVE_SEP_RE = new RegExp('\\' + __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep, 'g');
|
|
704
704
|
const PATTERN_REGEX_CACHE = new Map();
|
|
705
705
|
const GLOB_ALL_PATTERN = "**/*";
|
|
706
706
|
const TS_EXTENSIONS = [
|
|
@@ -718,7 +718,7 @@ const util_JS_EXTENSIONS = [
|
|
|
718
718
|
const TSJS_EXTENSIONS = TS_EXTENSIONS.concat(util_JS_EXTENSIONS);
|
|
719
719
|
const TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
720
720
|
const TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext)=>ext.substring(1)).join('|')})`;
|
|
721
|
-
const IS_POSIX =
|
|
721
|
+
const IS_POSIX = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
722
722
|
function util_makePromise() {
|
|
723
723
|
let resolve, reject;
|
|
724
724
|
const promise = new Promise((res, rej)=>{
|
|
@@ -732,22 +732,22 @@ function util_makePromise() {
|
|
|
732
732
|
};
|
|
733
733
|
}
|
|
734
734
|
async function util_resolveTSConfigJson(filename, cache) {
|
|
735
|
-
if ('.json' !==
|
|
736
|
-
const tsconfig =
|
|
735
|
+
if ('.json' !== __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(filename)) return;
|
|
736
|
+
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename);
|
|
737
737
|
if (cache && (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename))) return tsconfig;
|
|
738
|
-
return
|
|
738
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.stat(tsconfig).then((stat)=>{
|
|
739
739
|
if (stat.isFile() || stat.isFIFO()) return tsconfig;
|
|
740
740
|
throw new Error(`${filename} exists but is not a regular file.`);
|
|
741
741
|
});
|
|
742
742
|
}
|
|
743
743
|
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 ?
|
|
744
|
+
const posix2native = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(POSIX_SEP_RE, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep);
|
|
745
|
+
const util_native2posix = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(NATIVE_SEP_RE, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.sep);
|
|
746
|
+
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
747
|
function util_resolveReferencedTSConfigFiles(result, options) {
|
|
748
|
-
const dir =
|
|
748
|
+
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile);
|
|
749
749
|
return result.tsconfig.references.map((ref)=>{
|
|
750
|
-
const refPath = ref.path.endsWith('.json') ? ref.path :
|
|
750
|
+
const refPath = ref.path.endsWith('.json') ? ref.path : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(ref.path, options?.configName ?? 'tsconfig.json');
|
|
751
751
|
return resolve2posix(dir, refPath);
|
|
752
752
|
});
|
|
753
753
|
}
|
|
@@ -761,7 +761,7 @@ function util_resolveSolutionTSConfig(filename, result) {
|
|
|
761
761
|
return result;
|
|
762
762
|
}
|
|
763
763
|
function util_isIncluded(filename, result) {
|
|
764
|
-
const dir = util_native2posix(
|
|
764
|
+
const dir = util_native2posix(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(result.tsconfigFile));
|
|
765
765
|
const files = (result.tsconfig.files || []).map((file)=>resolve2posix(dir, file));
|
|
766
766
|
const absoluteFilename = resolve2posix(null, filename);
|
|
767
767
|
if (files.includes(filename)) return true;
|
|
@@ -852,13 +852,13 @@ function util_replaceTokens(tsconfig, configDir) {
|
|
|
852
852
|
return JSON.parse(JSON.stringify(tsconfig).replaceAll(/"\${configDir}/g, `"${util_native2posix(configDir)}`));
|
|
853
853
|
}
|
|
854
854
|
async function find(filename, options) {
|
|
855
|
-
let dir =
|
|
855
|
+
let dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(filename));
|
|
856
856
|
if (options?.ignoreNodeModules && util_isInNodeModules(dir)) return null;
|
|
857
857
|
const cache = options?.cache;
|
|
858
858
|
const configName = options?.configName ?? 'tsconfig.json';
|
|
859
859
|
if (cache?.hasConfigPath(dir, configName)) return cache.getConfigPath(dir, configName);
|
|
860
860
|
const { promise, resolve, reject } = util_makePromise();
|
|
861
|
-
if (options?.root && !
|
|
861
|
+
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
862
|
findUp(dir, {
|
|
863
863
|
promise,
|
|
864
864
|
resolve,
|
|
@@ -881,13 +881,13 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
881
881
|
else resolve(cached);
|
|
882
882
|
} else cache.setConfigPath(dir, promise, configName);
|
|
883
883
|
}
|
|
884
|
-
const tsconfig =
|
|
885
|
-
|
|
884
|
+
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, options?.configName ?? 'tsconfig.json');
|
|
885
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].stat(tsconfig, (err, stats)=>{
|
|
886
886
|
if (stats && (stats.isFile() || stats.isFIFO())) resolve(tsconfig);
|
|
887
887
|
else if (err?.code !== 'ENOENT') reject(err);
|
|
888
888
|
else {
|
|
889
889
|
let parent;
|
|
890
|
-
if (root === dir || (parent =
|
|
890
|
+
if (root === dir || (parent = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(dir)) === dir) resolve(null);
|
|
891
891
|
else findUp(parent, {
|
|
892
892
|
promise,
|
|
893
893
|
resolve,
|
|
@@ -896,7 +896,7 @@ function findUp(dir, { resolve, reject, promise }, options) {
|
|
|
896
896
|
}
|
|
897
897
|
});
|
|
898
898
|
}
|
|
899
|
-
|
|
899
|
+
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep;
|
|
900
900
|
function toJson(tsconfigJson) {
|
|
901
901
|
const stripped = stripDanglingComma(stripJsonComments(stripBom(tsconfigJson)));
|
|
902
902
|
if ('' === stripped.trim()) return '{}';
|
|
@@ -1017,7 +1017,7 @@ async function parse(filename, options) {
|
|
|
1017
1017
|
parseReferences(result, options)
|
|
1018
1018
|
]);
|
|
1019
1019
|
}
|
|
1020
|
-
result.tsconfig = util_replaceTokens(result.tsconfig,
|
|
1020
|
+
result.tsconfig = util_replaceTokens(result.tsconfig, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(tsconfigFile));
|
|
1021
1021
|
resolve(util_resolveSolutionTSConfig(filename, result));
|
|
1022
1022
|
} catch (e) {
|
|
1023
1023
|
reject(e);
|
|
@@ -1038,12 +1038,12 @@ async function getParsedDeep(filename, cache, options) {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
async function parseFile(tsconfigFile, cache, skipCache) {
|
|
1040
1040
|
if (!skipCache && cache?.hasParseResult(tsconfigFile) && !cache.getParseResult(tsconfigFile)._isRootFile_) return cache.getParseResult(tsconfigFile);
|
|
1041
|
-
const promise =
|
|
1041
|
+
const promise = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.readFile(tsconfigFile, 'utf-8').then(toJson).then((json)=>{
|
|
1042
1042
|
const parsed = JSON.parse(json);
|
|
1043
1043
|
applyDefaults(parsed, tsconfigFile);
|
|
1044
1044
|
return {
|
|
1045
1045
|
tsconfigFile,
|
|
1046
|
-
tsconfig: normalizeTSConfig(parsed,
|
|
1046
|
+
tsconfig: normalizeTSConfig(parsed, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(tsconfigFile))
|
|
1047
1047
|
};
|
|
1048
1048
|
}).catch((e)=>{
|
|
1049
1049
|
throw new TSConfckParseError(`parsing ${tsconfigFile} failed: ${e}`, 'PARSE_FILE', tsconfigFile, e);
|
|
@@ -1053,7 +1053,7 @@ async function parseFile(tsconfigFile, cache, skipCache) {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
function normalizeTSConfig(tsconfig, dir) {
|
|
1055
1055
|
const baseUrl = tsconfig.compilerOptions?.baseUrl;
|
|
1056
|
-
if (baseUrl && !baseUrl.startsWith('${') && !
|
|
1056
|
+
if (baseUrl && !baseUrl.startsWith('${') && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(baseUrl)) tsconfig.compilerOptions.baseUrl = resolve2posix(dir, baseUrl);
|
|
1057
1057
|
return tsconfig;
|
|
1058
1058
|
}
|
|
1059
1059
|
async function parseReferences(result, options) {
|
|
@@ -1112,7 +1112,7 @@ function resolveExtends(extended, from) {
|
|
|
1112
1112
|
} catch (e) {
|
|
1113
1113
|
error = e;
|
|
1114
1114
|
}
|
|
1115
|
-
if ('.' !== extended[0] && !
|
|
1115
|
+
if ('.' !== extended[0] && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(extended)) try {
|
|
1116
1116
|
return req.resolve(`${extended}/tsconfig.json`);
|
|
1117
1117
|
} catch (e) {
|
|
1118
1118
|
error = e;
|
|
@@ -1132,7 +1132,7 @@ const EXTENDABLE_KEYS = [
|
|
|
1132
1132
|
function extendTSConfig(extending, extended) {
|
|
1133
1133
|
const extendingConfig = extending.tsconfig;
|
|
1134
1134
|
const extendedConfig = extended.tsconfig;
|
|
1135
|
-
const relativePath = util_native2posix(
|
|
1135
|
+
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
1136
|
for (const key of Object.keys(extendedConfig).filter((key)=>EXTENDABLE_KEYS.includes(key)))if ('compilerOptions' === key) {
|
|
1137
1137
|
if (!extendingConfig.compilerOptions) extendingConfig.compilerOptions = {};
|
|
1138
1138
|
for (const option of Object.keys(extendedConfig.compilerOptions)){
|
|
@@ -1165,8 +1165,8 @@ function rebaseRelative(key, value, prependPath) {
|
|
|
1165
1165
|
return rebasePath(value, prependPath);
|
|
1166
1166
|
}
|
|
1167
1167
|
function rebasePath(value, prependPath) {
|
|
1168
|
-
if (
|
|
1169
|
-
return
|
|
1168
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(value) || value.startsWith('${configDir}')) return value;
|
|
1169
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.join(prependPath, value));
|
|
1170
1170
|
}
|
|
1171
1171
|
class TSConfckParseError extends Error {
|
|
1172
1172
|
code;
|
|
@@ -1195,12 +1195,12 @@ const DEFAULT_JSCONFIG_COMPILER_OPTIONS = {
|
|
|
1195
1195
|
noEmit: true
|
|
1196
1196
|
};
|
|
1197
1197
|
function isJSConfig(configFileName) {
|
|
1198
|
-
return 'jsconfig.json' ===
|
|
1198
|
+
return 'jsconfig.json' === __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(configFileName);
|
|
1199
1199
|
}
|
|
1200
1200
|
async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
1201
|
-
const tsconfigFileName = await find((0,
|
|
1201
|
+
const tsconfigFileName = await find((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, tsconfigPath), {
|
|
1202
1202
|
root,
|
|
1203
|
-
configName: (0,
|
|
1203
|
+
configName: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.basename)(tsconfigPath)
|
|
1204
1204
|
});
|
|
1205
1205
|
if (tsconfigFileName) {
|
|
1206
1206
|
const { tsconfig } = await parse(tsconfigFileName);
|
|
@@ -1211,21 +1211,21 @@ async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
|
1211
1211
|
function defineConfig(config) {
|
|
1212
1212
|
return config;
|
|
1213
1213
|
}
|
|
1214
|
-
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(
|
|
1214
|
+
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync);
|
|
1215
1215
|
const resolveConfigPath = (root, customConfig)=>{
|
|
1216
1216
|
if (customConfig) {
|
|
1217
|
-
const customConfigPath = (0,
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1217
|
+
const customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
|
|
1218
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
1219
|
+
__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
1220
|
}
|
|
1221
|
-
const configFilePath = findConfig((0,
|
|
1221
|
+
const configFilePath = findConfig((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, DEFAULT_CONFIG_NAME));
|
|
1222
1222
|
if (configFilePath) return configFilePath;
|
|
1223
1223
|
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
1224
1224
|
};
|
|
1225
1225
|
async function loadConfig({ cwd = process.cwd(), path, envMode }) {
|
|
1226
1226
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
1227
|
-
const { content } = await (0,
|
|
1228
|
-
cwd: (0,
|
|
1227
|
+
const { content } = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadConfig)({
|
|
1228
|
+
cwd: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(configFilePath),
|
|
1229
1229
|
path: configFilePath,
|
|
1230
1230
|
envMode
|
|
1231
1231
|
});
|
|
@@ -1292,7 +1292,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1292
1292
|
};
|
|
1293
1293
|
if (contextInfo.issuer && 'commonjs' === dependencyType) {
|
|
1294
1294
|
matchUserExternals(externals, request, _callback);
|
|
1295
|
-
if (externalized)
|
|
1295
|
+
if (externalized) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request));
|
|
1296
1296
|
}
|
|
1297
1297
|
callback();
|
|
1298
1298
|
}
|
|
@@ -1306,7 +1306,7 @@ const composeAutoExternalConfig = (options)=>{
|
|
|
1306
1306
|
const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
|
|
1307
1307
|
if (false === autoExternal) return {};
|
|
1308
1308
|
if (!pkgJson) {
|
|
1309
|
-
|
|
1309
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExternal configuration will not be applied due to read package.json failed');
|
|
1310
1310
|
return {};
|
|
1311
1311
|
}
|
|
1312
1312
|
const userExternalKeys = userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];
|
|
@@ -1377,30 +1377,30 @@ function composeBannerFooterConfig(banner, footer) {
|
|
|
1377
1377
|
if (isEmptyObject(bannerConfig) && isEmptyObject(footerConfig)) return {};
|
|
1378
1378
|
const plugins = [];
|
|
1379
1379
|
if (!isEmptyObject(bannerConfig)) {
|
|
1380
|
-
if (bannerConfig.js) plugins.push(new
|
|
1380
|
+
if (bannerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1381
1381
|
banner: bannerConfig.js,
|
|
1382
|
-
stage:
|
|
1382
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1383
1383
|
raw: true,
|
|
1384
1384
|
include: /\.(js|mjs|cjs)$/
|
|
1385
1385
|
}));
|
|
1386
|
-
if (bannerConfig.css) plugins.push(new
|
|
1386
|
+
if (bannerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1387
1387
|
banner: bannerConfig.css,
|
|
1388
|
-
stage:
|
|
1388
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1389
1389
|
raw: true,
|
|
1390
1390
|
include: /\.(css)$/
|
|
1391
1391
|
}));
|
|
1392
1392
|
}
|
|
1393
1393
|
if (!isEmptyObject(footerConfig)) {
|
|
1394
|
-
if (footerConfig.js) plugins.push(new
|
|
1394
|
+
if (footerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1395
1395
|
banner: footerConfig.js,
|
|
1396
|
-
stage:
|
|
1396
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1397
1397
|
raw: true,
|
|
1398
1398
|
footer: true,
|
|
1399
1399
|
include: /\.(js|mjs|cjs)$/
|
|
1400
1400
|
}));
|
|
1401
|
-
if (footerConfig.css) plugins.push(new
|
|
1401
|
+
if (footerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
1402
1402
|
banner: footerConfig.css,
|
|
1403
|
-
stage:
|
|
1403
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
|
|
1404
1404
|
raw: true,
|
|
1405
1405
|
footer: true,
|
|
1406
1406
|
include: /\.(css)$/
|
|
@@ -1425,7 +1425,7 @@ function composeDecoratorsConfig(compilerOptions, version) {
|
|
|
1425
1425
|
};
|
|
1426
1426
|
}
|
|
1427
1427
|
async function createConstantRsbuildConfig() {
|
|
1428
|
-
return (0,
|
|
1428
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.defineConfig)({
|
|
1429
1429
|
dev: {
|
|
1430
1430
|
progressBar: false
|
|
1431
1431
|
},
|
|
@@ -1514,7 +1514,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1514
1514
|
},
|
|
1515
1515
|
optimization: {
|
|
1516
1516
|
concatenateModules: true,
|
|
1517
|
-
sideEffects: 'flag'
|
|
1517
|
+
sideEffects: 'flag',
|
|
1518
|
+
avoidEntryIife: true
|
|
1518
1519
|
},
|
|
1519
1520
|
output: {
|
|
1520
1521
|
module: true,
|
|
@@ -1589,15 +1590,20 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1589
1590
|
}
|
|
1590
1591
|
case 'mf':
|
|
1591
1592
|
return {
|
|
1593
|
+
dev: {
|
|
1594
|
+
writeToDisk: true
|
|
1595
|
+
},
|
|
1592
1596
|
tools: {
|
|
1593
|
-
rspack: {
|
|
1594
|
-
output
|
|
1597
|
+
rspack: (config, { env })=>{
|
|
1598
|
+
config.output = {
|
|
1599
|
+
...config.output,
|
|
1595
1600
|
uniqueName: pkgJson.name
|
|
1596
|
-
}
|
|
1597
|
-
optimization
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
+
};
|
|
1602
|
+
config.optimization = {
|
|
1603
|
+
...config.optimization,
|
|
1604
|
+
nodeEnv: 'development' === env ? 'development' : 'production',
|
|
1605
|
+
moduleIds: 'development' === env ? 'named' : 'deterministic'
|
|
1606
|
+
};
|
|
1601
1607
|
}
|
|
1602
1608
|
},
|
|
1603
1609
|
output: {
|
|
@@ -1675,7 +1681,7 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1675
1681
|
enabledShims
|
|
1676
1682
|
};
|
|
1677
1683
|
};
|
|
1678
|
-
const composeModuleImportWarn = (request)=>`The externalized commonjs request ${
|
|
1684
|
+
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"')}.`;
|
|
1679
1685
|
const composeExternalsConfig = (format, externals)=>{
|
|
1680
1686
|
const externalsTypeMap = {
|
|
1681
1687
|
esm: 'module-import',
|
|
@@ -1716,7 +1722,7 @@ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
|
1716
1722
|
}
|
|
1717
1723
|
}
|
|
1718
1724
|
};
|
|
1719
|
-
const updatedJsExtension = 'string' == typeof updatedConfig.output?.filename?.js && updatedConfig.output?.filename?.js ? (0,
|
|
1725
|
+
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;
|
|
1720
1726
|
return {
|
|
1721
1727
|
config: updatedConfig,
|
|
1722
1728
|
jsExtension: updatedJsExtension,
|
|
@@ -1789,14 +1795,14 @@ const composeEntryConfig = async (entries, bundle, root, cssModulesAuto)=>{
|
|
|
1789
1795
|
const lcp = await calcLongestCommonPath(resolvedEntryFiles);
|
|
1790
1796
|
const outBase = null === lcp ? root : lcp;
|
|
1791
1797
|
function getEntryName(file) {
|
|
1792
|
-
const { dir, name } =
|
|
1793
|
-
const entryFileName =
|
|
1798
|
+
const { dir, name } = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(outBase, file));
|
|
1799
|
+
const entryFileName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, name);
|
|
1794
1800
|
if (isCssGlobalFile(file, cssModulesAuto)) return `${RSLIB_CSS_ENTRY_FLAG}/${entryFileName}`;
|
|
1795
1801
|
return entryFileName;
|
|
1796
1802
|
}
|
|
1797
1803
|
for (const file of resolvedEntryFiles){
|
|
1798
1804
|
const entryName = getEntryName(file);
|
|
1799
|
-
if (resolvedEntries[entryName])
|
|
1805
|
+
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`);
|
|
1800
1806
|
resolvedEntries[entryName] = file;
|
|
1801
1807
|
}
|
|
1802
1808
|
}
|
|
@@ -1835,17 +1841,15 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1835
1841
|
let resolvedRequest = request;
|
|
1836
1842
|
const cssExternal = cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, isStyleRedirected);
|
|
1837
1843
|
if (false !== cssExternal) return cssExternal;
|
|
1838
|
-
if (jsRedirectPath) {
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
} catch (e) {
|
|
1842
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug(`Failed to resolve ${resolvedRequest} with resolver`);
|
|
1843
|
-
}
|
|
1844
|
-
resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].dirname(contextInfo.issuer), resolvedRequest));
|
|
1844
|
+
if (jsRedirectPath) try {
|
|
1845
|
+
resolvedRequest = await resolver(context, resolvedRequest);
|
|
1846
|
+
resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(contextInfo.issuer), resolvedRequest));
|
|
1845
1847
|
if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
|
|
1848
|
+
} catch (e) {
|
|
1849
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Failed to resolve module ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(`"${resolvedRequest}"`)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(contextInfo.issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`);
|
|
1846
1850
|
}
|
|
1847
|
-
if (jsRedirectExtension) {
|
|
1848
|
-
const ext = (0,
|
|
1851
|
+
if (jsRedirectExtension && resolvedRequest.startsWith('.')) {
|
|
1852
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(resolvedRequest);
|
|
1849
1853
|
if (ext) {
|
|
1850
1854
|
if (!JS_EXTENSIONS_PATTERN.test(resolvedRequest)) return callback();
|
|
1851
1855
|
resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
@@ -1941,7 +1945,7 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
1941
1945
|
...Object.keys(pkgJson?.devDependencies ?? [])
|
|
1942
1946
|
];
|
|
1943
1947
|
if (!deps.includes(SWC_HELPERS)) {
|
|
1944
|
-
|
|
1948
|
+
__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.`);
|
|
1945
1949
|
process.exit(1);
|
|
1946
1950
|
}
|
|
1947
1951
|
defaultConfig = Object.assign(defaultConfig, {
|
|
@@ -1990,14 +1994,14 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
1990
1994
|
const minifyConfig = composeMinifyConfig(config);
|
|
1991
1995
|
const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
|
|
1992
1996
|
const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
|
|
1993
|
-
return (0,
|
|
1997
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(formatConfig, shimsConfig, syntaxConfig, externalHelpersConfig, autoExtensionConfig, targetConfig, externalsWarnConfig, autoExternalConfig, targetExternalsConfig, userExternalsConfig, bundlelessExternalConfig, entryConfig, cssConfig, assetConfig, entryChunkConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig);
|
|
1994
1998
|
}
|
|
1995
1999
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
1996
2000
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
1997
2001
|
const { lib: libConfigsArray, mode, root, plugins: sharedPlugins, dev, server, ...sharedRsbuildConfig } = rslibConfig;
|
|
1998
2002
|
if (!libConfigsArray) throw new Error(`Expect lib field to be an array, but got ${libConfigsArray}.`);
|
|
1999
2003
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
2000
|
-
const userConfig = (0,
|
|
2004
|
+
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
2001
2005
|
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, root, sharedPlugins);
|
|
2002
2006
|
userConfig.source ??= {};
|
|
2003
2007
|
userConfig.source.entry = {};
|
|
@@ -2005,7 +2009,7 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
2005
2009
|
delete userConfig.output.externals;
|
|
2006
2010
|
const config = {
|
|
2007
2011
|
format: libConfig.format,
|
|
2008
|
-
config: (0,
|
|
2012
|
+
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
2009
2013
|
id: true,
|
|
2010
2014
|
bundle: true,
|
|
2011
2015
|
format: true,
|
|
@@ -2092,15 +2096,15 @@ const clearConsole = ()=>{
|
|
|
2092
2096
|
const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
2093
2097
|
if (clear) clearConsole();
|
|
2094
2098
|
if (filePath) {
|
|
2095
|
-
const filename =
|
|
2096
|
-
|
|
2097
|
-
} else
|
|
2099
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
2100
|
+
__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`);
|
|
2101
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('Restarting...\n');
|
|
2098
2102
|
for (const cleaner of cleaners)await cleaner();
|
|
2099
2103
|
cleaners = [];
|
|
2100
2104
|
};
|
|
2101
2105
|
async function build(config, options = {}) {
|
|
2102
2106
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2103
|
-
const rsbuildInstance = await (0,
|
|
2107
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2104
2108
|
rsbuildConfig: {
|
|
2105
2109
|
mode: 'production',
|
|
2106
2110
|
root: config.root,
|
|
@@ -2118,13 +2122,13 @@ async function build(config, options = {}) {
|
|
|
2118
2122
|
return rsbuildInstance;
|
|
2119
2123
|
}
|
|
2120
2124
|
const getEnvDir = (cwd, envDir)=>{
|
|
2121
|
-
if (envDir) return
|
|
2125
|
+
if (envDir) return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(cwd, envDir);
|
|
2122
2126
|
return cwd;
|
|
2123
2127
|
};
|
|
2124
2128
|
async function init(options) {
|
|
2125
2129
|
const cwd = process.cwd();
|
|
2126
2130
|
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
2127
|
-
const envs = (0,
|
|
2131
|
+
const envs = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadEnv)({
|
|
2128
2132
|
cwd: getEnvDir(root, options.envDir),
|
|
2129
2133
|
mode: options.envMode
|
|
2130
2134
|
});
|
|
@@ -2151,7 +2155,7 @@ async function init(options) {
|
|
|
2151
2155
|
}
|
|
2152
2156
|
async function inspect(config, options = {}) {
|
|
2153
2157
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2154
|
-
const rsbuildInstance = await (0,
|
|
2158
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2155
2159
|
rsbuildConfig: {
|
|
2156
2160
|
mode: 'production',
|
|
2157
2161
|
root: config.root,
|
|
@@ -2182,24 +2186,13 @@ async function initMFRsbuild(config, options = {}) {
|
|
|
2182
2186
|
}).map((env)=>env.id);
|
|
2183
2187
|
if (!selectedEnvironmentIds.length) throw new Error('No mf format found, please check your config.');
|
|
2184
2188
|
const selectedEnvironments = pruneEnvironments(environments, selectedEnvironmentIds);
|
|
2185
|
-
const rsbuildInstance = await (0,
|
|
2189
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
|
|
2186
2190
|
rsbuildConfig: {
|
|
2187
2191
|
mode: 'development',
|
|
2188
2192
|
root: config.root,
|
|
2189
2193
|
plugins: config.plugins,
|
|
2190
|
-
dev:
|
|
2191
|
-
...config.dev ?? {},
|
|
2192
|
-
writeToDisk: true
|
|
2193
|
-
},
|
|
2194
|
+
dev: config.dev,
|
|
2194
2195
|
server: config.server,
|
|
2195
|
-
tools: {
|
|
2196
|
-
rspack: {
|
|
2197
|
-
optimization: {
|
|
2198
|
-
nodeEnv: 'development',
|
|
2199
|
-
moduleIds: 'named'
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
},
|
|
2203
2196
|
environments: selectedEnvironments
|
|
2204
2197
|
}
|
|
2205
2198
|
});
|
|
@@ -2214,10 +2207,10 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2214
2207
|
value
|
|
2215
2208
|
]);
|
|
2216
2209
|
function runCli() {
|
|
2217
|
-
|
|
2218
|
-
const buildCommand =
|
|
2219
|
-
const inspectCommand =
|
|
2220
|
-
const mfDevCommand =
|
|
2210
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.2.1");
|
|
2211
|
+
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2212
|
+
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2213
|
+
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
2221
2214
|
[
|
|
2222
2215
|
buildCommand,
|
|
2223
2216
|
inspectCommand,
|
|
@@ -2234,8 +2227,8 @@ function runCli() {
|
|
|
2234
2227
|
};
|
|
2235
2228
|
await cliBuild();
|
|
2236
2229
|
} catch (err) {
|
|
2237
|
-
|
|
2238
|
-
|
|
2230
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to build.');
|
|
2231
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2239
2232
|
process.exit(1);
|
|
2240
2233
|
}
|
|
2241
2234
|
});
|
|
@@ -2249,8 +2242,8 @@ function runCli() {
|
|
|
2249
2242
|
verbose: options.verbose
|
|
2250
2243
|
});
|
|
2251
2244
|
} catch (err) {
|
|
2252
|
-
|
|
2253
|
-
|
|
2245
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to inspect config.');
|
|
2246
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2254
2247
|
process.exit(1);
|
|
2255
2248
|
}
|
|
2256
2249
|
});
|
|
@@ -2267,13 +2260,13 @@ function runCli() {
|
|
|
2267
2260
|
};
|
|
2268
2261
|
await cliMfDev();
|
|
2269
2262
|
} catch (err) {
|
|
2270
|
-
|
|
2271
|
-
|
|
2263
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start mf-dev.');
|
|
2264
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
|
|
2272
2265
|
process.exit(1);
|
|
2273
2266
|
}
|
|
2274
2267
|
});
|
|
2275
|
-
|
|
2268
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2276
2269
|
}
|
|
2277
|
-
const src_rslib_entry_version = "0.2.
|
|
2278
|
-
var __webpack_exports__logger =
|
|
2270
|
+
const src_rslib_entry_version = "0.2.1";
|
|
2271
|
+
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2279
2272
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
2
2
|
const BASE_URI = 'webpack://';
|
|
3
3
|
const MODULE_TYPE = 'css/mini-extract';
|
|
4
4
|
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
@@ -96,17 +96,17 @@ const pitch = function(request, _, _data) {
|
|
|
96
96
|
let resultSource = `// extracted by ${LOADER_NAME}`;
|
|
97
97
|
let importCssFiles = '';
|
|
98
98
|
function getRelativePath(from, to) {
|
|
99
|
-
let relativePath =
|
|
100
|
-
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !
|
|
99
|
+
let relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(from, to);
|
|
100
|
+
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(relativePath)) relativePath = `./${relativePath}`;
|
|
101
101
|
return relativePath;
|
|
102
102
|
}
|
|
103
103
|
const m = new Map();
|
|
104
104
|
for (const { content, filepath } of dependencies){
|
|
105
105
|
let distFilepath = getRelativePath(rootDir, filepath);
|
|
106
|
-
const ext = (0,
|
|
106
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(distFilepath);
|
|
107
107
|
if ('css' !== ext) distFilepath = distFilepath.replace(ext, '.css');
|
|
108
108
|
distFilepath = distFilepath.replace(/\.module\.css/, '_module.css');
|
|
109
|
-
const cssFilename =
|
|
109
|
+
const cssFilename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(distFilepath);
|
|
110
110
|
if (content.trim()) {
|
|
111
111
|
m.get(distFilepath) ? m.set(distFilepath, `${m.get(distFilepath) + content}\n`) : m.set(distFilepath, `${content}\n`);
|
|
112
112
|
importCssFiles += '\n';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.1.
|
|
35
|
+
"@rsbuild/core": "~1.1.13",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.2.
|
|
37
|
+
"rsbuild-plugin-dts": "0.2.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
+
"@module-federation/rsbuild-plugin": "^0.8.5",
|
|
40
41
|
"@types/fs-extra": "^11.0.4",
|
|
41
42
|
"chokidar": "^4.0.3",
|
|
42
43
|
"commander": "^12.1.0",
|
|
@@ -45,10 +46,10 @@
|
|
|
45
46
|
"picocolors": "1.1.1",
|
|
46
47
|
"prebundle": "1.2.5",
|
|
47
48
|
"rsbuild-plugin-publint": "^0.2.1",
|
|
48
|
-
"rslib": "npm:@rslib/core@0.
|
|
49
|
+
"rslib": "npm:@rslib/core@0.2.0",
|
|
49
50
|
"rslog": "^1.2.3",
|
|
50
51
|
"tsconfck": "3.1.4",
|
|
51
|
-
"typescript": "^5.
|
|
52
|
+
"typescript": "^5.7.2",
|
|
52
53
|
"@rslib/tsconfig": "0.0.1"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|