@rslib/core 0.16.1 → 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 CHANGED
@@ -1661,7 +1661,7 @@ async function createConstantRsbuildConfig() {
1661
1661
  }
1662
1662
  });
1663
1663
  }
1664
- const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims })=>{
1664
+ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims, advancedEsm })=>{
1665
1665
  const jsParserOptions = {
1666
1666
  cjs: {
1667
1667
  requireResolve: false,
@@ -1679,12 +1679,14 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
1679
1679
  worker: false
1680
1680
  }
1681
1681
  };
1682
+ const experimentalEsmOutput = bundle && 'esm' === format && advancedEsm;
1682
1683
  const plugins = [
1683
1684
  new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.RslibPlugin({
1684
1685
  interceptApiPlugin: true,
1685
1686
  forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename
1686
- })
1687
- ];
1687
+ }),
1688
+ experimentalEsmOutput && new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.EsmLibraryPlugin()
1689
+ ].filter(Boolean);
1688
1690
  switch(format){
1689
1691
  case 'esm':
1690
1692
  return {
@@ -1700,8 +1702,9 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
1700
1702
  }
1701
1703
  },
1702
1704
  optimization: {
1703
- concatenateModules: true,
1704
- sideEffects: 'flag',
1705
+ concatenateModules: !experimentalEsmOutput,
1706
+ sideEffects: experimentalEsmOutput ? true : 'flag',
1707
+ runtimeChunk: experimentalEsmOutput ? 'single' : void 0,
1705
1708
  avoidEntryIife: true,
1706
1709
  splitChunks: {
1707
1710
  chunks: 'async'
@@ -1709,7 +1712,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
1709
1712
  },
1710
1713
  output: {
1711
1714
  module: true,
1712
- chunkFormat: 'module',
1715
+ chunkFormat: experimentalEsmOutput ? false : 'module',
1713
1716
  library: {
1714
1717
  type: 'modern-module'
1715
1718
  },
@@ -2363,7 +2366,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
2363
2366
  const pkgJson = readPackageJson(rootPath);
2364
2367
  const { compilerOptions } = await loadTsconfig(rootPath, config.source?.tsconfigPath);
2365
2368
  const cssModulesAuto = config.output?.cssModules?.auto ?? true;
2366
- 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;
2367
2371
  const { rsbuildConfig: bundleConfig } = composeBundleConfig(bundle);
2368
2372
  const { rsbuildConfig: shimsConfig, enabledShims } = composeShimsConfig(format, shims);
2369
2373
  const formatConfig = composeFormatConfig({
@@ -2371,7 +2375,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
2371
2375
  pkgJson: pkgJson,
2372
2376
  bundle,
2373
2377
  umdName,
2374
- enabledShims
2378
+ enabledShims,
2379
+ advancedEsm: advancedEsm ?? false
2375
2380
  });
2376
2381
  const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
2377
2382
  const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
@@ -2429,7 +2434,8 @@ async function composeCreateRsbuildConfig(rslibConfig) {
2429
2434
  dts: true,
2430
2435
  shims: true,
2431
2436
  umdName: true,
2432
- outBase: true
2437
+ outBase: true,
2438
+ experiments: true
2433
2439
  }))
2434
2440
  };
2435
2441
  if ('string' == typeof libConfig.id) config.id = libConfig.id;
@@ -3198,7 +3204,7 @@ const applyCommonOptions = (cli)=>{
3198
3204
  function runCli() {
3199
3205
  const cli = dist('rslib');
3200
3206
  cli.help();
3201
- cli.version("0.16.1");
3207
+ cli.version("0.17.0");
3202
3208
  applyCommonOptions(cli);
3203
3209
  const buildCommand = cli.command('build', 'build the library for production');
3204
3210
  const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
@@ -3291,8 +3297,8 @@ function prepareCli() {
3291
3297
  setupLogLevel();
3292
3298
  const { npm_execpath } = process.env;
3293
3299
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger.log();
3294
- logger.greet(` Rslib v0.16.1\n`);
3300
+ logger.greet(` Rslib v0.17.0\n`);
3295
3301
  }
3296
- const src_version = "0.16.1";
3302
+ const src_version = "0.17.0";
3297
3303
  var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
3298
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.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,8 +36,8 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "1.6.0-beta.1",
40
- "rsbuild-plugin-dts": "0.16.1"
39
+ "@rsbuild/core": "~1.6.0",
40
+ "rsbuild-plugin-dts": "0.17.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@module-federation/rsbuild-plugin": "^0.21.1",
@@ -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.16.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",