@rslib/core 0.5.5 → 0.6.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 +72 -85
- package/dist-types/index.d.ts +2 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -184,7 +184,7 @@ function prepareCli() {
|
|
|
184
184
|
initNodeEnv();
|
|
185
185
|
const { npm_execpath } = process.env;
|
|
186
186
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
187
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.
|
|
187
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.6.1\n`);
|
|
188
188
|
}
|
|
189
189
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
190
190
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -234,17 +234,16 @@ function getUndoPath(filename, outputPathArg, enforceRelative) {
|
|
|
234
234
|
let depth = -1;
|
|
235
235
|
let append = '';
|
|
236
236
|
let outputPath = outputPathArg.replace(/[\\/]$/, '');
|
|
237
|
-
for (const part of filename.split(/[/\\]+/))if ('..' === part)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} else if ('.' !== part) depth++;
|
|
237
|
+
for (const part of filename.split(/[/\\]+/))if ('..' === part) if (depth > -1) depth--;
|
|
238
|
+
else {
|
|
239
|
+
const i = outputPath.lastIndexOf('/');
|
|
240
|
+
const j = outputPath.lastIndexOf('\\');
|
|
241
|
+
const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
|
|
242
|
+
if (pos < 0) return `${outputPath}/`;
|
|
243
|
+
append = `${outputPath.slice(pos + 1)}/${append}`;
|
|
244
|
+
outputPath = outputPath.slice(0, pos);
|
|
245
|
+
}
|
|
246
|
+
else if ('.' !== part) depth++;
|
|
248
247
|
return depth > 0 ? `${'../'.repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
|
|
249
248
|
}
|
|
250
249
|
const LibSvgrPatchPlugin_pluginName = 'LIB_SVGR_PATCH_PLUGIN';
|
|
@@ -339,19 +338,17 @@ const pluginLibAsset = ({ bundle })=>({
|
|
|
339
338
|
});
|
|
340
339
|
config.plugin(LibSvgrPatchPlugin.name).use(LibSvgrPatchPlugin, []);
|
|
341
340
|
}
|
|
342
|
-
if (isUsingSvgr) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
rule.issuer([]);
|
|
354
|
-
}
|
|
341
|
+
if (isUsingSvgr) if (bundle) {
|
|
342
|
+
const rule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG_URL);
|
|
343
|
+
const originalGeneratorOptions = rule.get('generator');
|
|
344
|
+
const generatorOptions = isUserSetPublicPath ? originalGeneratorOptions : {
|
|
345
|
+
...originalGeneratorOptions,
|
|
346
|
+
importMode: 'preserve'
|
|
347
|
+
};
|
|
348
|
+
rule.generator(generatorOptions);
|
|
349
|
+
} else {
|
|
350
|
+
const rule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG);
|
|
351
|
+
rule.issuer([]);
|
|
355
352
|
}
|
|
356
353
|
if (bundle) config.plugins.get(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT)?.tap((options)=>[
|
|
357
354
|
{
|
|
@@ -552,15 +549,11 @@ class EntryChunkPlugin {
|
|
|
552
549
|
this.contextToWatch = contextToWatch;
|
|
553
550
|
}
|
|
554
551
|
apply(compiler) {
|
|
555
|
-
compiler.hooks.afterCompile.
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const contextDep = compilation.contextDependencies;
|
|
561
|
-
if (!contextDep.has(this.contextToWatch)) contextDep.add(this.contextToWatch);
|
|
562
|
-
resolve();
|
|
563
|
-
}));
|
|
552
|
+
compiler.hooks.afterCompile.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
553
|
+
if (null === this.contextToWatch) return;
|
|
554
|
+
const contextDep = compilation.contextDependencies;
|
|
555
|
+
if (!contextDep.has(this.contextToWatch)) contextDep.add(this.contextToWatch);
|
|
556
|
+
});
|
|
564
557
|
compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
565
558
|
const entries = {};
|
|
566
559
|
for (const [key, value] of compilation.entries){
|
|
@@ -1049,19 +1042,17 @@ async function find(filename, options) {
|
|
|
1049
1042
|
}
|
|
1050
1043
|
function findUp(dir, { resolve, reject, promise }, options) {
|
|
1051
1044
|
const { cache, root, configName } = options ?? {};
|
|
1052
|
-
if (cache) {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
} else cache.setConfigPath(dir, promise, configName);
|
|
1064
|
-
}
|
|
1045
|
+
if (cache) if (cache.hasConfigPath(dir, configName)) {
|
|
1046
|
+
let cached;
|
|
1047
|
+
try {
|
|
1048
|
+
cached = cache.getConfigPath(dir, configName);
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
reject(e);
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
if (cached?.then) cached.then(resolve).catch(reject);
|
|
1054
|
+
else resolve(cached);
|
|
1055
|
+
} else cache.setConfigPath(dir, promise, configName);
|
|
1065
1056
|
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, options?.configName ?? 'tsconfig.json');
|
|
1066
1057
|
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].stat(tsconfig, (err, stats)=>{
|
|
1067
1058
|
if (stats && (stats.isFile() || stats.isFIFO())) resolve(tsconfig);
|
|
@@ -1138,36 +1129,33 @@ function stripJsonComments(jsonString) {
|
|
|
1138
1129
|
const escaped = isEscaped(jsonString, index);
|
|
1139
1130
|
if (!escaped) isInsideString = !isInsideString;
|
|
1140
1131
|
}
|
|
1141
|
-
if (!isInsideString) {
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
} else if (isInsideComment || currentCharacter + nextCharacter !== '/*') {
|
|
1153
|
-
if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
1154
|
-
index++;
|
|
1155
|
-
isInsideComment = false;
|
|
1156
|
-
result += strip(jsonString, offset, index + 1);
|
|
1157
|
-
offset = index + 1;
|
|
1158
|
-
}
|
|
1159
|
-
} else {
|
|
1160
|
-
result += jsonString.slice(offset, index);
|
|
1161
|
-
offset = index;
|
|
1162
|
-
isInsideComment = multiComment;
|
|
1163
|
-
index++;
|
|
1164
|
-
}
|
|
1165
|
-
} else {
|
|
1166
|
-
result += jsonString.slice(offset, index);
|
|
1167
|
-
offset = index;
|
|
1168
|
-
isInsideComment = singleComment;
|
|
1132
|
+
if (!isInsideString) if (isInsideComment || currentCharacter + nextCharacter !== '//') if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
|
|
1133
|
+
index++;
|
|
1134
|
+
isInsideComment = false;
|
|
1135
|
+
result += strip(jsonString, offset, index);
|
|
1136
|
+
offset = index;
|
|
1137
|
+
} else if (isInsideComment === singleComment && '\n' === currentCharacter) {
|
|
1138
|
+
isInsideComment = false;
|
|
1139
|
+
result += strip(jsonString, offset, index);
|
|
1140
|
+
offset = index;
|
|
1141
|
+
} else if (isInsideComment || currentCharacter + nextCharacter !== '/*') {
|
|
1142
|
+
if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
1169
1143
|
index++;
|
|
1144
|
+
isInsideComment = false;
|
|
1145
|
+
result += strip(jsonString, offset, index + 1);
|
|
1146
|
+
offset = index + 1;
|
|
1170
1147
|
}
|
|
1148
|
+
} else {
|
|
1149
|
+
result += jsonString.slice(offset, index);
|
|
1150
|
+
offset = index;
|
|
1151
|
+
isInsideComment = multiComment;
|
|
1152
|
+
index++;
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
result += jsonString.slice(offset, index);
|
|
1156
|
+
offset = index;
|
|
1157
|
+
isInsideComment = singleComment;
|
|
1158
|
+
index++;
|
|
1171
1159
|
}
|
|
1172
1160
|
}
|
|
1173
1161
|
return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
|
|
@@ -1320,12 +1308,10 @@ function extendTSConfig(extending, extended) {
|
|
|
1320
1308
|
for (const key of Object.keys(extendedConfig).filter((key)=>EXTENDABLE_KEYS.includes(key)))if ('compilerOptions' === key) {
|
|
1321
1309
|
if (!extendingConfig.compilerOptions) extendingConfig.compilerOptions = {};
|
|
1322
1310
|
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);
|
|
1323
|
-
} else if (void 0 === extendingConfig[key]) {
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
} else extendingConfig[key] = rebaseRelative(key, extendedConfig[key], relativePath);
|
|
1328
|
-
}
|
|
1311
|
+
} else if (void 0 === extendingConfig[key]) if ('watchOptions' === key) {
|
|
1312
|
+
extendingConfig.watchOptions = {};
|
|
1313
|
+
for (const option of Object.keys(extendedConfig.watchOptions))extendingConfig.watchOptions[option] = rebaseRelative(option, extendedConfig.watchOptions[option], relativePath);
|
|
1314
|
+
} else extendingConfig[key] = rebaseRelative(key, extendedConfig[key], relativePath);
|
|
1329
1315
|
}
|
|
1330
1316
|
const REBASE_KEYS = [
|
|
1331
1317
|
'files',
|
|
@@ -1746,7 +1732,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1746
1732
|
iife: false,
|
|
1747
1733
|
chunkFormat: 'commonjs',
|
|
1748
1734
|
library: {
|
|
1749
|
-
type: 'commonjs'
|
|
1735
|
+
type: 'commonjs-static'
|
|
1750
1736
|
},
|
|
1751
1737
|
chunkLoading: 'require',
|
|
1752
1738
|
workerChunkLoading: 'async-node',
|
|
@@ -2481,7 +2467,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2481
2467
|
value
|
|
2482
2468
|
]);
|
|
2483
2469
|
function runCli() {
|
|
2484
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.
|
|
2470
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.6.1");
|
|
2485
2471
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2486
2472
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2487
2473
|
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
@@ -2542,6 +2528,7 @@ function runCli() {
|
|
|
2542
2528
|
});
|
|
2543
2529
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2544
2530
|
}
|
|
2545
|
-
const src_rslib_entry_version = "0.
|
|
2531
|
+
const src_rslib_entry_version = "0.6.1";
|
|
2546
2532
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2547
|
-
|
|
2533
|
+
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
2534
|
+
export { build, defineConfig, inspect, loadConfig, prepareCli, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ as rsbuild, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|
package/dist-types/index.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export { defineConfig, loadConfig, composeCreateRsbuildConfig as unstable_compos
|
|
|
7
7
|
export { logger } from './utils/logger';
|
|
8
8
|
export type * from './types';
|
|
9
9
|
export declare const version: string;
|
|
10
|
+
export { rspack, type Rspack } from '@rsbuild/core';
|
|
11
|
+
export * as rsbuild from '@rsbuild/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "
|
|
39
|
+
"@rsbuild/core": "1.3.1",
|
|
40
40
|
"tinyglobby": "^0.2.12",
|
|
41
|
-
"rsbuild-plugin-dts": "0.
|
|
41
|
+
"rsbuild-plugin-dts": "0.6.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.11.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.11.2",
|
|
45
45
|
"@types/fs-extra": "^11.0.4",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
47
47
|
"commander": "^13.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
51
|
"prebundle": "1.2.7",
|
|
52
52
|
"rsbuild-plugin-publint": "^0.3.0",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.6.0",
|
|
54
54
|
"rslog": "^1.2.3",
|
|
55
55
|
"tsconfck": "3.1.5",
|
|
56
56
|
"typescript": "^5.8.2",
|