@rslib/core 0.0.14 → 0.0.16
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/bin/rslib.js +13 -1
- package/dist/index.js +20 -9
- package/dist-types/index.d.ts +1 -1
- package/dist-types/types/config/index.d.ts +2 -2
- package/package.json +6 -6
package/bin/rslib.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import nodeModule from 'node:module';
|
|
3
|
+
|
|
4
|
+
// enable on-disk code caching of all modules loaded by Node.js
|
|
5
|
+
// requires Nodejs >= 22.8.0
|
|
6
|
+
const { enableCompileCache } = nodeModule;
|
|
7
|
+
if (enableCompileCache) {
|
|
8
|
+
try {
|
|
9
|
+
enableCompileCache();
|
|
10
|
+
} catch {
|
|
11
|
+
// ignore errors
|
|
12
|
+
}
|
|
13
|
+
}
|
|
3
14
|
|
|
4
15
|
async function main() {
|
|
16
|
+
const { logger, prepareCli, runCli } = await import('../dist/index.js');
|
|
5
17
|
prepareCli();
|
|
6
18
|
|
|
7
19
|
try {
|
package/dist/index.js
CHANGED
|
@@ -150,7 +150,7 @@ function prepareCli() {
|
|
|
150
150
|
// Some package managers automatically output a blank line, some do not.
|
|
151
151
|
const { npm_execpath } = process.env;
|
|
152
152
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
153
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.0.
|
|
153
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.0.16\n`);
|
|
154
154
|
}
|
|
155
155
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
156
156
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -1432,7 +1432,8 @@ function composeMinifyConfig(config) {
|
|
|
1432
1432
|
jsOptions: {
|
|
1433
1433
|
minimizerOptions: {
|
|
1434
1434
|
mangle: false,
|
|
1435
|
-
|
|
1435
|
+
// MF assets are loaded over the network, which means they will not be compressed by the project. Therefore, minifying them is necessary.
|
|
1436
|
+
minify: 'mf' === format,
|
|
1436
1437
|
compress: {
|
|
1437
1438
|
defaults: false,
|
|
1438
1439
|
unused: true,
|
|
@@ -1739,7 +1740,10 @@ const composeExternalsConfig = (format, externals)=>{
|
|
|
1739
1740
|
esm: 'module-import',
|
|
1740
1741
|
cjs: 'commonjs',
|
|
1741
1742
|
umd: 'umd',
|
|
1742
|
-
|
|
1743
|
+
// If use 'var', when projects import an external package like '@pkg', this will cause a syntax error such as 'var pkg = @pkg'.
|
|
1744
|
+
// If use 'umd', the judgement conditions may be affected by other packages that define variables like 'define'.
|
|
1745
|
+
// Therefore, we use 'global' to satisfy both web and node environments.
|
|
1746
|
+
mf: 'global'
|
|
1743
1747
|
};
|
|
1744
1748
|
switch(format){
|
|
1745
1749
|
case 'esm':
|
|
@@ -1905,14 +1909,21 @@ const composeBundleConfig = (jsExtension, redirect, cssModulesAuto, bundle)=>{
|
|
|
1905
1909
|
};
|
|
1906
1910
|
};
|
|
1907
1911
|
const composeDtsConfig = async (libConfig, dtsExtension)=>{
|
|
1908
|
-
const {
|
|
1912
|
+
const { output, autoExternal, banner, footer } = libConfig;
|
|
1913
|
+
let { dts } = libConfig;
|
|
1909
1914
|
if (false === dts || void 0 === dts) return {};
|
|
1915
|
+
// DTS default to bundleless whether js is bundle or not
|
|
1916
|
+
if (true === dts) dts = {
|
|
1917
|
+
bundle: false
|
|
1918
|
+
};
|
|
1910
1919
|
const { pluginDts } = await import("rsbuild-plugin-dts");
|
|
1911
1920
|
return {
|
|
1912
1921
|
plugins: [
|
|
1913
1922
|
pluginDts({
|
|
1914
|
-
|
|
1923
|
+
// Only setting dts.bundle to true will generate the bundled d.ts.
|
|
1924
|
+
bundle: dts?.bundle ?? false,
|
|
1915
1925
|
distPath: dts?.distPath ?? output?.distPath?.root ?? './dist',
|
|
1926
|
+
build: dts?.build ?? false,
|
|
1916
1927
|
abortOnError: dts?.abortOnError ?? true,
|
|
1917
1928
|
dtsExtension: dts?.autoExtension ? dtsExtension : '.d.ts',
|
|
1918
1929
|
autoExternal,
|
|
@@ -2108,7 +2119,7 @@ const applyCommonOptions = (command)=>{
|
|
|
2108
2119
|
command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file');
|
|
2109
2120
|
};
|
|
2110
2121
|
function runCli() {
|
|
2111
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.0.
|
|
2122
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.0.16");
|
|
2112
2123
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('build');
|
|
2113
2124
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('inspect');
|
|
2114
2125
|
[
|
|
@@ -2128,7 +2139,7 @@ function runCli() {
|
|
|
2128
2139
|
process.exit(1);
|
|
2129
2140
|
}
|
|
2130
2141
|
});
|
|
2131
|
-
inspectCommand.description('inspect the
|
|
2142
|
+
inspectCommand.description('inspect the Rsbuild / Rspack configs of Rslib projects').option('--output <output>', 'specify inspect content output path', '.rsbuild').option('--verbose', 'show full function definitions in output').action(async (options)=>{
|
|
2132
2143
|
try {
|
|
2133
2144
|
// TODO: inspect should output Rslib's config
|
|
2134
2145
|
const rslibConfig = await loadConfig({
|
|
@@ -2150,6 +2161,6 @@ function runCli() {
|
|
|
2150
2161
|
});
|
|
2151
2162
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.parse();
|
|
2152
2163
|
}
|
|
2153
|
-
const src_version = "0.0.
|
|
2164
|
+
const src_version = "0.0.16";
|
|
2154
2165
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger;
|
|
2155
|
-
export { build, defineConfig, loadConfig, prepareCli, runCli, src_version as version, __webpack_exports__logger as logger };
|
|
2166
|
+
export { build, defineConfig, loadConfig, prepareCli, runCli, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_version as version, __webpack_exports__logger as logger };
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { prepareCli } from './cli/prepare';
|
|
2
2
|
export { runCli } from './cli/commands';
|
|
3
|
-
export { defineConfig, loadConfig } from './config';
|
|
3
|
+
export { defineConfig, loadConfig, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, } from './config';
|
|
4
4
|
export { build } from './build';
|
|
5
5
|
export { logger } from './utils/logger';
|
|
6
6
|
export type * from './types';
|
|
@@ -6,9 +6,9 @@ export type LatestEcmaVersions = 'es2024' | 'esnext';
|
|
|
6
6
|
export type EcmaScriptVersion = FixedEcmaVersions | LatestEcmaVersions;
|
|
7
7
|
export type RsbuildConfigOutputTarget = NonNullable<RsbuildConfig['output']>['target'];
|
|
8
8
|
export type Syntax = EcmaScriptVersion | string[];
|
|
9
|
-
export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError'> & {
|
|
9
|
+
export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError' | 'build'> & {
|
|
10
10
|
autoExtension?: boolean;
|
|
11
|
-
}) |
|
|
11
|
+
}) | boolean;
|
|
12
12
|
export type AutoExternal = boolean | {
|
|
13
13
|
dependencies?: boolean;
|
|
14
14
|
devDependencies?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "The Rspack-based library build tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.0.
|
|
36
|
-
"tinyglobby": "^0.2.
|
|
37
|
-
"rsbuild-plugin-dts": "0.0.
|
|
35
|
+
"@rsbuild/core": "~1.0.19",
|
|
36
|
+
"tinyglobby": "^0.2.10",
|
|
37
|
+
"rsbuild-plugin-dts": "0.0.16"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@rspack/core": "1.0.8",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"fs-extra": "^11.2.0",
|
|
44
44
|
"memfs": "^4.14.0",
|
|
45
45
|
"picocolors": "1.1.1",
|
|
46
|
-
"prebundle": "1.2.
|
|
47
|
-
"rslib": "npm:@rslib/core@0.0.
|
|
46
|
+
"prebundle": "1.2.5",
|
|
47
|
+
"rslib": "npm:@rslib/core@0.0.15",
|
|
48
48
|
"rslog": "^1.2.3",
|
|
49
49
|
"tsconfck": "3.1.4",
|
|
50
50
|
"typescript": "^5.6.3",
|