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: 3.2.44 SFC compile error when use import.meta.url in main.ts #7093
Comments
It seems to be related to #6781 |
The main problem is that the compiler treat main.ts as a SFC but it is not. const baseUrl = import.meta.url
const useImage = (url: string) => {
return new URL(`/src/${url}`, baseUrl).href;
}; this is my current workaround |
I created a second branch with this small diff for reproduction #on branch workaround
git diff main diff --git a/src/main.ts b/src/main.ts
index 79771e5..2b91996 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -6,8 +6,9 @@ import router from './router'
import './assets/main.css'
+const baseUrl = import.meta.url
const useImage = (url: string) => {
- return new URL(`/src/${url}`, import.meta.url).href;
+ return new URL(`/src/${url}`, baseUrl).href;
};
const app = createApp(App) |
It seems to be related to the code here |
Thanks for the detective work! Closing this as it needs to be adressed in the Vite repo, not here. If you haven't already, please open an issue there. |
Vue version
3.2.44
Link to minimal reproduction
https://github.com/eltorio/vue-sfc-bug
Steps to reproduce
clone the repo, install and run it
git clone https://github.com/eltorio/vue-sfc-bug.git cd vue-sfc-bug npm i npm run dev
repository was created with
edit main.ts
edit tsconfig.json
What is expected?
Compile (as it works with 3.2.41)
What is actually happening?
compile error with error
System Info
System: OS: macOS 13.1 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 101.22 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.18.0 - /usr/local/bin/node Yarn: 1.22.18 - /usr/local/bin/yarn npm: 8.19.2 - /usr/local/bin/npm Browsers: Brave Browser: 107.1.45.118 Chrome: 107.0.5304.110 Firefox: 106.0.5 Safari: 16.1 npmPackages: vue: ^3.2.44 => 3.2.44
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: