Web JS in sveltekit error
I am trying to get Rive to run in Sveltekit with ts. For some reason, it runs correctly on the first page load, but on reload, an error 500 is thrown.
The specific error is:
```
SyntaxError: [vite] Named export 'Rive' not found. The requested module '@rive-app/canvas' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@rive-app/canvas';
const {Rive} = pkg;
at analyzeImportedModDifference.....
This is seen from this component
<script lang="ts"> import { Rive } from '@rive-app/canvas'; import { onMount } from 'svelte'; let canvasEl: HTMLCanvasElement; onMount(() => { const r = new Rive({ src: '/riv/...', autoplay: true, canvas: canvasEl, onLoad: () => { r.resizeDrawingSurfaceToCanvas(); } }); }); </script> <canvas bind:this={canvasEl} class="max-w-xs md:max-w-md lg:max-w-lg"></canvas>```
And for reference, I am using the npm package installed with
npm i @rive-app/canvas
Any ideas about the error?
Thanks!
hey, I just tried a similar code and it worked well for me, even after a page refresh. Do you have a sample repo I can checkout to test it?
`import * as rive from '@rive-app/canvas';` seems to get it working -- named imports or import rive from both throw the same undefined error. using the CDN and accessing window.rive also works.