How to update js build process to fix "SyntaxError: Cannot use import statement outside a module"

27 views Asked by At

I am having an easily reproducible error with the npm library @capacitor-community/apple-sign-in.

You can reproduce by running:

npm create svelte@latest my-app
cd my-app
npm install
npm i @capacitor-community/apple-sign-in

Then add usage of @capacitor-community/apple-sign-in such as in src/routes/Header.svelte.

Then, npm run build will reproduce the failure.

The error is SyntaxError: Cannot use import statement outside a module.

This can also be reproduced by cloning my demo repo and npm run build.

The plugin seems to not have this issue with create-react-app apps, so it seems to be an issue with how the build is happening for default svelte apps.

I am guessing this can be fixed using babel, esbuild, or vite features, so I am reaching out to stack overflow hoping to find a workaround.

I've also created this GitHub issue: https://github.com/capacitor-community/apple-sign-in/issues/108

0

There are 0 answers