-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Cannot find module 'virtual:pwa-info' or its corresponding type declarations #59
Comments
UPDATE If I build and preview it I do see the PWA is correctly made and I see correct logs in the browser too but my VS code is still complaining about not able to find the module. |
Same issue on Webstorm, even after following the Accessing PWA info part. |
Same issue here, I tried everything specified in the docs: added types to |
Also the same errors also pop up in the example project repo |
can you try importing the modules (or use the triple slash reference in the corresponding svelte file script)? // src/app.d.ts
import 'vite-plugin-pwa/info';
import 'vite-plugin-pwa/svelte';
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {}; |
Can you check typescript version? I'm using 5.2.2 EDIT: sorry, you're not using TypeScript |
I am |
the |
I guess SvelteKit should switch to module resolution |
@Naviamold1 can your trying adding a new /// <reference types="vite-plugin-pwa/info" />
/// <reference types="vite-plugin-pwa/svelte" /> or (it seems your are using the virtual for VanillaJS) /// <reference types="vite-plugin-pwa/info" />
/// <reference types="vite-plugin-pwa/vanillajs" /> |
@userquin do you have Aside: I can't test with the example project in this repo because pnpm can't seem to find the package at the root of the monorepo with the workspace protocol |
I'm using {
"name": "sveltekit-latest-example",
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"run-tsc": "svelte-check --help",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
},
"devDependencies": {
"@fontsource/fira-mono": "^4.5.10",
"@neoconfetti/svelte": "^1.0.0",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.20.4",
"@types/cookie": "^0.5.1",
"@vite-pwa/sveltekit": "^0.2.5",
"svelte": "^4.2.0",
"svelte-check": "^3.4.3",
"typescript": "^5.2.2",
"unplugin-icons": "^0.16.6",
"vite": "^4.4.2"
},
"type": "module"
} |
Ahh, works for me if I use npm but not with pnpm, probably because of hoisting or whatever it's called. Also works if I install vite-plugin-pwa directly. Maybe these types could be exposed through a single entrypoint in @vite-pwa/sveltekit? |
huh ye with npm its working but not with pnpm |
ok, to make it working with pnpm, you need to add 2 entries to engine-strict=true
resolution-mode=highest
auto-install-peers=true
shamefully-hoist=true EDIT: |
can you try adding the imports in |
// src/app.d.ts
import 'vite-plugin-pwa/info';
import 'vite-plugin-pwa/vanillajs'; // <== or import 'vite-plugin-pwa/svelte'; if using the virtual module for svelte
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}
export {}; |
YES this worked now all errors are gone. |
You're using the virtual module for VanillaJS and so you can use import { registerSW } from 'virtual:pwa-register';` or import { useRegisterSW } from 'virtual:pwa-register/svelte';` PWA plugin is fw agnostic, the virtual for Svelte is just a wrapper around the VanillaJS one, exposing info with the reactivity from the framework, in Svelte using Writable stores: https://github.com/vite-pwa/vite-plugin-pwa/blob/main/src/client/build/svelte.ts |
I was following the steps from here - https://vite-pwa-org.netlify.app/frameworks/sveltekit.html
I installed the dependency, added the plugin in the
vite.config.js
and when I am adding the webmanifest link or the register SW code, I am seeing the problem that it is complaining about not able to find the modulevirtual:pwa-info
.Based on what I see in the docs, I have tried adding the
types
in my tsconfig. I also tried adding the references in myapp.d.ts
file (as shown in this example - https://github.com/vite-pwa/sveltekit/blob/main/examples/sveltekit-ts/src/app.d.ts#L1 )But neither have worked for me. VS Code still complains that the module is not found and in the run time It does have any
pwaInfo
.My
+layout.svelte
My
vite.config.ts
My
app.d.ts
:Sveltejs/kit version - 1.7.2
vite-wa/sveltekit version - 0.2.5
What am I doing wrong ? Any help will be appreciated. thanks.
The text was updated successfully, but these errors were encountered: