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
When using import.meta.url with URL and an invalid path, the asset-import-meta-url plugin tries to open the file and errors out. This also happens when the line of code is commented out.
//no validation should be done to find out if this is actually a file or not.consturl=newURL('some/non/existant/path.js',import.meta.url)// This also gets transformed and errors even though its commented out// new URL('some/non/existant/path.js', import.meta.url)console.log(url)
vite v2.4.2 building for production...
✓ 0 modules transformed.
[asset-import-meta-url] ENOENT: no such file or directory, open '/Users/smidget/Development/example/bugs/vite-asset-import-meta-url-bug/src/some/non/existant/path.js'
file: /Users/smidget/Development/example/bugs/vite-asset-import-meta-url-bug/src/index.js
error during build:
Error: ENOENT: no such file or directory, open '/Users/smidget/Development/example/bugs/vite-asset-import-meta-url-bug/src/some/non/existant/path.js'
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
I think this issue needs to be re-opened. The pr does not fully addresses the problem.
It shouldn't try to resolve the file on disk at all. There are going to be many times when files don't exist at build time that exist at runtime.
For example, in my electron app I have this code for the main process:
Describe the bug
When using import.meta.url with URL and an invalid path, the asset-import-meta-url plugin tries to open the file and errors out. This also happens when the line of code is commented out.
Reproduction
Clone this then do
yarn & yarn run build
(or npm equiv)https://gitlab.com/brandonryan/example/-/tree/main/bugs/vite-asset-import-meta-url-bug
System Info
System: OS: macOS 11.4 CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz Memory: 65.06 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.4.2 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.18.1 - /usr/local/bin/npm Browsers: Chrome: 91.0.4472.114 Firefox: 89.0.2 Safari: 14.1.1 npmPackages: vite: ^2.4.2 => 2.4.2
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: