-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Failed to resolve import @capacitor imports when building for other modes #17681
Comments
Hi, This is expected. You are building all modes with that capacitor import statement. // quasar.config file
boot: [
ctx.mode.capacitor
? 'my-boot-file'
: null // or some non capacitor boot file
] |
@rstoenescu it was working on app-vite v1. Let aside importing things with regular import, even dynamic import with conditionals is not working: if (process.env.MODE === 'capacitor') {
const { Preferences } = await import('@capacitor/preferences');
const { value } = await Preferences.get({ key: 'locale' });
currentLocale = value || currentLocale;
} |
It means it must be a change that was introduced in Vite 3/4/5 or 6. But the solution with the separate boot files will still work. |
Also, alias should use absolute paths, not relative. I think this is the real problem. |
I tried using alias and its works but not for sub-imported packaged. I dont know, its related but in my case (the exact same configurations with this project: eslint config, packages and package versions, prettierrc) my IDE and eslint cant find $t from i18n but it builds without errors. |
So, to be more explicit. Only this is required in quasar.config file. Builds all modes correctly. import { fileURLToPath } from 'node:url'
// ....
build: {
alias: {
'@capacitor/preferences': fileURLToPath(new URL('./src-capacitor/node_modules/@capacitor/preferences', import.meta.url))
}, |
The workaround seems to work. Unfortunately, $t of i18n is supposedly non-existent. I can build it without problems but eslint/vue-tsc give me errors for it. |
@Excel1 please create a separate issue for it with proper information. You have been saying the same things on Discord as well, but unfortunately, it's impossible to help without a reproduction. |
What happened?
ERROR
For my example Repo the same:
What did you expect to happen?
That everything works as usual like if im using ">quasar dev -T mobile"
Reproduction URL
Edit by maintainers: removed as it does not reflecting the actual issue and is confusing
How to reproduce?
(Just clone repo and run quasar dev)
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
SPA Mode
Platforms/Browsers
No response
Quasar info output
Relevant log output
No response
Additional context
If you use capacitor dev for mobile it works as expected.
Workaround is to set an alias in quasar config:
Maybe related to: vitejs/vite#18790 (comment)
Thank you @yusufkandemir for figure it out!
The text was updated successfully, but these errors were encountered: