-
Notifications
You must be signed in to change notification settings - Fork 233
Open
Description
Hi, if your library depends on an external package, how can you build for <script type="module">
? Bonus points if you can make it work as CJS, too.
Here's our library
// my-library.js
import fetch from 'isomorphic-unfetch'
export default function (url) {
// do stuff
return fetch(url)
}
Using rollup es
format, can this work?
<script type="module">
import myLibrary from './dist/my-library.es.js'
myLibrary(42)
</script>
Right now you it warns you
Uncaught TypeError: Failed to resolve module specifier "isomorphic-unfetch". Relative references must start with either "/", "./", or "../".`
If you change the library's import to something like ./node_modules/isomorphic-unfetch/es-version.js
it'll work locally but of course break the built version. What to do? What is this rabbit hole?
Any help would be great appreciated! Thank you.
Possibly related
bennypowers, EpicButterz, Grsmto, jgravois, klarkc and 21 more
Metadata
Metadata
Assignees
Labels
No labels