How to "browserify" a node.js module into a browser importable ES6 module?

Viewed 130

I first thought this would be trivial, but after digging into it, I can't find a way to do this. Is this impossible?

For example, I would like to take any node.js package and compile it like this:

import { method } from "SomeLibrary";
export const api = method

and maybe run webpack or parcel

parcel build index.js

and was hoping it would result in a standalone JavaScript, which I can call from a <script type='module'>, like this:

<script type="module">
import { api } from "SomeModule.min.js";
api()
</script>

But I can't find a way to make this work. Is something like this impossible?

0 Answers
Related