@rslib/core 0.16.0 → 0.17.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 +76 -85
- package/dist-types/types/config.d.ts +14 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -732,94 +732,82 @@ const RSPACK_TARGET_UNLISTED_MODERN_ECMA_VERSIONS = [
|
|
|
732
732
|
];
|
|
733
733
|
const ESX_TO_BROWSERSLIST = {
|
|
734
734
|
es5: {
|
|
735
|
-
chrome: '
|
|
736
|
-
edge: '12
|
|
737
|
-
firefox: '2
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
opera: '10.10.0',
|
|
742
|
-
safari: '3.1.0'
|
|
735
|
+
chrome: '13',
|
|
736
|
+
edge: '12',
|
|
737
|
+
firefox: '2',
|
|
738
|
+
ios: '6',
|
|
739
|
+
node: '0.6',
|
|
740
|
+
safari: '5.1'
|
|
743
741
|
},
|
|
744
|
-
es6
|
|
745
|
-
|
|
746
|
-
edge: '15.0.0',
|
|
747
|
-
firefox: '54.0.0',
|
|
748
|
-
safari: '10.0.0',
|
|
749
|
-
opera: '38.0.0',
|
|
750
|
-
samsung: '5.0.0'
|
|
742
|
+
get es6 () {
|
|
743
|
+
return ESX_TO_BROWSERSLIST.es2015;
|
|
751
744
|
},
|
|
752
745
|
es2015: {
|
|
753
|
-
chrome: '51
|
|
754
|
-
edge: '
|
|
755
|
-
firefox: '
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
746
|
+
chrome: '51',
|
|
747
|
+
edge: '79',
|
|
748
|
+
firefox: '53',
|
|
749
|
+
ios: '16.3',
|
|
750
|
+
node: '6.5',
|
|
751
|
+
safari: '16.3'
|
|
759
752
|
},
|
|
760
753
|
es2016: {
|
|
761
|
-
chrome: '52
|
|
762
|
-
edge: '
|
|
763
|
-
firefox: '
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
754
|
+
chrome: '52',
|
|
755
|
+
edge: '79',
|
|
756
|
+
firefox: '53',
|
|
757
|
+
ios: '16.3',
|
|
758
|
+
node: '7',
|
|
759
|
+
safari: '16.3'
|
|
767
760
|
},
|
|
768
761
|
es2017: {
|
|
769
|
-
chrome: '
|
|
770
|
-
edge: '
|
|
771
|
-
firefox: '
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
762
|
+
chrome: '55',
|
|
763
|
+
edge: '79',
|
|
764
|
+
firefox: '53',
|
|
765
|
+
ios: '16.3',
|
|
766
|
+
node: '7.6',
|
|
767
|
+
safari: '16.3'
|
|
775
768
|
},
|
|
776
769
|
es2018: {
|
|
777
|
-
chrome: '64
|
|
778
|
-
edge: '79
|
|
779
|
-
firefox: '78
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
770
|
+
chrome: '64',
|
|
771
|
+
edge: '79',
|
|
772
|
+
firefox: '78',
|
|
773
|
+
ios: '16.3',
|
|
774
|
+
node: '10',
|
|
775
|
+
safari: '16.3'
|
|
783
776
|
},
|
|
784
777
|
es2019: {
|
|
785
|
-
chrome: '
|
|
786
|
-
edge: '79
|
|
787
|
-
firefox: '78
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
778
|
+
chrome: '66',
|
|
779
|
+
edge: '79',
|
|
780
|
+
firefox: '78',
|
|
781
|
+
ios: '16.3',
|
|
782
|
+
node: '10',
|
|
783
|
+
safari: '16.3'
|
|
791
784
|
},
|
|
792
785
|
es2020: {
|
|
793
|
-
chrome: '
|
|
794
|
-
edge: '
|
|
795
|
-
firefox: '80
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
786
|
+
chrome: '91',
|
|
787
|
+
edge: '91',
|
|
788
|
+
firefox: '80',
|
|
789
|
+
ios: '16.3',
|
|
790
|
+
node: '16.9',
|
|
791
|
+
safari: '16.3'
|
|
799
792
|
},
|
|
800
793
|
es2021: {
|
|
801
|
-
chrome: '
|
|
802
|
-
edge: '
|
|
803
|
-
firefox: '80
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
794
|
+
chrome: '91',
|
|
795
|
+
edge: '91',
|
|
796
|
+
firefox: '80',
|
|
797
|
+
ios: '16.3',
|
|
798
|
+
node: '16.9',
|
|
799
|
+
safari: '16.3'
|
|
807
800
|
},
|
|
808
801
|
es2022: {
|
|
809
|
-
chrome: '94
|
|
810
|
-
edge: '94
|
|
811
|
-
firefox: '93
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
802
|
+
chrome: '94',
|
|
803
|
+
edge: '94',
|
|
804
|
+
firefox: '93',
|
|
805
|
+
ios: '16.4',
|
|
806
|
+
node: '16.11',
|
|
807
|
+
safari: '16.4'
|
|
815
808
|
},
|
|
816
|
-
es2023
|
|
817
|
-
|
|
818
|
-
edge: '110.0.0',
|
|
819
|
-
firefox: '115.0.0',
|
|
820
|
-
safari: '17.0.0',
|
|
821
|
-
opera: '96.0.0',
|
|
822
|
-
samsung: '21.0.0'
|
|
809
|
+
get es2023 () {
|
|
810
|
+
return ESX_TO_BROWSERSLIST.es2022;
|
|
823
811
|
},
|
|
824
812
|
es2024: calcEsnextBrowserslistByTarget,
|
|
825
813
|
esnext: calcEsnextBrowserslistByTarget
|
|
@@ -1673,7 +1661,7 @@ async function createConstantRsbuildConfig() {
|
|
|
1673
1661
|
}
|
|
1674
1662
|
});
|
|
1675
1663
|
}
|
|
1676
|
-
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims })=>{
|
|
1664
|
+
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims, advancedEsm })=>{
|
|
1677
1665
|
const jsParserOptions = {
|
|
1678
1666
|
cjs: {
|
|
1679
1667
|
requireResolve: false,
|
|
@@ -1691,12 +1679,14 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
|
|
|
1691
1679
|
worker: false
|
|
1692
1680
|
}
|
|
1693
1681
|
};
|
|
1682
|
+
const experimentalEsmOutput = bundle && 'esm' === format && advancedEsm;
|
|
1694
1683
|
const plugins = [
|
|
1695
1684
|
new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.RslibPlugin({
|
|
1696
1685
|
interceptApiPlugin: true,
|
|
1697
1686
|
forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename
|
|
1698
|
-
})
|
|
1699
|
-
|
|
1687
|
+
}),
|
|
1688
|
+
experimentalEsmOutput && new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.EsmLibraryPlugin()
|
|
1689
|
+
].filter(Boolean);
|
|
1700
1690
|
switch(format){
|
|
1701
1691
|
case 'esm':
|
|
1702
1692
|
return {
|
|
@@ -1712,8 +1702,9 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
|
|
|
1712
1702
|
}
|
|
1713
1703
|
},
|
|
1714
1704
|
optimization: {
|
|
1715
|
-
concatenateModules:
|
|
1716
|
-
sideEffects: 'flag',
|
|
1705
|
+
concatenateModules: !experimentalEsmOutput,
|
|
1706
|
+
sideEffects: experimentalEsmOutput ? true : 'flag',
|
|
1707
|
+
runtimeChunk: experimentalEsmOutput ? 'single' : void 0,
|
|
1717
1708
|
avoidEntryIife: true,
|
|
1718
1709
|
splitChunks: {
|
|
1719
1710
|
chunks: 'async'
|
|
@@ -1721,7 +1712,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
|
|
|
1721
1712
|
},
|
|
1722
1713
|
output: {
|
|
1723
1714
|
module: true,
|
|
1724
|
-
chunkFormat: 'module',
|
|
1715
|
+
chunkFormat: experimentalEsmOutput ? false : 'module',
|
|
1725
1716
|
library: {
|
|
1726
1717
|
type: 'modern-module'
|
|
1727
1718
|
},
|
|
@@ -2375,7 +2366,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
|
|
|
2375
2366
|
const pkgJson = readPackageJson(rootPath);
|
|
2376
2367
|
const { compilerOptions } = await loadTsconfig(rootPath, config.source?.tsconfigPath);
|
|
2377
2368
|
const cssModulesAuto = config.output?.cssModules?.auto ?? true;
|
|
2378
|
-
const { format = 'esm', shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal, externalHelpers = false, redirect = {}, umdName } = config;
|
|
2369
|
+
const { format = 'esm', shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal, externalHelpers = false, redirect = {}, umdName, experiments } = config;
|
|
2370
|
+
const advancedEsm = experiments?.advancedEsm;
|
|
2379
2371
|
const { rsbuildConfig: bundleConfig } = composeBundleConfig(bundle);
|
|
2380
2372
|
const { rsbuildConfig: shimsConfig, enabledShims } = composeShimsConfig(format, shims);
|
|
2381
2373
|
const formatConfig = composeFormatConfig({
|
|
@@ -2383,7 +2375,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
|
|
|
2383
2375
|
pkgJson: pkgJson,
|
|
2384
2376
|
bundle,
|
|
2385
2377
|
umdName,
|
|
2386
|
-
enabledShims
|
|
2378
|
+
enabledShims,
|
|
2379
|
+
advancedEsm: advancedEsm ?? false
|
|
2387
2380
|
});
|
|
2388
2381
|
const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
|
|
2389
2382
|
const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
@@ -2425,9 +2418,6 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
2425
2418
|
userConfig.source.entry = {};
|
|
2426
2419
|
userConfig.output ??= {};
|
|
2427
2420
|
delete userConfig.output.externals;
|
|
2428
|
-
if (userConfig.output.distPath && 'string' == typeof userConfig.output.distPath) userConfig.output.distPath = {
|
|
2429
|
-
root: userConfig.output.distPath
|
|
2430
|
-
};
|
|
2431
2421
|
const config = {
|
|
2432
2422
|
format: libConfig.format ?? 'esm',
|
|
2433
2423
|
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
@@ -2444,7 +2434,8 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
2444
2434
|
dts: true,
|
|
2445
2435
|
shims: true,
|
|
2446
2436
|
umdName: true,
|
|
2447
|
-
outBase: true
|
|
2437
|
+
outBase: true,
|
|
2438
|
+
experiments: true
|
|
2448
2439
|
}))
|
|
2449
2440
|
};
|
|
2450
2441
|
if ('string' == typeof libConfig.id) config.id = libConfig.id;
|
|
@@ -3213,7 +3204,7 @@ const applyCommonOptions = (cli)=>{
|
|
|
3213
3204
|
function runCli() {
|
|
3214
3205
|
const cli = dist('rslib');
|
|
3215
3206
|
cli.help();
|
|
3216
|
-
cli.version("0.
|
|
3207
|
+
cli.version("0.17.0");
|
|
3217
3208
|
applyCommonOptions(cli);
|
|
3218
3209
|
const buildCommand = cli.command('build', 'build the library for production');
|
|
3219
3210
|
const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
|
|
@@ -3306,8 +3297,8 @@ function prepareCli() {
|
|
|
3306
3297
|
setupLogLevel();
|
|
3307
3298
|
const { npm_execpath } = process.env;
|
|
3308
3299
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger.log();
|
|
3309
|
-
logger.greet(` Rslib v0.
|
|
3300
|
+
logger.greet(` Rslib v0.17.0\n`);
|
|
3310
3301
|
}
|
|
3311
|
-
const src_version = "0.
|
|
3302
|
+
const src_version = "0.17.0";
|
|
3312
3303
|
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
3313
3304
|
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 };
|
|
@@ -193,6 +193,14 @@ export type Redirect = {
|
|
|
193
193
|
/** Controls the redirect of the import paths of output TypeScript declaration files. */
|
|
194
194
|
dts?: DtsRedirect;
|
|
195
195
|
};
|
|
196
|
+
export type LibExperiments = {
|
|
197
|
+
/**
|
|
198
|
+
* Whether to enable Rspack advanced ESM output.
|
|
199
|
+
* @defaultValue `false`
|
|
200
|
+
* @see {@link https://rslib.rs/config/lib/experiments#experimentsadvancedesm}
|
|
201
|
+
*/
|
|
202
|
+
advancedEsm?: boolean;
|
|
203
|
+
};
|
|
196
204
|
export interface LibConfig extends EnvironmentConfig {
|
|
197
205
|
/**
|
|
198
206
|
* The unique identifier of the library.
|
|
@@ -295,6 +303,12 @@ export interface LibConfig extends EnvironmentConfig {
|
|
|
295
303
|
* @inheritdoc
|
|
296
304
|
*/
|
|
297
305
|
output?: RslibOutputConfig;
|
|
306
|
+
/**
|
|
307
|
+
* Options for experimental features.
|
|
308
|
+
* @defaultValue `{}`
|
|
309
|
+
* @see {@link https://rslib.rs/config/lib/experiments}
|
|
310
|
+
*/
|
|
311
|
+
experiments?: LibExperiments;
|
|
298
312
|
}
|
|
299
313
|
export type LibOnlyConfig = Omit<LibConfig, keyof EnvironmentConfig>;
|
|
300
314
|
interface RslibOutputConfig extends OutputConfig {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "1.6.0
|
|
40
|
-
"rsbuild-plugin-dts": "0.
|
|
39
|
+
"@rsbuild/core": "~1.6.0",
|
|
40
|
+
"rsbuild-plugin-dts": "0.17.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@module-federation/rsbuild-plugin": "^0.
|
|
43
|
+
"@module-federation/rsbuild-plugin": "^0.21.1",
|
|
44
44
|
"@types/fs-extra": "^11.0.4",
|
|
45
45
|
"cac": "^6.7.14",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
51
|
"prebundle": "1.4.2",
|
|
52
52
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.16.1",
|
|
54
54
|
"rslog": "^1.3.0",
|
|
55
55
|
"tinyglobby": "0.2.14",
|
|
56
56
|
"tsconfck": "3.1.6",
|