-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
refactor(types): bundle client types #9966
Conversation
9fbfe17
to
2d925f8
Compare
2d925f8
to
b8f6194
Compare
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Amazing work @sapphi-red! I think to play safe it is better to merge this one on the 3.2 beta, and we could delete the facade in v4. |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
import type { | ||
ImportMeta as ViteImportMeta, | ||
ImportMetaEnv as ViteImportMetaEnv | ||
// eslint-disable-next-line node/no-missing-import -- use .js for `moduleResolution: "nodenext"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When vite/client
or vite/import-meta
is used from a file using moduleResolution: "nodenext"
, this import needs to be vite/client/types
or vite/client/types.js
... (vitepress uses moduleResolution: "nodenext"
)
Tried this PR inside Astro to see if it fixed #9827 and everything worked 👍 Nice work! |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
Patch missed by ryu-cho related vitejs/vite#9966
Description
Moved
d.ts
files undertypes
tosrc/dep-types
andsrc/types
and use api-extractor to bundle client types.This solves following issues:
'vite'
and'types/*'
types
directory is not included inexports
field but was included in packagetypes
directory included dep types and it was a bit hard to differentiate types of deps or notvite/types/importMeta
can be imported byvite/import-meta
or importViteImportMeta
type fromvite/client/types
This PR deprecates:
import 'vite/types/*'
import 'vite/client/types'
orimport 'vite'
import { /* import.meta.glob related types */ } from 'vite'
(related: vite config files can't be compiled withoutdom
types #9813)import 'vite/client/types'
I added facade files under
types
directory so there should be backward compatibility.Additional context
https://vitejs.dev/guide/api-plugin.html#typescript-for-custom-events
This example was not working for
server.ws.send('custom:foo', { msg: 'foo' })
. So I updated the docs.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).