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

typescript 5.0 and nodenext module resolutions results in vue files not found #2662

Closed
kalvenschraut opened this issue Apr 21, 2023 · 7 comments

Comments

@kalvenschraut
Copy link
Contributor

kalvenschraut commented Apr 21, 2023

Original discussion about initial support here
I confirmed was still an issue as of vue-tsc 1.4.

Reproduction here

Also wanted to note that this error does not appear in my editor, only when running vue-tsc.

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Apr 27, 2023

I discussed it with vue team members and the conclusion is that you should use "moduleResolution": "bundler". Is there any reason you can't use it?

@kalvenschraut
Copy link
Contributor Author

kalvenschraut commented Apr 27, 2023

Mainly for consistency across my monorepo codebase.

It was working previously and no error appears in my editor. Feel like there is just something missing in vue-tsc that was not ported over from the language-server.

Mainly using nodenext as I was trying to get all my ts code compiled to ESM (have code not using vite atm, primarly API code).

Looks like bundle resolution doesn't enforce extensions to be used everywhere, which I preferred with the nodenext resolution. Guess this probably is a linting rule somewhere if I look for one though.

It appears module resolution bundle was first introduced in 5.0, so did this change, or something related cause the issue?

@kalvenschraut
Copy link
Contributor Author

Tried setting up the eslint rule to cover this case and had mixed results.

Is there a specific reason that Node16/Next can't be supported also?

If it is just a time factor, I can attempt to look into this if there is any specific area you would recommend looking at.

@kalvenschraut
Copy link
Contributor Author

kalvenschraut commented May 9, 2023

I think i more understand the problem now.

Typescript changed to ESM which makes the patching of this not work and is basically dead code unless there is a different way to do the patch.

Talked about in microsoft/TypeScript#52953 a bit

Typescript seems to recommend to do module resolution bundler here, or I just live with .vue.js files.

Actually if #3150 is fixed then this would resolve some of the issues I ran into in my previous comment.

@kalvenschraut
Copy link
Contributor Author

@johnsoncodehk I have a somewhat working version for this I can submit a PR for, but more so wondering if volar wants to take the stance of supporting NodeNext or push everyone to bundler resolution.

Lot of inspiration came from svelte language tools, https://github.com/sveltejs/language-tools/blob/9dd59e03d4e5e0e83b5bbfd2aa8331e6bf5cebaa/packages/typescript-plugin/src/module-loader.ts#L199

@so1ve
Copy link
Member

so1ve commented Sep 18, 2023

@kalvenschraut Can we close this issue? :)

@kalvenschraut
Copy link
Contributor Author

Probably, I personally haven't tested with nodenext since I have since switched to bundler resolution so can't confirm it is working now, but my PR should have addressed this issue.

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

3 participants