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

Type imports broken in TypeScript's NodeNext mode (ESM support) #3488

Closed
1 of 2 tasks
nickluger opened this issue Dec 4, 2022 · 11 comments · Fixed by #4001
Closed
1 of 2 tasks

Type imports broken in TypeScript's NodeNext mode (ESM support) #3488

nickluger opened this issue Dec 4, 2022 · 11 comments · Fixed by #4001
Labels
Type: Bug The issue or pullrequest is related to a bug
Milestone

Comments

@nickluger
Copy link

What’s the bug you are facing?

This used to work in beta.199:

import type { JSONContent } from "@tiptap/core";

Now (beta.204) it shows the Module has no exported member error.

This could be due to this TS issue, meaning the index.d.ts exported by tiptap is using expressions like export * from './CommandManager';, while it should be export * from './CommandManager.js';.

I'm using:

  • ESM, i.e. "type": "module" in my package.json.
  • TS version 4.9.3.
  • TS NodeNext mode, as supposed to be used for ESM projects.

Which browser was this experienced in? Are any special extensions installed?

This happens in TS.

How can we reproduce the bug on our side?

  1. Create an ESM TS project with "type": "module" in your package.json and "module": "NodeNext" in your tsconfig.json.
  2. Write import type { JSONContent } from "@tiptap/core";
  3. Run tsc
  4. See the error.

Can you provide a CodeSandbox?

No, that's in TS.

What did you expect to happen?

TS should resolve the type.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@nickluger nickluger added the Type: Bug The issue or pullrequest is related to a bug label Dec 4, 2022
@benasher44
Copy link
Contributor

Any chance that 2023 is the year of nodenext support in tiptap? 🙏

@bdbch bdbch added this to the 2.0.0 Release milestone Feb 24, 2023
@dziraf
Copy link

dziraf commented Mar 3, 2023

Any idea if it is possible to resolve this temporarily without creating patch packages as it seems to be an issue with every subpackage?

@nickluger
Copy link
Author

Any idea if it is possible to resolve this temporarily without creating patch packages as it seems to be an issue with every subpackage?

We just copied the types we needed (for now).... 😅

@bdbch
Copy link
Member

bdbch commented Mar 27, 2023

@nickluger could you create a codesandbox running an example project that highlights the error you're describing?

I tried it for now with an Vite app (since they also run on "type": "module") by default and running tsc inside of it worked fine + typescript also can find the typings while the module is NodeNext.

Would love to get this working soon.

@dziraf
Copy link

dziraf commented Mar 27, 2023

@bdbch I prepared a repository which should allow you to reproduce the problem, I also added some additional info/context to it's README: https://github.com/dziraf/tiptap-types-issue

@bdbch
Copy link
Member

bdbch commented Mar 27, 2023

Thanks @dziraf, I started to work on a fix for this but I'd like to postpone it for the next version since I can't make sure my changes won't break other build processes right now. Need to test it a bit more. But I'll keep it on focus!

@benasher44
Copy link
Contributor

Just saw there's an RC. Any chance this will still make 2.1.0?

@bdbch
Copy link
Member

bdbch commented Apr 19, 2023

Potentially yes. Since this brings a lot of changes on how imports are made I just want to make sure the change to file extensions doesn't break the existing builds. in general if someone wants to pick up this issue to work on it feel free. Right now I'm a bit loaded with other things.

@benasher44
Copy link
Contributor

With a hint, I could take a crack at it. My issue right now is I'm not super familiar with how people are using rollup to do this, and that seems to be the core build tool being used here.

@benasher44
Copy link
Contributor

benasher44 commented Apr 30, 2023

Actually it looks like just adding file endings to the imports fixes it. This should be harmless to add even for CJS users, since omitting them there is mostly stylistic (and maybe as a negative leans on the behavior of the resolver to choose the final path). I'll give that a try.

@benasher44
Copy link
Contributor

I put up a #4001 — went with using eslint to enforce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants