-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Glob import does not refresh in SSR - minimatch vs micromatch #5511
Comments
@patak-js I can make a PR to fix this but I'm not sure what's preferable:
|
It is incredible that we have this issue, and I'll add one more to the table. @rollup/pluginutils createFilter is using picomatch... that is very similar to minimatch. In the Rollup docs, it talks about minimatch here, but it is pointing to pluginutils (that uses micromatch). I think they are basically the same though. There is a comparison table here Given that Vite should align itself with the rollup ecosystem, I think we should migrate to use picomatch everywhere, so I vote to implement 2 here. If you send the PR, we can discuss it this Friday with the team. |
We ran into this as well in SvelteKit. Issue about it here: sveltejs/kit#2374. We came up with another solution, which was to use functions rather than globs: sveltejs/kit#2430 |
Thanks for the pointer @benmccann, I like the idea of providing functions as the main way to achieve this. I still think we should align with rollup pluginutils, maybe we could offer both ways. I don't know if we are going to be able to remove support for picomatch/minimatch when the rollup ecosystem (and now the Vite ecosystem) is so used to these patterns. |
@patak-js Oh I see. Looks like
In that case, do you know any good replacement for |
|
@patak-js perhaps I'm misunderstanding something but, in that case, we should not use |
Yes, you are right. Maybe 1, but document that we only support the picomatch subset? |
Describe the bug
The observed bug is that
import.meta.glob('...')
does not detect newly added files under some circumstances.I've only seen this during SSR and using a pattern like
..../*.(js|ts)
. It works when using..../*.[jt]s)
instead.I think the reason is that
import.meta.glob
usesfast-glob
to match files, which internally usesmicromatch
.However, the watcher uses
minimatch
instead to track new files. Apparently, the syntax of those two is different.See this example:
Related issue: #2734
Reproduction
https://stackblitz.com/edit/vitejs-vite-5mh3tc?file=entry-server.js
npm run dev
files
directory. The view won't be refreshed automatically.entry-server.js
.System Info
System: OS: macOS 12.0.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 3.98 GB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.5.0 - /opt/dev/sh/nvm/versions/node/v16.5.0/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 7.19.1 - /opt/dev/sh/nvm/versions/node/v16.5.0/bin/npm Watchman: 2021.10.18.00 - /usr/local/bin/watchman Browsers: Chrome: 95.0.4638.54 Safari: 15.1 npmPackages: vite: ^2.6.0 => 2.6.13
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: