You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[next-ts-plugin] fix: language service crashes / metadata plugin not working (#77213)
### Why?
This PR tackles two issues:
1. The Next.js TS plugin for metadata wasn't working.
2. The language service occasionally crashes in large projects.
#### The Next.js TS plugin for metadata wasn't working
The plugin wasn't working due to the position mismatch of
`optionalReplacementSpan` since VSCode
[v1.86](https://code.visualstudio.com/updates/v1_86) due to the behavior
change of mapping the `replacementSpan` with `optionalReplacementSpan`
if it exists.
x-ref:
https://github.com/microsoft/vscode/pull/200945/files#diff-9027dfcf905374dcada6a75144ed94935254a5a6bf325a20d557201cd7fbe704R766
#### The language service occasionally crashes in large projects
Since we spun up another language service and a custom language service
host for metadata rules, it occasionally crashed on large projects.
### How?
- Synced the `optionalReplacementSpan` to the new position.
- Removed creating another language service and relying on
`@typescript/vfs` for the virtual file system, which is recommended:
"where files on disk aren't the source of truth".
https://github.com/user-attachments/assets/b5b325a4-fd2f-4210-be68-1aa5e40229c2
### Success Criteria
- [x] Does it do completions with `export const metadata = { a }`?
- [x] Does it disable the plugin with `{ enabled: false }` in the
tsconfig.json?
- [x] Does the language service not break when used in large projects?
### Follow Up
This fix is a partial port from the commit
[071d839](071d839)
and will continue to follow up on the refactors from PR #77206,
including a proper test to prevent regression.
---------
Co-authored-by: Zack Tanner <[email protected]>
'Failed to create virtual TypeScript environment. This is a bug in Next.js TypeScript plugin. Please report it by opening an issue at https://github.com/vercel/next.js/issues.'
0 commit comments