ionic-team / ionic-team/pwa-elements

Warning when running with Angular + Vite

Open
#129 5 comments 17 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
171
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Running a fresh Angular 17 project, which uses Vite, and latest Capacitor.
Added `pwa-elements` as described in the Capacitor docs https://capacitorjs.com/docs/web/pwa-elements#angular:
`main.ts`:
```ts
import { defineCustomElements } from '@ionic/pwa-elements/loader';
defineCustomElements(window);
```
Running the code (`ng serve`) results in this warning: "The above dynamic import cannot be analyzed by Vite".
![image](https://github.com/ionic-team/pwa-elements/assets/14004275/54942801-83cd-4786-b9e3-55749d22584e)

Notably, everything does still seem to function, but the warning is a nuisance.

Hard to say if the issue is more with the stencil version that builds `pwa-elements` or what.

**Workarounds**
Changing the vite config as described here https://github.com/ionic-team/pwa-elements/issues/109#issuecomment-1405061645 might potentially work, except Angular doesn't currently support configuring vite (https://angular.io/guide/esbuild#:~:text=currently%20cannot%20be%20directly%20configured).

Instead including `pwa-elements` via a cdn script tag in `index.html` does remove the warning, but doesn't work for offline scenarios.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.