@rslib/core 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +112 -113
- package/dist/libCssExtractLoader.js +5 -5
- package/package.json +2 -2
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__ from "../compiled/rslog/index.js";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs__ from "node:fs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises__ from "node:fs/promises";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__ from "../compiled/picocolors/index.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__ from "../compiled/commander/index.js";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core__ from "@rsbuild/core";
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
9
|
-
import * as
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module__ 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__["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__["default"].stat(lca);
|
|
83
|
+
if (stats?.isFile()) lca = __WEBPACK_EXTERNAL_MODULE_node_path__["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__.isAbsolute)(filepath) ? filepath : (0, __WEBPACK_EXTERNAL_MODULE_node_path__.join)(base, filepath);
|
|
88
88
|
}
|
|
89
89
|
const readPackageJson = (rootPath)=>{
|
|
90
|
-
const pkgJsonPath =
|
|
91
|
-
if (!
|
|
92
|
-
|
|
90
|
+
const pkgJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].join(rootPath, './package.json');
|
|
91
|
+
if (!__WEBPACK_EXTERNAL_MODULE_node_fs__["default"].existsSync(pkgJsonPath)) {
|
|
92
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.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__["default"].readFileSync(pkgJsonPath, 'utf8'));
|
|
97
97
|
} catch (err) {
|
|
98
|
-
|
|
98
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.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__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green('format: "mf"')} should be used with ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["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__.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__.logger.greet(` Rslib v0.2.2\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__.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__.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__["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__.rspack.BannerPlugin({
|
|
386
386
|
banner: requireShim,
|
|
387
|
-
stage:
|
|
387
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.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__.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__.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__.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__.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__.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__.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__["default"].posix.sep, 'g');
|
|
703
|
+
const NATIVE_SEP_RE = new RegExp('\\' + __WEBPACK_EXTERNAL_MODULE_node_path__["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__["default"].posix.sep === __WEBPACK_EXTERNAL_MODULE_node_path__["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__["default"].extname(filename)) return;
|
|
736
|
+
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(filename);
|
|
737
737
|
if (cache && (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename))) return tsconfig;
|
|
738
|
-
return
|
|
738
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs__.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__["default"].sep);
|
|
745
|
+
const util_native2posix = IS_POSIX ? (filename)=>filename : (filename)=>filename.replace(NATIVE_SEP_RE, __WEBPACK_EXTERNAL_MODULE_node_path__["default"].posix.sep);
|
|
746
|
+
const resolve2posix = IS_POSIX ? (dir, filename)=>dir ? __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(dir, filename) : __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(filename) : (dir, filename)=>util_native2posix(dir ? __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(posix2native(dir), posix2native(filename)) : __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(posix2native(filename)));
|
|
747
747
|
function util_resolveReferencedTSConfigFiles(result, options) {
|
|
748
|
-
const dir =
|
|
748
|
+
const dir = __WEBPACK_EXTERNAL_MODULE_node_path__["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__["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__["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__["default"].dirname(__WEBPACK_EXTERNAL_MODULE_node_path__["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__["default"].isAbsolute(options.root)) options.root = __WEBPACK_EXTERNAL_MODULE_node_path__["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__["default"].join(dir, options?.configName ?? 'tsconfig.json');
|
|
885
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs__["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__["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__["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__["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__.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__["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__["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__["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__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].dirname(extending.tsconfigFile), __WEBPACK_EXTERNAL_MODULE_node_path__["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__["default"].isAbsolute(value) || value.startsWith('${configDir}')) return value;
|
|
1169
|
+
return __WEBPACK_EXTERNAL_MODULE_node_path__["default"].posix.normalize(__WEBPACK_EXTERNAL_MODULE_node_path__["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__["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__.join)(root, tsconfigPath), {
|
|
1202
1202
|
root,
|
|
1203
|
-
configName: (0,
|
|
1203
|
+
configName: (0, __WEBPACK_EXTERNAL_MODULE_node_path__.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__["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__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path__.join)(root, customConfig);
|
|
1218
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs__["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
1219
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.warn(`Cannot find config file: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].dim(customConfigPath)}\n`);
|
|
1220
1220
|
}
|
|
1221
|
-
const configFilePath = findConfig((0,
|
|
1221
|
+
const configFilePath = findConfig((0, __WEBPACK_EXTERNAL_MODULE_node_path__.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__.loadConfig)({
|
|
1228
|
+
cwd: (0, __WEBPACK_EXTERNAL_MODULE_node_path__.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__.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__.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__.rspack.BannerPlugin({
|
|
1381
1381
|
banner: bannerConfig.js,
|
|
1382
|
-
stage:
|
|
1382
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.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__.rspack.BannerPlugin({
|
|
1387
1387
|
banner: bannerConfig.css,
|
|
1388
|
-
stage:
|
|
1388
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.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__.rspack.BannerPlugin({
|
|
1395
1395
|
banner: footerConfig.js,
|
|
1396
|
-
stage:
|
|
1396
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.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__.rspack.BannerPlugin({
|
|
1402
1402
|
banner: footerConfig.css,
|
|
1403
|
-
stage:
|
|
1403
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.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__.defineConfig)({
|
|
1429
1429
|
dev: {
|
|
1430
1430
|
progressBar: false
|
|
1431
1431
|
},
|
|
@@ -1514,8 +1514,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1514
1514
|
},
|
|
1515
1515
|
optimization: {
|
|
1516
1516
|
concatenateModules: true,
|
|
1517
|
-
sideEffects: 'flag'
|
|
1518
|
-
avoidEntryIife: true
|
|
1517
|
+
sideEffects: 'flag'
|
|
1519
1518
|
},
|
|
1520
1519
|
output: {
|
|
1521
1520
|
module: true,
|
|
@@ -1681,7 +1680,7 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1681
1680
|
enabledShims
|
|
1682
1681
|
};
|
|
1683
1682
|
};
|
|
1684
|
-
const composeModuleImportWarn = (request)=>`The externalized commonjs request ${
|
|
1683
|
+
const composeModuleImportWarn = (request)=>`The externalized commonjs request ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green(`"${request}"`)} will use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["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__["default"].blue('"output.externals"')}.`;
|
|
1685
1684
|
const composeExternalsConfig = (format, externals)=>{
|
|
1686
1685
|
const externalsTypeMap = {
|
|
1687
1686
|
esm: 'module-import',
|
|
@@ -1722,7 +1721,7 @@ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
|
1722
1721
|
}
|
|
1723
1722
|
}
|
|
1724
1723
|
};
|
|
1725
|
-
const updatedJsExtension = 'string' == typeof updatedConfig.output?.filename?.js && updatedConfig.output?.filename?.js ? (0,
|
|
1724
|
+
const updatedJsExtension = 'string' == typeof updatedConfig.output?.filename?.js && updatedConfig.output?.filename?.js ? (0, __WEBPACK_EXTERNAL_MODULE_node_path__.extname)(updatedConfig.output.filename.js) : jsExtension;
|
|
1726
1725
|
return {
|
|
1727
1726
|
config: updatedConfig,
|
|
1728
1727
|
jsExtension: updatedJsExtension,
|
|
@@ -1795,14 +1794,14 @@ const composeEntryConfig = async (entries, bundle, root, cssModulesAuto)=>{
|
|
|
1795
1794
|
const lcp = await calcLongestCommonPath(resolvedEntryFiles);
|
|
1796
1795
|
const outBase = null === lcp ? root : lcp;
|
|
1797
1796
|
function getEntryName(file) {
|
|
1798
|
-
const { dir, name } =
|
|
1799
|
-
const entryFileName =
|
|
1797
|
+
const { dir, name } = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(outBase, file));
|
|
1798
|
+
const entryFileName = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].join(dir, name);
|
|
1800
1799
|
if (isCssGlobalFile(file, cssModulesAuto)) return `${RSLIB_CSS_ENTRY_FLAG}/${entryFileName}`;
|
|
1801
1800
|
return entryFileName;
|
|
1802
1801
|
}
|
|
1803
1802
|
for (const file of resolvedEntryFiles){
|
|
1804
1803
|
const entryName = getEntryName(file);
|
|
1805
|
-
if (resolvedEntries[entryName])
|
|
1804
|
+
if (resolvedEntries[entryName]) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.warn(`duplicate entry: ${entryName}, this may lead to the incorrect output, please rename the file`);
|
|
1806
1805
|
resolvedEntries[entryName] = file;
|
|
1807
1806
|
}
|
|
1808
1807
|
}
|
|
@@ -1843,13 +1842,13 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
1843
1842
|
if (false !== cssExternal) return cssExternal;
|
|
1844
1843
|
if (jsRedirectPath) try {
|
|
1845
1844
|
resolvedRequest = await resolver(context, resolvedRequest);
|
|
1846
|
-
resolvedRequest = normalizeSlash(
|
|
1845
|
+
resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].dirname(contextInfo.issuer), resolvedRequest));
|
|
1847
1846
|
if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
|
|
1848
1847
|
} catch (e) {
|
|
1849
|
-
|
|
1848
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.warn(`Failed to resolve module ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green(`"${resolvedRequest}"`)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green(contextInfo.issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`);
|
|
1850
1849
|
}
|
|
1851
1850
|
if (jsRedirectExtension && resolvedRequest.startsWith('.')) {
|
|
1852
|
-
const ext = (0,
|
|
1851
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path__.extname)(resolvedRequest);
|
|
1853
1852
|
if (ext) {
|
|
1854
1853
|
if (!JS_EXTENSIONS_PATTERN.test(resolvedRequest)) return callback();
|
|
1855
1854
|
resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
@@ -1945,7 +1944,7 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
1945
1944
|
...Object.keys(pkgJson?.devDependencies ?? [])
|
|
1946
1945
|
];
|
|
1947
1946
|
if (!deps.includes(SWC_HELPERS)) {
|
|
1948
|
-
|
|
1947
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green('externalHelpers')} is enabled, but the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].blue(SWC_HELPERS)} dependency declaration was not found in package.json.`);
|
|
1949
1948
|
process.exit(1);
|
|
1950
1949
|
}
|
|
1951
1950
|
defaultConfig = Object.assign(defaultConfig, {
|
|
@@ -1994,14 +1993,14 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
1994
1993
|
const minifyConfig = composeMinifyConfig(config);
|
|
1995
1994
|
const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
|
|
1996
1995
|
const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
|
|
1997
|
-
return (0,
|
|
1996
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(formatConfig, shimsConfig, syntaxConfig, externalHelpersConfig, autoExtensionConfig, targetConfig, externalsWarnConfig, autoExternalConfig, targetExternalsConfig, userExternalsConfig, bundlelessExternalConfig, entryConfig, cssConfig, assetConfig, entryChunkConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig);
|
|
1998
1997
|
}
|
|
1999
1998
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
2000
1999
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
2001
2000
|
const { lib: libConfigsArray, mode, root, plugins: sharedPlugins, dev, server, ...sharedRsbuildConfig } = rslibConfig;
|
|
2002
2001
|
if (!libConfigsArray) throw new Error(`Expect lib field to be an array, but got ${libConfigsArray}.`);
|
|
2003
2002
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
2004
|
-
const userConfig = (0,
|
|
2003
|
+
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
2005
2004
|
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, root, sharedPlugins);
|
|
2006
2005
|
userConfig.source ??= {};
|
|
2007
2006
|
userConfig.source.entry = {};
|
|
@@ -2009,7 +2008,7 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
2009
2008
|
delete userConfig.output.externals;
|
|
2010
2009
|
const config = {
|
|
2011
2010
|
format: libConfig.format,
|
|
2012
|
-
config: (0,
|
|
2011
|
+
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
2013
2012
|
id: true,
|
|
2014
2013
|
bundle: true,
|
|
2015
2014
|
format: true,
|
|
@@ -2096,15 +2095,15 @@ const clearConsole = ()=>{
|
|
|
2096
2095
|
const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
2097
2096
|
if (clear) clearConsole();
|
|
2098
2097
|
if (filePath) {
|
|
2099
|
-
const filename =
|
|
2100
|
-
|
|
2101
|
-
} else
|
|
2098
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].basename(filePath);
|
|
2099
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info(`Restart because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].yellow(filename)} is changed.\n`);
|
|
2100
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.info('Restarting...\n');
|
|
2102
2101
|
for (const cleaner of cleaners)await cleaner();
|
|
2103
2102
|
cleaners = [];
|
|
2104
2103
|
};
|
|
2105
2104
|
async function build(config, options = {}) {
|
|
2106
2105
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2107
|
-
const rsbuildInstance = await (0,
|
|
2106
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
2108
2107
|
rsbuildConfig: {
|
|
2109
2108
|
mode: 'production',
|
|
2110
2109
|
root: config.root,
|
|
@@ -2122,13 +2121,13 @@ async function build(config, options = {}) {
|
|
|
2122
2121
|
return rsbuildInstance;
|
|
2123
2122
|
}
|
|
2124
2123
|
const getEnvDir = (cwd, envDir)=>{
|
|
2125
|
-
if (envDir) return
|
|
2124
|
+
if (envDir) return __WEBPACK_EXTERNAL_MODULE_node_path__["default"].isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(cwd, envDir);
|
|
2126
2125
|
return cwd;
|
|
2127
2126
|
};
|
|
2128
2127
|
async function init(options) {
|
|
2129
2128
|
const cwd = process.cwd();
|
|
2130
2129
|
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
2131
|
-
const envs = (0,
|
|
2130
|
+
const envs = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.loadEnv)({
|
|
2132
2131
|
cwd: getEnvDir(root, options.envDir),
|
|
2133
2132
|
mode: options.envMode
|
|
2134
2133
|
});
|
|
@@ -2155,7 +2154,7 @@ async function init(options) {
|
|
|
2155
2154
|
}
|
|
2156
2155
|
async function inspect(config, options = {}) {
|
|
2157
2156
|
const { environments } = await composeRsbuildEnvironments(config);
|
|
2158
|
-
const rsbuildInstance = await (0,
|
|
2157
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
2159
2158
|
rsbuildConfig: {
|
|
2160
2159
|
mode: 'production',
|
|
2161
2160
|
root: config.root,
|
|
@@ -2186,7 +2185,7 @@ async function initMFRsbuild(config, options = {}) {
|
|
|
2186
2185
|
}).map((env)=>env.id);
|
|
2187
2186
|
if (!selectedEnvironmentIds.length) throw new Error('No mf format found, please check your config.');
|
|
2188
2187
|
const selectedEnvironments = pruneEnvironments(environments, selectedEnvironmentIds);
|
|
2189
|
-
const rsbuildInstance = await (0,
|
|
2188
|
+
const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
|
|
2190
2189
|
rsbuildConfig: {
|
|
2191
2190
|
mode: 'development',
|
|
2192
2191
|
root: config.root,
|
|
@@ -2207,10 +2206,10 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2207
2206
|
value
|
|
2208
2207
|
]);
|
|
2209
2208
|
function runCli() {
|
|
2210
|
-
|
|
2211
|
-
const buildCommand =
|
|
2212
|
-
const inspectCommand =
|
|
2213
|
-
const mfDevCommand =
|
|
2209
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.2.2");
|
|
2210
|
+
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('build');
|
|
2211
|
+
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('inspect');
|
|
2212
|
+
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('mf-dev');
|
|
2214
2213
|
[
|
|
2215
2214
|
buildCommand,
|
|
2216
2215
|
inspectCommand,
|
|
@@ -2227,8 +2226,8 @@ function runCli() {
|
|
|
2227
2226
|
};
|
|
2228
2227
|
await cliBuild();
|
|
2229
2228
|
} catch (err) {
|
|
2230
|
-
|
|
2231
|
-
|
|
2229
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to build.');
|
|
2230
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
2232
2231
|
process.exit(1);
|
|
2233
2232
|
}
|
|
2234
2233
|
});
|
|
@@ -2242,8 +2241,8 @@ function runCli() {
|
|
|
2242
2241
|
verbose: options.verbose
|
|
2243
2242
|
});
|
|
2244
2243
|
} catch (err) {
|
|
2245
|
-
|
|
2246
|
-
|
|
2244
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to inspect config.');
|
|
2245
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
2247
2246
|
process.exit(1);
|
|
2248
2247
|
}
|
|
2249
2248
|
});
|
|
@@ -2260,13 +2259,13 @@ function runCli() {
|
|
|
2260
2259
|
};
|
|
2261
2260
|
await cliMfDev();
|
|
2262
2261
|
} catch (err) {
|
|
2263
|
-
|
|
2264
|
-
|
|
2262
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start mf-dev.');
|
|
2263
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
|
|
2265
2264
|
process.exit(1);
|
|
2266
2265
|
}
|
|
2267
2266
|
});
|
|
2268
|
-
|
|
2267
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.parse();
|
|
2269
2268
|
}
|
|
2270
|
-
const src_rslib_entry_version = "0.2.
|
|
2271
|
-
var __webpack_exports__logger =
|
|
2269
|
+
const src_rslib_entry_version = "0.2.2";
|
|
2270
|
+
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger;
|
|
2272
2271
|
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__ 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__["default"].relative(from, to);
|
|
100
|
+
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !__WEBPACK_EXTERNAL_MODULE_node_path__["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__.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__["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.2",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@rsbuild/core": "~1.1.13",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.2.
|
|
37
|
+
"rsbuild-plugin-dts": "0.2.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@module-federation/rsbuild-plugin": "^0.8.5",
|