@rslib/core 0.5.2 → 0.5.4
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 +26 -15
- package/dist-types/types/config.d.ts +7 -7
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -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
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.5.
|
|
163
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.5.4\n`);
|
|
164
164
|
}
|
|
165
165
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
166
166
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -315,8 +315,16 @@ const pluginLibAsset = ({ bundle })=>({
|
|
|
315
315
|
});
|
|
316
316
|
config.plugin(LibSvgrPatchPlugin.name).use(LibSvgrPatchPlugin, []);
|
|
317
317
|
}
|
|
318
|
-
if (
|
|
319
|
-
if (
|
|
318
|
+
if (isUsingSvgr) {
|
|
319
|
+
if (bundle) {
|
|
320
|
+
const rule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG_URL);
|
|
321
|
+
const originalGeneratorOptions = rule.get('generator');
|
|
322
|
+
const generatorOptions = isUserSetPublicPath ? originalGeneratorOptions : {
|
|
323
|
+
...originalGeneratorOptions,
|
|
324
|
+
importMode: 'preserve'
|
|
325
|
+
};
|
|
326
|
+
rule.generator(generatorOptions);
|
|
327
|
+
} else {
|
|
320
328
|
const rule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG);
|
|
321
329
|
rule.issuer([]);
|
|
322
330
|
}
|
|
@@ -369,14 +377,6 @@ class LibCssExtractPlugin {
|
|
|
369
377
|
this.options = options ?? {};
|
|
370
378
|
}
|
|
371
379
|
apply(compiler) {
|
|
372
|
-
compiler.hooks.thisCompilation.tap(LibCssExtractPlugin_pluginName, (compilation)=>{
|
|
373
|
-
compilation.hooks.chunkAsset.tap(LibCssExtractPlugin_pluginName, (_chunk, filename)=>{
|
|
374
|
-
const asset = compilation.getAsset(filename);
|
|
375
|
-
if (!asset) return;
|
|
376
|
-
const needRemove = Boolean(asset.name.match(RSLIB_CSS_ENTRY_FLAG));
|
|
377
|
-
if (needRemove) compilation.deleteAsset(filename);
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
380
|
compiler.hooks.make.tap(LibCssExtractPlugin_pluginName, (compilation)=>{
|
|
381
381
|
compilation.hooks.processAssets.tap(LibCssExtractPlugin_pluginName, (assets)=>{
|
|
382
382
|
const chunkAsset = Object.keys(assets).filter((name)=>/\.css/.test(name));
|
|
@@ -454,6 +454,11 @@ const cssConfig_PLUGIN_NAME = 'rsbuild:lib-css';
|
|
|
454
454
|
const pluginLibCss = (rootDir, banner, footer)=>({
|
|
455
455
|
name: cssConfig_PLUGIN_NAME,
|
|
456
456
|
setup (api) {
|
|
457
|
+
api.processAssets({
|
|
458
|
+
stage: 'additional'
|
|
459
|
+
}, ({ assets, compilation })=>{
|
|
460
|
+
for (const key of Object.keys(assets))if (key.match(RSLIB_CSS_ENTRY_FLAG)) compilation.deleteAsset(key);
|
|
461
|
+
});
|
|
457
462
|
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
458
463
|
let isUsingCssExtract = false;
|
|
459
464
|
for (const ruleId of [
|
|
@@ -1880,10 +1885,16 @@ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
|
1880
1885
|
pkgJson,
|
|
1881
1886
|
autoExtension
|
|
1882
1887
|
});
|
|
1888
|
+
const filenameHash = config.output?.filenameHash ?? false;
|
|
1889
|
+
const getHash = ()=>{
|
|
1890
|
+
if ('string' == typeof filenameHash) return filenameHash ? `.[${filenameHash}]` : '';
|
|
1891
|
+
return filenameHash ? '.[contenthash:8]' : '';
|
|
1892
|
+
};
|
|
1893
|
+
const hash = getHash();
|
|
1883
1894
|
const updatedConfig = {
|
|
1884
1895
|
output: {
|
|
1885
1896
|
filename: {
|
|
1886
|
-
js: `[name]${jsExtension}`,
|
|
1897
|
+
js: `[name]${hash}${jsExtension}`,
|
|
1887
1898
|
...config.output?.filename
|
|
1888
1899
|
}
|
|
1889
1900
|
}
|
|
@@ -2233,7 +2244,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2233
2244
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
2234
2245
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
2235
2246
|
const { lib: libConfigsArray, mode, root, plugins: sharedPlugins, dev, server, ...sharedRsbuildConfig } = rslibConfig;
|
|
2236
|
-
if (!libConfigsArray) throw new Error(`Expect lib field to be
|
|
2247
|
+
if (!Array.isArray(libConfigsArray) || 0 === libConfigsArray.length) throw new Error(`Expect "lib" field to be a non-empty array, but got: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].cyan(JSON.stringify(libConfigsArray))}.`);
|
|
2237
2248
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
2238
2249
|
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
2239
2250
|
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, root, sharedPlugins);
|
|
@@ -2444,7 +2455,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2444
2455
|
value
|
|
2445
2456
|
]);
|
|
2446
2457
|
function runCli() {
|
|
2447
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.5.
|
|
2458
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.5.4");
|
|
2448
2459
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2449
2460
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2450
2461
|
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
@@ -2505,6 +2516,6 @@ function runCli() {
|
|
|
2505
2516
|
});
|
|
2506
2517
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2507
2518
|
}
|
|
2508
|
-
const src_rslib_entry_version = "0.5.
|
|
2519
|
+
const src_rslib_entry_version = "0.5.4";
|
|
2509
2520
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2510
2521
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|
|
@@ -16,31 +16,31 @@ export type RsbuildConfigOutputTarget = NonNullable<EnvironmentConfig['output']>
|
|
|
16
16
|
export type Syntax = EcmaScriptVersion | string[];
|
|
17
17
|
export type Dts = {
|
|
18
18
|
/**
|
|
19
|
-
* Whether to bundle the
|
|
19
|
+
* Whether to bundle the declaration files.
|
|
20
20
|
* @defaultValue `false`
|
|
21
21
|
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsbundle}
|
|
22
22
|
*/
|
|
23
23
|
bundle?: boolean;
|
|
24
24
|
/**
|
|
25
|
-
* The output directory of
|
|
25
|
+
* The output directory of declaration files.
|
|
26
26
|
* @defaultValue {@link https://lib.rsbuild.dev/config/lib/dts#default-value}
|
|
27
27
|
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsdistpath}
|
|
28
28
|
*/
|
|
29
29
|
distPath?: string;
|
|
30
30
|
/**
|
|
31
|
-
* Whether to generate
|
|
31
|
+
* Whether to generate declaration files with building the project references.
|
|
32
32
|
* @defaultValue `false`
|
|
33
33
|
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsbuild}
|
|
34
34
|
*/
|
|
35
35
|
build?: boolean;
|
|
36
36
|
/**
|
|
37
|
-
* Whether to abort the build process when an error occurs during
|
|
37
|
+
* Whether to abort the build process when an error occurs during declaration files generation.
|
|
38
38
|
* @defaultValue `true`
|
|
39
39
|
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsabortonerror}
|
|
40
40
|
*/
|
|
41
41
|
abortOnError?: boolean;
|
|
42
42
|
/**
|
|
43
|
-
* Whether to automatically set the
|
|
43
|
+
* Whether to automatically set the declaration file extension based on the {@link format} option.
|
|
44
44
|
* @defaultValue `false`
|
|
45
45
|
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsautoextension}
|
|
46
46
|
*/
|
|
@@ -211,13 +211,13 @@ export interface LibConfig extends EnvironmentConfig {
|
|
|
211
211
|
*/
|
|
212
212
|
externalHelpers?: boolean;
|
|
213
213
|
/**
|
|
214
|
-
* Inject content into the top of each JavaScript, CSS or
|
|
214
|
+
* Inject content into the top of each JavaScript, CSS or declaration file.
|
|
215
215
|
* @defaultValue `{}`
|
|
216
216
|
* @see {@link https://lib.rsbuild.dev/config/lib/banner}
|
|
217
217
|
*/
|
|
218
218
|
banner?: BannerAndFooter;
|
|
219
219
|
/**
|
|
220
|
-
* Inject content into the bottom of each JavaScript, CSS or
|
|
220
|
+
* Inject content into the bottom of each JavaScript, CSS or declaration file.
|
|
221
221
|
* @defaultValue `{}`
|
|
222
222
|
* @see {@link https://lib.rsbuild.dev/config/lib/footer}
|
|
223
223
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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": "~1.2.
|
|
39
|
+
"@rsbuild/core": "~1.2.16",
|
|
40
40
|
"tinyglobby": "^0.2.12",
|
|
41
|
-
"rsbuild-plugin-dts": "0.5.
|
|
41
|
+
"rsbuild-plugin-dts": "0.5.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.10.0",
|
|
45
45
|
"@types/fs-extra": "^11.0.4",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
47
47
|
"commander": "^13.1.0",
|
|
@@ -50,10 +50,10 @@
|
|
|
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.5.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.5.3",
|
|
54
54
|
"rslog": "^1.2.3",
|
|
55
55
|
"tsconfck": "3.1.5",
|
|
56
|
-
"typescript": "^5.
|
|
56
|
+
"typescript": "^5.8.2",
|
|
57
57
|
"@rslib/tsconfig": "0.0.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|