Skip to content
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

Error when trying to resolve augmented modules via --dts-only and --dts-resolve #1239

Open
SplinterStan opened this issue Oct 21, 2024 · 2 comments

Comments

@SplinterStan
Copy link

SplinterStan commented Oct 21, 2024

Problem

  • When trying to generate DTS files for a specific module that depends on another module having it's types declared via module augmentation (declare module ...) results in an error.
  • However, TypeScript compiler is able to resolve augmented modules.

Version info

  • tsup 8.3.0
  • typescript 5.6.3

Repro

  1. Create a new package called tsup-augmented-module via npm init and put inside index.d.ts module augmentation, e.g.:
declare module "tsup-augmented-module" {

    export type SetupOptions = {
        token: string;
        someOtherOption?: number;
    };

}
  1. Specify "types": "index.d.ts" in package.json.
  2. Create another consumer module via npm init and put your augmented module as dependency:
"dependencies": {
  "tsup-augmented-module": "file:../tsup-augmented-module",
}
  1. Now, in your index.ts write:
import { SetupOptions } from 'tsup-augmented-module';

export function test(options: SetupOptions): string {
  return 'test accomplished!';
}
  1. Now, run npx tsup --entry index.ts --dts-only --dts-resolve and see an error like:
RollupError: "SetupOptions" is not exported by 'tsup-augmented-module', imported by "./index.ts".

Expectation

As typescript complier is able to resolve augmented modules, tsup should be able to as well.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@unional
Copy link

unional commented Oct 24, 2024

I'm probably facing the same issue. There is the repro: https://github.com/repobuddy/storybook-image-snapshot

branch: rollup-dts

npm i
npm build
> tsup

CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v8.3.0
CLI Using tsup config: /home/unional/code/repobuddy/sis/tsup.config.ts
CLI Target: chrome100,safari15,firefox91,node18
CLI Cleaning output folder
ESM Build start
Generated an empty chunk: "index".
ESM dist/index.js     68.00 B
ESM dist/index.js.map 69.00 B
ESM ⚡️ Build success in 19ms
DTS Build start
node_modules/rollup/dist/rollup.d.ts (9:0): "Decorator" is not exported by "node_modules/@types/estree/index.d.ts", imported by "node_modules/rollup/dist/rollup.d.ts".
Error: error occured in dts build
    at Worker.<anonymous> (/home/unional/code/repobuddy/sis/node_modules/tsup/dist/index.js:1543:26)
    at Worker.emit (node:events:514:28)
    at MessagePort.<anonymous> (node:internal/worker:263:53)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:814:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
DTS Build error

@unional
Copy link

unional commented Oct 24, 2024

Maybe related to #1231

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

2 participants