capacitor-community / native-audio

MIT License
102 stars 62 forks source link

Error with plugin initialization and import: capacitorExports is not defined #92

Open sethlangel opened 8 months ago

sethlangel commented 8 months ago

Describe the bug A clear and concise description of what the bug is.

Initialization of plugin and importing NativeAudio throws an error

ReferenceError: capacitorExports is not defined

To Reproduce Steps to reproduce the behavior:

  1. Import NativeAudio as described in the docs??

Expected behavior Plugin and methods get imported, methods able to be used to load the audio.

-Web, iOS, and Android

Additional context I removed the NativeAudio.preload code and it still crashed. I removed the import and the error went away. Using NextJS 12.

formicagreen commented 8 months ago

Having the same issue

liho00 commented 6 months ago

same issues with next js build

bennieforss commented 6 months ago

Same issues with next js build

hesslau commented 5 months ago

here as well. any ideas for a workaround?

jormaj commented 2 months ago

In my case this was caused by an issue with the ESM module version. If you explicitly load the commonJS version, it seems to be working fine. You can do this in the following way:

import { NativeAudio } from '@capgo/native-audio/dist/plugin.cjs';

Note that I'm using the Capgo fork, but might work with the capacitor-community version as well

JACKZGGG commented 3 weeks ago

Having the same issue,

jcesarmobile commented 3 weeks ago

can you provide a sample app? I can't reproduce