8000 Incorrect default export in generated `.cjs` file when using `treeshake: true` · Issue #1319 · egoist/tsup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Incorrect default export in generated .cjs file when using treeshake: true #1319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AlexShukel opened this issue Mar 14, 2025 · 0 comments

Comments

@AlexShukel
Copy link
AlexShukel commented Mar 14, 2025

Problem

When using treeshake: true option, the invalid default export is generated in .cjs files, probably because of rollup usage. When building with rollup's treeshake - @arethetypeswrong/cli gives the following error (see https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md for error explanation):

Image

However, if we set treeshake: false in tsup.config.ts and rebuild, the error is gone:

Image

To reproduce

  1. git clone https://github.com/AlexShukel/tsup-cts-default-export
  2. pnpm i
  3. pnpm build
  4. pnpm lint

The final distributable directory is dist, so we copy package.json there in pnpm build command. Then, with pnpm lint we call attw to check the package inside dist directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0