这是indexloc提供的服务,不要输入任何密码
Skip to content

7.1: Does not match the legacyOutput mode #938

@RobinTail

Description

@RobinTail

In 7.1, #934 made declaration files for each format.

Here is my tsup.config.ts file:

export default defineConfig({
  entry: ["src/index.ts"],
  format: ["cjs", "esm"],
  legacyOutput: true,
  splitting: false,
  sourcemap: false,
  clean: true,
  dts: true,
  minify: true,
});

I'm using legacyOutput mode, which

Outputs different formats to different folder instead of using different extensions

And here is the list of the files produced:

$ ls dist
esm         index.d.mts index.d.ts  index.js
$ ls dist/esm
index.js

Meaning, that the esm bundle is located in the corresponding folder.
However, its declaration file (index.d.mts) is not.

Moreover, it's impossible to use onSuccess callback for running fs.rename (in order to move index.d.mts into esm folder), since that callback is being fired BEFORE making declarations.

Could you please fix it by placing the declaration files into the same directories where you put the bundles?

Also, in legacy mode, the declaration filename should be .d.ts instead of .d.mts.

CC @andrewbranch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions