I’m kinda confused how to properly export my own JS library (for Svelte).
When I import the library on a local project (example local project) then everything works just fine, but when I import it in a online editor like Svelte REPL or CodeSandbox it just won’t work, because the module can’t be found.
The file that exports: https://github.com/DanielSharkov/svelte-router/blob/master/src/index.js
Replication on CodeSandbox: https://codesandbox.io/s/jovial-morning-5o7xr?file=/router.js
To replicate it on Svelte REPL (I can’t safe to share it, because of the error):
<script>
import {SvelteRouter} from '@danielsharkov/svelte-router'
console.log(SvelteRouter)
</script>
For more details of the library you may inspect the repository: https://github.com/DanielSharkov/svelte-router
The files src/router.js
and src/router.mjs
aren’t in the repository, as these are builds of index.ts
.