egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
8.48k stars 209 forks source link

fix(dts): ensure chunks conform to bundle format #1034

Closed ckohen closed 7 months ago

ckohen commented 7 months ago

For runs with multiple entrypoints, there will sometimes be chunks generated. Currently, the chunks generated always output .d.ts regardless of format, since that is rollup-plugin-dts's default. The prior PR fixed this for the main bundle output, but not these chunks.

In a lot of cases, this would be a non issue. However, in certain cases, a type is determined to be "internal" even though typescript can see through to the expected type. Because this file ends in .ts, it finds the nearest package.json to determine the module type (lets say cjs for this example). If this "internal" type is imported from another package with dual exports (say for something that's a peer dep), and then imported in application code that is another type (esm for this example), the same import is found in the two separate exports of said subpackage and may not be assignable to the same type. This is particularly noticeable with classes that have true private properties,

codesandbox[bot] commented 7 months ago

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tsup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2023 1:29am
ocavue commented 7 months ago

Thanks. Could you add a test case? You can check this one as an example.

github-actions[bot] commented 7 months ago

:tada: This PR is included in version 8.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: