-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Regression: Optimized dependencies in 2.6.x cannot access import.meta
#5270
Comments
I posted this on the Vue Land Discord under [#Tools -> Vite] just yesterday. I have a feeling they're related 😅 Discord postI have a small setup() {
const getPath = (name: string) => new URL(name, import.meta.url).href
return {
getPath
}
} I have a
Is there an easy explanation as to why |
I'm also running into this, looks like the regression was introduced in |
This is caused by the esbuild module.exports = defineConfig({
optimizeDeps: {
esbuildOptions: {
target: 'es2020',
},
},
}) Remind you that this will also happen in production mode. You will always have to set esbuild target manually. Which is ridiculous because this usage is right in the official document but not supported by default. I would recommend vite to upgrade its esbuild config. Even esbuild use |
PR #7279 |
Describe the bug
Dependencies optimized by Vite are getting a hardcoded empty object instead of
import.meta
since2.6.0-beta.0
. This means such dependencies cannot accessimport.meta.hot
API or any environment variable likeimport.meta.env.SSR
.This is a workaround implemented in
vite-ssr
. However, I hit a wall when trying to workaroundimport.meta.hot.on(...)
in Vitedge :/Thanks!
Reproduction
https://github.com/frandiox/vite-260-meta-issue
System Info
System: OS: macOS 10.15.7 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 152.89 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.18.0 - /usr/local/bin/node Yarn: 1.22.0 - /usr/local/bin/yarn npm: 6.14.15 - /usr/local/bin/npm Watchman: 2021.09.06.00 - /usr/local/bin/watchman Browsers: Brave Browser: 91.1.25.72 Chrome: 94.0.4606.71 Edge: 94.0.992.47 Firefox: 89.0.2 Safari: 15.0 npmPackages: vite: 2.6.7 => 2.6.7
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: