-
-
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
feat!: update to chokidar v4 #18453
feat!: update to chokidar v4 #18453
Conversation
export type { | ||
FSWatcher, | ||
WatchOptions, | ||
AwaitWriteFinishOptions, |
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.
I removed this export because initially it wasn't exported by chokidar
. It feels kinda rare to use this and I don't see it publicly used anywhere on github. So I figured to remove this.
Of course it has to be windows 🥲 I did get that error locally while developing, but the added EDIT: Looks like it's not necessarily windows now. |
I'm able to reproduce locally sometimes by updating the
And after adding some loggings, here's what I got: stdout | playground/hmr/__tests__/hmr.spec.ts > should hmr when file is deleted and restored
edit child
watch change /Users/bjorn/Work/oss/vite/playground-temp/hmr/file-delete-restore/child.js
edit parent
delete child
watch change /Users/bjorn/Work/oss/vite/playground-temp/hmr/file-delete-restore/parent.js
add child
edit parent
watch change /Users/bjorn/Work/oss/vite/playground-temp/hmr/file-delete-restore/parent.js
watch change /Users/bjorn/Work/oss/vite/playground-temp/hmr/file-delete-restore/child.js
From what I can tell, chokidar (or node fs) is collapsing the |
packages/vite/rollup.config.ts
Outdated
// chokidar -> fsevents | ||
'fsevents-handler.js': { | ||
src: `require('fsevents')`, | ||
replacement: `__require('fsevents')`, | ||
}, |
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.
📝 Note to reviewers: chokidar now has ESM files so we don't need to patch require
.
@@ -153,7 +147,6 @@ const moduleRunnerConfig = defineConfig({ | |||
'module-runner': path.resolve(__dirname, 'src/module-runner/index.ts'), | |||
}, | |||
external: [ | |||
'fsevents', |
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.
📝 Note to reviewers: chokidar no longer uses fsevents
(uses fs.watch
for macos as well)
@@ -446,10 +446,7 @@ export async function _createServer( | |||
resolvedOutDirs, | |||
) | |||
const resolvedWatchOptions = resolveChokidarOptions( | |||
{ | |||
disableGlobbing: true, |
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.
This will break these: https://github.com/ElMassimo/vite-plugin-full-reload/blob/00045424209f8f9bef260047da1e9a73afd78f43/src/index.ts#L48, https://github.com/search?q=watch.disableGlobbing+NOT+is%3Afork&type=code
Probably fine but just to point it out.
Co-authored-by: 翠 / green <[email protected]>
Adding a timeout seems to make it more stable, though a bit unfortunate to have it. What's described in #18453 (comment) was causing the issue, and a timeout after the initial delete needs to be long enough for the fs to detect a deletion. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
/ecosystem-ci run |
📝 Ran ecosystem CI on
✅ analogjs, astro, histoire, ladle, laravel, marko, nuxt, previewjs, quasar, qwik, rakkas, storybook, unocss, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-svelte, vite-plugin-vue, vite-setup-catalogue, vitepress, vuepress |
Description
close #18129
NOTE: I started trying to bundle the chokidar types instead of inlining it, but it didn't work out as easily because chokidar's types includes a lot of internal stuff, which causes bundling issues, type compat issues, and large bundle size. At the end it's better to keep inlining it.
Due to explorations above, I've tweaked our code to work a little differently which I'll make comments below explaining
It also looks like we can remove the anymatch types that was used by chokidar before. I'm thinking perhaps that can be a follow-up.