@rslib/core 0.12.2 → 0.12.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 +59 -10
- package/dist-types/config.d.ts +2 -1
- package/dist-types/utils/helper.d.ts +1 -0
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -312,6 +312,7 @@ const pluginLibCss = (rootDir, auto, banner, footer)=>({
|
|
|
312
312
|
CHAIN_ID.RULE.LESS,
|
|
313
313
|
CHAIN_ID.RULE.STYLUS
|
|
314
314
|
]){
|
|
315
|
+
if (!config.module.rules.has(ruleId)) continue;
|
|
315
316
|
const rule = config.module.rule(ruleId);
|
|
316
317
|
if (rule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT)) {
|
|
317
318
|
isUsingCssExtract = true;
|
|
@@ -695,6 +696,14 @@ const windowsSlashRegex = /\\/g;
|
|
|
695
696
|
function normalizeSlash(p) {
|
|
696
697
|
return p.replace(windowsSlashRegex, '/');
|
|
697
698
|
}
|
|
699
|
+
async function isDirectory(filePath) {
|
|
700
|
+
try {
|
|
701
|
+
const stat = await node_fs_promises.stat(filePath);
|
|
702
|
+
return stat.isDirectory();
|
|
703
|
+
} catch {
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
698
707
|
const LATEST_TARGET_VERSIONS = {
|
|
699
708
|
node: [
|
|
700
709
|
'last 1 node versions'
|
|
@@ -1588,6 +1597,23 @@ function composeDecoratorsConfig(compilerOptions, version) {
|
|
|
1588
1597
|
}
|
|
1589
1598
|
};
|
|
1590
1599
|
}
|
|
1600
|
+
function composePrintFileSizeConfig(bundle, target) {
|
|
1601
|
+
if (bundle) return {};
|
|
1602
|
+
return {
|
|
1603
|
+
performance: {
|
|
1604
|
+
printFileSize: {
|
|
1605
|
+
total: ({ environmentName, distPath, assets, totalSize, totalGzipSize })=>{
|
|
1606
|
+
let log = `${picocolors.yellow(assets.length)} files generated in ${picocolors.blue(distPath)} ${picocolors.dim(`(${environmentName})`)}`;
|
|
1607
|
+
log += '\n';
|
|
1608
|
+
log += `${picocolors.magenta('Total size:')} ${(totalSize / 1000).toFixed(1)} kB`;
|
|
1609
|
+
if ('web' === target) log += ` ${picocolors.green(`(${(totalGzipSize / 1000).toFixed(1)} kB gzipped)`)}`;
|
|
1610
|
+
return log;
|
|
1611
|
+
},
|
|
1612
|
+
detail: false
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1591
1617
|
async function createConstantRsbuildConfig() {
|
|
1592
1618
|
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.defineConfig)({
|
|
1593
1619
|
performance: {
|
|
@@ -1757,7 +1783,10 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1757
1783
|
}
|
|
1758
1784
|
},
|
|
1759
1785
|
optimization: {
|
|
1760
|
-
nodeEnv: process.env.NODE_ENV
|
|
1786
|
+
nodeEnv: process.env.NODE_ENV,
|
|
1787
|
+
splitChunks: {
|
|
1788
|
+
chunks: 'async'
|
|
1789
|
+
}
|
|
1761
1790
|
},
|
|
1762
1791
|
plugins
|
|
1763
1792
|
}
|
|
@@ -1840,6 +1869,14 @@ const disableUrlParseRsbuildPlugin = ()=>({
|
|
|
1840
1869
|
});
|
|
1841
1870
|
}
|
|
1842
1871
|
});
|
|
1872
|
+
const fixJsModuleTypePlugin = ()=>({
|
|
1873
|
+
name: 'rsbuild:fix-js-module-type',
|
|
1874
|
+
setup (api) {
|
|
1875
|
+
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
1876
|
+
config.module.rule(CHAIN_ID.RULE.JS).delete('type');
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1843
1880
|
const composeShimsConfig = (format, shims)=>{
|
|
1844
1881
|
const resolvedShims = {
|
|
1845
1882
|
cjs: {
|
|
@@ -1875,7 +1912,8 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1875
1912
|
},
|
|
1876
1913
|
plugins: [
|
|
1877
1914
|
resolvedShims.esm.require && pluginEsmRequireShim(),
|
|
1878
|
-
disableUrlParseRsbuildPlugin()
|
|
1915
|
+
disableUrlParseRsbuildPlugin(),
|
|
1916
|
+
fixJsModuleTypePlugin()
|
|
1879
1917
|
].filter(Boolean)
|
|
1880
1918
|
};
|
|
1881
1919
|
break;
|
|
@@ -1883,13 +1921,19 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1883
1921
|
rsbuildConfig = {
|
|
1884
1922
|
plugins: [
|
|
1885
1923
|
resolvedShims.cjs['import.meta.url'] && pluginCjsImportMetaUrlShim(),
|
|
1886
|
-
disableUrlParseRsbuildPlugin()
|
|
1924
|
+
disableUrlParseRsbuildPlugin(),
|
|
1925
|
+
fixJsModuleTypePlugin()
|
|
1887
1926
|
].filter(Boolean)
|
|
1888
1927
|
};
|
|
1889
1928
|
break;
|
|
1890
1929
|
case 'umd':
|
|
1891
1930
|
case 'iife':
|
|
1892
1931
|
case 'mf':
|
|
1932
|
+
rsbuildConfig = {
|
|
1933
|
+
plugins: [
|
|
1934
|
+
fixJsModuleTypePlugin()
|
|
1935
|
+
]
|
|
1936
|
+
};
|
|
1893
1937
|
break;
|
|
1894
1938
|
default:
|
|
1895
1939
|
throw new Error(`Unsupported format: ${format}`);
|
|
@@ -2057,7 +2101,8 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
2057
2101
|
if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
|
|
2058
2102
|
const globEntryFiles = await glob(entryFiles, {
|
|
2059
2103
|
cwd: root,
|
|
2060
|
-
absolute: true
|
|
2104
|
+
absolute: true,
|
|
2105
|
+
dot: true
|
|
2061
2106
|
});
|
|
2062
2107
|
const resolvedEntryFiles = globEntryFiles.filter((i)=>!DTS_EXTENSIONS_PATTERN.test(i));
|
|
2063
2108
|
if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
|
|
@@ -2134,7 +2179,7 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
2134
2179
|
const isSubpath = normalizeSlash(resolvedRequest).startsWith(`${normalizeSlash(outBase)}/`);
|
|
2135
2180
|
if (isSubpath) {
|
|
2136
2181
|
resolvedRequest = normalizeSlash(node_path.relative(node_path.dirname(issuer), resolvedRequest));
|
|
2137
|
-
if (
|
|
2182
|
+
if (!resolvedRequest.startsWith('./') && !resolvedRequest.startsWith('../')) resolvedRequest = `./${resolvedRequest}`;
|
|
2138
2183
|
return resolvedRequest;
|
|
2139
2184
|
}
|
|
2140
2185
|
return;
|
|
@@ -2158,7 +2203,10 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
2158
2203
|
resolvedRequest = assetRedirectPath ? redirectedPath : request;
|
|
2159
2204
|
if (assetRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
|
|
2160
2205
|
}
|
|
2161
|
-
else if (jsRedirectExtension)
|
|
2206
|
+
else if (jsRedirectExtension) {
|
|
2207
|
+
if (!jsRedirectPath && await isDirectory(join(dirname(issuer), resolvedRequest))) resolvedRequest = `${resolvedRequest.replace(/\/+$/, '')}/index`;
|
|
2208
|
+
resolvedRequest = `${resolvedRequest}${jsExtension}`;
|
|
2209
|
+
}
|
|
2162
2210
|
}
|
|
2163
2211
|
callback(void 0, resolvedRequest);
|
|
2164
2212
|
return;
|
|
@@ -2304,7 +2352,8 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2304
2352
|
const minifyConfig = composeMinifyConfig(config);
|
|
2305
2353
|
const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
|
|
2306
2354
|
const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
|
|
2307
|
-
|
|
2355
|
+
const printFileSizeConfig = composePrintFileSizeConfig(bundle, target);
|
|
2356
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(formatConfig, shimsConfig, syntaxConfig, externalHelpersConfig, autoExtensionConfig, targetConfig, externalsWarnConfig, userExternalsConfig, autoExternalConfig, targetExternalsConfig, bundlelessExternalConfig, entryConfig, cssConfig, assetConfig, entryChunkConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig, printFileSizeConfig);
|
|
2308
2357
|
}
|
|
2309
2358
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
2310
2359
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
@@ -3012,7 +3061,7 @@ const applyCommonOptions = (cli)=>{
|
|
|
3012
3061
|
function runCli() {
|
|
3013
3062
|
const cli = dist('rslib');
|
|
3014
3063
|
cli.help();
|
|
3015
|
-
cli.version("0.12.
|
|
3064
|
+
cli.version("0.12.4");
|
|
3016
3065
|
applyCommonOptions(cli);
|
|
3017
3066
|
const buildCommand = cli.command('build', 'build the library for production');
|
|
3018
3067
|
const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
|
|
@@ -3083,8 +3132,8 @@ function prepareCli() {
|
|
|
3083
3132
|
initNodeEnv();
|
|
3084
3133
|
const { npm_execpath } = process.env;
|
|
3085
3134
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3086
|
-
logger.greet(` Rslib v0.12.
|
|
3135
|
+
logger.greet(` Rslib v0.12.4\n`);
|
|
3087
3136
|
}
|
|
3088
|
-
const src_version = "0.12.
|
|
3137
|
+
const src_version = "0.12.4";
|
|
3089
3138
|
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
3090
3139
|
export { build, defineConfig, inspect, loadConfig, logger, prepareCli, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ as rsbuild, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_version as version, __webpack_exports__rspack as rspack };
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EnvironmentConfig, type RsbuildEntry } from '@rsbuild/core';
|
|
2
|
-
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RequireKey, RsbuildConfigEntry, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
2
|
+
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RequireKey, RsbuildConfigEntry, RsbuildConfigOutputTarget, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* This function helps you to autocomplete configuration types.
|
|
5
5
|
* It accepts a Rslib config object, or a function that returns a config.
|
|
@@ -26,6 +26,7 @@ export declare const composeAutoExternalConfig: (options: {
|
|
|
26
26
|
export declare function composeMinifyConfig(config: LibConfig): EnvironmentConfig;
|
|
27
27
|
export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter): EnvironmentConfig;
|
|
28
28
|
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
|
|
29
|
+
export declare function composePrintFileSizeConfig(bundle: LibConfig['bundle'], target: RsbuildConfigOutputTarget): EnvironmentConfig;
|
|
29
30
|
export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
|
|
30
31
|
export declare const composeModuleImportWarn: (request: string, issuer: string) => string;
|
|
31
32
|
export declare const resolveEntryPath: (entries: RsbuildConfigEntry, root: string) => RsbuildEntry;
|
|
@@ -21,3 +21,4 @@ export declare function debounce<T extends (...args: any[]) => void>(func: T, wa
|
|
|
21
21
|
export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
|
|
22
22
|
export declare const isIntermediateOutputFormat: (format: Format) => boolean;
|
|
23
23
|
export declare function normalizeSlash(p: string): string;
|
|
24
|
+
export declare function isDirectory(filePath: string): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,21 +36,22 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "1.5.
|
|
39
|
+
"@rsbuild/core": "~1.5.1",
|
|
40
40
|
"tinyglobby": "^0.2.14",
|
|
41
|
-
"rsbuild-plugin-dts": "0.12.
|
|
41
|
+
"rsbuild-plugin-dts": "0.12.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.18.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.18.3",
|
|
45
45
|
"@types/fs-extra": "^11.0.4",
|
|
46
46
|
"cac": "^6.7.14",
|
|
47
47
|
"chokidar": "^4.0.3",
|
|
48
48
|
"fs-extra": "^11.3.1",
|
|
49
|
-
"memfs": "^4.
|
|
49
|
+
"memfs": "^4.38.2",
|
|
50
|
+
"path-serializer": "0.5.1",
|
|
50
51
|
"picocolors": "1.1.1",
|
|
51
52
|
"prebundle": "1.4.1",
|
|
52
53
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.12.
|
|
54
|
+
"rslib": "npm:@rslib/core@0.12.3",
|
|
54
55
|
"rslog": "^1.2.11",
|
|
55
56
|
"tsconfck": "3.1.6",
|
|
56
57
|
"typescript": "^5.9.2",
|