rslib: [Bug]: Failed to rename declaration file, rslib only generates one of `d.ts` and `d.mts`.

Version

System:
    OS: macOS 15.3.1
    CPU: (11) arm64 Apple M3 Pro
    Memory: 146.03 MB / 36.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Browsers:
    Chrome: 134.0.6998.89
    Safari: 18.3
  npmPackages:
    @rslib/core: ^0.5.4 => 0.5.4

Details

I try to use rslib in commonjs project

https://github.com/samchon/openapi/pull/160

import { defineConfig } from "@rslib/core";

export default defineConfig({
  source: {
    entry: {
      index: [
        "./src/**",
      ],
    }
  },
  lib: [
    {
      format: "cjs",
      bundle: false,
      dts: true,
      output: {
        filename: {
          js: "[name].js",
        },
        distPath: {
          root: "./lib",
        },
        sourceMap: true,
      },
    },
    {
      format: "esm",
      bundle: false,
      dts: {
        autoExtension: true,
      },
      output: {
        filename: {
          js: "[name].mjs",
        },
        distPath: {
          root: "./lib",
        },
        sourceMap: true,
      },
    },
  ],
});

I’d like to output both d.ts and d.mts but only d.ts are not generated. Why…

Reproduce link

https://github.com/ryoppippi/openapi/tree/feature/build

Reproduce Steps

git clone https://github.com/ryoppippi/openapi
cd openapi
git switch feature/build
pnpm i
pnpm run build
cd lib

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

Thank you so much!!!

Okay, so no way to define script in rslib.config.ts?

eg. https://github.com/web-infra-dev/rslib/blob/2a163501d32b42f22d4d9143dbd5ed13c86c0ab6/packages/core/rslib.config.ts#L7-L26

You can write an Rsbuild plugin and copy files to lib folder.

😄 @ryoppippi A small user survey, what reasons caused you to migrate from rollup to rslib?