Open oskarrough opened 6 years ago
Hey 🙂 I'm kinda new to rollup but also ran into this problem. The way I got around it is to use @rollup/plugin-node-resolve
as a plugin when bundling modules for use in the browser, so that dependancies are all bundled up and no resolving is needed client-side. Something like:
// rollup.config.js
{
input: 'src/main.js',
output: {
file: pkg.module,
format: 'esm'
},
plugins: [
resolve(),
]
},
Whereas if I was building out an es module to be used in Webpack / whatever I wouldn't bundle the dependancies and let the build tool handle it.
There might be a better way of handling this so if anyone has a better option give me a shout :)
Cheers!
@oskarrough it's not possible right now to change where the identifier points to. In the future, we could probably use import-maps.
For me, it was a matter of changing: from:
to:
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
Using rollup
es
format, can this work?Right now you it warns you
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