@rslib/core 0.11.2 → 0.12.0
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 +32 -24
- package/dist/libCssExtractLoader.js +1 -1
- package/dist-types/utils/helper.d.ts +2 -2
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -277,22 +277,23 @@ class LibCssExtractPlugin {
|
|
|
277
277
|
const cssConfig_require = createRequire(import.meta.url);
|
|
278
278
|
const RSLIB_CSS_ENTRY_FLAG = '__rslib_css__';
|
|
279
279
|
async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectedPath, issuer) {
|
|
280
|
-
if (/compiled\/css-loader\//.test(request)) return callback();
|
|
280
|
+
if (/compiled\/css-loader\//.test(request)) return void callback();
|
|
281
281
|
let resolvedRequest = request;
|
|
282
282
|
if (styleRedirectPath) {
|
|
283
283
|
if (void 0 === redirectedPath) return false;
|
|
284
284
|
resolvedRequest = redirectedPath;
|
|
285
285
|
}
|
|
286
286
|
if (!isCssFile(resolvedRequest)) {
|
|
287
|
-
if (isCssFile(issuer)) return callback();
|
|
287
|
+
if (isCssFile(issuer)) return void callback();
|
|
288
288
|
return false;
|
|
289
289
|
}
|
|
290
290
|
if (styleRedirectExtension) {
|
|
291
291
|
const isCssModulesRequest = isCssModulesFile(resolvedRequest, auto);
|
|
292
|
-
if (isCssModulesRequest) return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, jsExtension));
|
|
293
|
-
|
|
292
|
+
if (isCssModulesRequest) return void callback(void 0, resolvedRequest.replace(/\.[^.]+$/, jsExtension));
|
|
293
|
+
callback(void 0, resolvedRequest.replace(/\.[^.]+$/, '.css'));
|
|
294
|
+
return;
|
|
294
295
|
}
|
|
295
|
-
|
|
296
|
+
callback(void 0, resolvedRequest);
|
|
296
297
|
}
|
|
297
298
|
const cssConfig_PLUGIN_NAME = 'rsbuild:lib-css';
|
|
298
299
|
const pluginLibCss = (rootDir, auto, banner, footer)=>({
|
|
@@ -524,7 +525,7 @@ function getTime() {
|
|
|
524
525
|
logger.override({
|
|
525
526
|
debug: (message, ...args)=>{
|
|
526
527
|
if ('verbose' !== logger.level) return;
|
|
527
|
-
const time = picocolors.gray(
|
|
528
|
+
const time = picocolors.gray(getTime());
|
|
528
529
|
console.log(` ${picocolors.green('rslib')} ${time} ${message}`, ...args);
|
|
529
530
|
}
|
|
530
531
|
});
|
|
@@ -1421,13 +1422,14 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1421
1422
|
asyncFlag = false;
|
|
1422
1423
|
return;
|
|
1423
1424
|
}
|
|
1424
|
-
|
|
1425
|
+
next();
|
|
1426
|
+
return;
|
|
1425
1427
|
}
|
|
1426
1428
|
callback(matched, shouldWarn);
|
|
1427
1429
|
};
|
|
1428
1430
|
do {
|
|
1429
1431
|
asyncFlag = true;
|
|
1430
|
-
if (i >= externals.length) return callback(false);
|
|
1432
|
+
if (i >= externals.length) return void callback(false);
|
|
1431
1433
|
matchUserExternals(externals[i++], request, handleExternalsAndCallback);
|
|
1432
1434
|
}while (!asyncFlag);
|
|
1433
1435
|
asyncFlag = false;
|
|
@@ -1464,7 +1466,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1464
1466
|
const getAutoExternalDefaultValue = (format, autoExternal)=>autoExternal ?? isIntermediateOutputFormat(format);
|
|
1465
1467
|
const composeAutoExternalConfig = (options)=>{
|
|
1466
1468
|
const { bundle, format, pkgJson, userExternals } = options;
|
|
1467
|
-
if (
|
|
1469
|
+
if (!bundle) return {};
|
|
1468
1470
|
const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
|
|
1469
1471
|
if (false === autoExternal) return {};
|
|
1470
1472
|
if (!pkgJson) {
|
|
@@ -1597,9 +1599,6 @@ async function createConstantRsbuildConfig() {
|
|
|
1597
1599
|
htmlPlugin: false,
|
|
1598
1600
|
rspack: {
|
|
1599
1601
|
optimization: {
|
|
1600
|
-
splitChunks: {
|
|
1601
|
-
chunks: 'async'
|
|
1602
|
-
},
|
|
1603
1602
|
moduleIds: 'named',
|
|
1604
1603
|
nodeEnv: false
|
|
1605
1604
|
},
|
|
@@ -1683,7 +1682,10 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1683
1682
|
optimization: {
|
|
1684
1683
|
concatenateModules: true,
|
|
1685
1684
|
sideEffects: 'flag',
|
|
1686
|
-
avoidEntryIife: true
|
|
1685
|
+
avoidEntryIife: true,
|
|
1686
|
+
splitChunks: {
|
|
1687
|
+
chunks: 'async'
|
|
1688
|
+
}
|
|
1687
1689
|
},
|
|
1688
1690
|
output: {
|
|
1689
1691
|
module: true,
|
|
@@ -1714,6 +1716,11 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1714
1716
|
}
|
|
1715
1717
|
}
|
|
1716
1718
|
},
|
|
1719
|
+
optimization: {
|
|
1720
|
+
splitChunks: {
|
|
1721
|
+
chunks: 'async'
|
|
1722
|
+
}
|
|
1723
|
+
},
|
|
1717
1724
|
output: {
|
|
1718
1725
|
iife: false,
|
|
1719
1726
|
chunkFormat: 'commonjs',
|
|
@@ -1729,7 +1736,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1729
1736
|
};
|
|
1730
1737
|
case 'umd':
|
|
1731
1738
|
{
|
|
1732
|
-
if (
|
|
1739
|
+
if (!bundle) throw new Error('When using "umd" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.');
|
|
1733
1740
|
const config = {
|
|
1734
1741
|
tools: {
|
|
1735
1742
|
rspack: {
|
|
@@ -1760,7 +1767,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1760
1767
|
}
|
|
1761
1768
|
case 'iife':
|
|
1762
1769
|
{
|
|
1763
|
-
if (
|
|
1770
|
+
if (!bundle) throw new Error('When using "iife" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.');
|
|
1764
1771
|
const config = {
|
|
1765
1772
|
output: {
|
|
1766
1773
|
minify: {
|
|
@@ -1797,7 +1804,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1797
1804
|
return config;
|
|
1798
1805
|
}
|
|
1799
1806
|
case 'mf':
|
|
1800
|
-
if (
|
|
1807
|
+
if (!bundle) throw new Error('When using "mf" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.');
|
|
1801
1808
|
return {
|
|
1802
1809
|
dev: {
|
|
1803
1810
|
writeToDisk: true
|
|
@@ -2022,7 +2029,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
2022
2029
|
const stats = node_fs.statSync(entryAbsPath);
|
|
2023
2030
|
if (!stats.isFile()) entryErrorReasons.push(dirError);
|
|
2024
2031
|
} else if (isDirLike) entryErrorReasons.push(dirError);
|
|
2025
|
-
else entryErrorReasons.push(`Can't resolve the entry ${picocolors.cyan(`"${entry}"`)} at the location ${picocolors.cyan(
|
|
2032
|
+
else entryErrorReasons.push(`Can't resolve the entry ${picocolors.cyan(`"${entry}"`)} at the location ${picocolors.cyan(entryAbsPath)}. Please ensure that the file exists.`);
|
|
2026
2033
|
return entry;
|
|
2027
2034
|
});
|
|
2028
2035
|
if (entryErrorReasons.length) throw new AggregateError(entryErrorReasons.map((reason)=>new Error(reason)));
|
|
@@ -2116,9 +2123,9 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
2116
2123
|
externals: [
|
|
2117
2124
|
async (data, callback)=>{
|
|
2118
2125
|
const { request, getResolve, context, contextInfo } = data;
|
|
2119
|
-
if (!request || !getResolve || !context || !contextInfo) return callback();
|
|
2126
|
+
if (!request || !getResolve || !context || !contextInfo) return void callback();
|
|
2120
2127
|
const { issuer } = contextInfo;
|
|
2121
|
-
if (!resolver) resolver =
|
|
2128
|
+
if (!resolver) resolver = getResolve();
|
|
2122
2129
|
async function redirectPath(request) {
|
|
2123
2130
|
try {
|
|
2124
2131
|
let resolvedRequest = request;
|
|
@@ -2141,7 +2148,7 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
2141
2148
|
const redirectedPath = await redirectPath(resolvedRequest);
|
|
2142
2149
|
const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectedPath, issuer);
|
|
2143
2150
|
if (false !== cssExternal) return cssExternal;
|
|
2144
|
-
if (void 0 === redirectedPath) return callback(void 0, request);
|
|
2151
|
+
if (void 0 === redirectedPath) return void callback(void 0, request);
|
|
2145
2152
|
if (jsRedirectPath) resolvedRequest = redirectedPath;
|
|
2146
2153
|
if (resolvedRequest.startsWith('.')) {
|
|
2147
2154
|
const ext = extname(resolvedRequest);
|
|
@@ -2153,7 +2160,8 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
|
|
|
2153
2160
|
}
|
|
2154
2161
|
else if (jsRedirectExtension) resolvedRequest = `${resolvedRequest}${jsExtension}`;
|
|
2155
2162
|
}
|
|
2156
|
-
|
|
2163
|
+
callback(void 0, resolvedRequest);
|
|
2164
|
+
return;
|
|
2157
2165
|
}
|
|
2158
2166
|
callback();
|
|
2159
2167
|
}
|
|
@@ -3004,7 +3012,7 @@ const applyCommonOptions = (cli)=>{
|
|
|
3004
3012
|
function runCli() {
|
|
3005
3013
|
const cli = dist('rslib');
|
|
3006
3014
|
cli.help();
|
|
3007
|
-
cli.version("0.
|
|
3015
|
+
cli.version("0.12.0");
|
|
3008
3016
|
applyCommonOptions(cli);
|
|
3009
3017
|
const buildCommand = cli.command('build', 'build the library for production');
|
|
3010
3018
|
const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
|
|
@@ -3075,8 +3083,8 @@ function prepareCli() {
|
|
|
3075
3083
|
initNodeEnv();
|
|
3076
3084
|
const { npm_execpath } = process.env;
|
|
3077
3085
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3078
|
-
logger.greet(` Rslib v0.
|
|
3086
|
+
logger.greet(` Rslib v0.12.0\n`);
|
|
3079
3087
|
}
|
|
3080
|
-
const src_version = "0.
|
|
3088
|
+
const src_version = "0.12.0";
|
|
3081
3089
|
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
3082
3090
|
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 };
|
|
@@ -166,7 +166,7 @@ const pitch = function(request, _, _data) {
|
|
|
166
166
|
}
|
|
167
167
|
if (sourceMap) {
|
|
168
168
|
const sourceMapPath = `${distFilepath}.map`;
|
|
169
|
-
m.set(sourceMapPath,
|
|
169
|
+
m.set(sourceMapPath, sourceMap);
|
|
170
170
|
const sourceMappingURL = `/*# sourceMappingURL=${cssFilename}.map */`;
|
|
171
171
|
m.set(distFilepath, `${m.get(distFilepath)}\n${sourceMappingURL}`);
|
|
172
172
|
}
|
|
@@ -4,13 +4,13 @@ import type { Format, LibConfig, PkgJson } from '../types';
|
|
|
4
4
|
* Node.js built-in modules.
|
|
5
5
|
* Copied from https://github.com/webpack/webpack/blob/dd44b206a9c50f4b4cb4d134e1a0bd0387b159a3/lib/node/NodeTargetPlugin.js#L12-L72
|
|
6
6
|
*/
|
|
7
|
-
export declare const nodeBuiltInModules:
|
|
7
|
+
export declare const nodeBuiltInModules: (string | RegExp)[];
|
|
8
8
|
export declare function calcLongestCommonPath(absPaths: string[]): Promise<string | null>;
|
|
9
9
|
export declare function getAbsolutePath(base: string, filepath: string): string;
|
|
10
10
|
export declare const readPackageJson: (rootPath: string) => undefined | PkgJson;
|
|
11
11
|
export declare const isObject: (obj: unknown) => obj is Record<string, any>;
|
|
12
12
|
export declare const isEmptyObject: (obj: object) => boolean;
|
|
13
|
-
export declare function pick<T, U extends keyof T>(obj: T, keys:
|
|
13
|
+
export declare function pick<T, U extends keyof T>(obj: T, keys: readonly U[]): Pick<T, U>;
|
|
14
14
|
export declare function omit<T extends object, U extends keyof T>(obj: T, keysObj: Record<U, boolean>): Omit<T, keyof U>;
|
|
15
15
|
export declare function isPluginIncluded(pluginName: string, plugins?: RsbuildPlugins): boolean;
|
|
16
16
|
export declare function checkMFPlugin(config: LibConfig, sharedPlugins?: RsbuildPlugins): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,21 +36,21 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "
|
|
39
|
+
"@rsbuild/core": "1.5.0-beta.0",
|
|
40
40
|
"tinyglobby": "^0.2.14",
|
|
41
|
-
"rsbuild-plugin-dts": "0.
|
|
41
|
+
"rsbuild-plugin-dts": "0.12.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.18.0",
|
|
45
45
|
"@types/fs-extra": "^11.0.4",
|
|
46
46
|
"cac": "^6.7.14",
|
|
47
47
|
"chokidar": "^4.0.3",
|
|
48
|
-
"fs-extra": "^11.3.
|
|
48
|
+
"fs-extra": "^11.3.1",
|
|
49
49
|
"memfs": "^4.36.0",
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
51
|
"prebundle": "1.4.1",
|
|
52
52
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.11.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.11.2",
|
|
54
54
|
"rslog": "^1.2.11",
|
|
55
55
|
"tsconfck": "3.1.6",
|
|
56
56
|
"typescript": "^5.9.2",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
|
-
"node": ">=
|
|
72
|
+
"node": ">=18.12.0"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public",
|