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

don't work with pnpm and turborepo #269

Closed
yovanoc opened this issue Nov 16, 2023 · 11 comments
Closed

don't work with pnpm and turborepo #269

yovanoc opened this issue Nov 16, 2023 · 11 comments

Comments

@yovanoc
Copy link

yovanoc commented Nov 16, 2023

I don't know if its a bug or if I don't understand something but I can't find a way to make my use case working.
It appears that inside my turborepo monorepo, and using pnpm, dts-bundle-generator can't bring types from other packages.
I got a lot of error TS2304: Cannot find name XXX with XXX being types from other packages. I tried --external-inlines with these packages and changing --disable-symlinks-following but none of these works. What should I try?
thanks

edit: it appears that if I do relative imports like ../../../../../../packages it works with dts-bundle-generator. but can't build my project.

@timocov
Copy link
Owner

timocov commented Nov 17, 2023

Can you share the repro?

@yovanoc
Copy link
Author

yovanoc commented Nov 17, 2023

It's a private startup project so I can't but maybe I can try to make a minimal repro starting from turborepo examples

@timocov
Copy link
Owner

timocov commented Nov 17, 2023

Yes please, it would be helpful. Otherwise it's hard to tell what's exactly wrong.

@yovanoc
Copy link
Author

yovanoc commented Nov 17, 2023

Ok here we go: https://github.com/yovanoc/dts-repro

pnpm generate:api in the main-service app.

the generated api.d.ts don't include StaticType from packages/external-types even if we add --external-inlines @dts-repro/external-types to the command too

@timocov
Copy link
Owner

timocov commented Nov 19, 2023

Hey @yovanoc, thanks for the repro. How does it work for you? I just opened your repro and vscode also highlights the same issue as the tool generates:

image

$ pnpm generate:api

> @dts-repro/main-service@0.0.0 generate:api D:\projects\dts-repro\apps\main-service
> pnpm dlx dts-bundle-generator -o api.d.ts ./src/api.ts

Packages: +18
++++++++++++++++++
Progress: resolved 18, reused 18, downloaded 0, added 18, done
Compiling input files...
src/api.ts(2,33): error TS2307: Cannot find module '@dts-repro/external-types/dist/static-types' or its corresponding type declarations.

Error: Compiled with errors
 ELIFECYCLE  Command failed with exit code 1.

@timocov
Copy link
Owner

timocov commented Nov 19, 2023

It seems that you're using composite projects that aren't supported right now (#93). As a workaround you can create a separate tsconfig for the tool that will include all needed files (basically just don't restrict any folders), something like this:

{
  "compilerOptions": {
    "module": "NodeNext",
    "paths": {
      "@dts-repro/*": ["../../packages/*"]
    },
    "types": ["node"],
    "moduleResolution": "NodeNext"
  },
  "exclude": ["node_modules"]
}

works fine:

$ pnpm generate:api

> @dts-repro/main-service@0.0.0 generate:api D:\projects\dts-repro\apps\main-service
> pnpm dlx dts-bundle-generator -o api.d.ts ./src/api.ts --project tsconfig.dts.json && cat api.d.ts

Packages: +18
++++++++++++++++++
Progress: resolved 18, reused 18, downloaded 0, added 18, done
Compiling input files...
Processing ./src/api.ts
Writing ./src/api.ts -> api.d.ts
Checking generated files...
Done in 3.04s
// Generated by dts-bundle-generator v8.1.2

export type InternalType = {
        someStr: string;
};
export type StaticType = {
        test: number;
};
export type Api = {
        internal: InternalType;
        static: StaticType;
};

export {};

@timocov timocov closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2023
@timocov
Copy link
Owner

timocov commented Nov 19, 2023

Feel free to post any updates if it is not the only issue you're experiencing.

@yovanoc
Copy link
Author

yovanoc commented Nov 20, 2023

oh thanks for the info I think it should be written in the readme.. but when I do that on the real project I get Error: Unknown top-level node kind (with modifiers): SourceFile. If you're seeing this error, please report a bug on https://github.com/timocov/dts-bundle-generator/issues

@timocov
Copy link
Owner

timocov commented Nov 20, 2023

Make sure skibLibCheck is disabled. Can you provide a repro?

@yovanoc
Copy link
Author

yovanoc commented Nov 20, 2023

Can we talk in PM somewhere that I give you access to the repo?
Thanks for your time

@timocov
Copy link
Owner

timocov commented Nov 20, 2023

Sure. Pls email me at timocov@gmail.com

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