Skip to content

alyssaq/esm-browser-example

Repository files navigation

esm-browser-example

Run ES modules in the browser with minimal modifications. No concatenation, no minfication.
Uses babel to parse ES6 code and re-writes import/export file statements by appending .js and resolving paths in node_modules.

Building

ESM Libraries:

$ npm install
$ node babelparser.js

It will create a build folder with index.html and ESM files.

Building with react & react-router

Because React's npm module is a 💩and is not ES6-compliant / ESM, use rollup to create a bundle with cjs.

$ npm run rollup

The bundles will be in the build folder with bundle.html

Running

In the build folder, run a simple HTTP server with python:

$ python -m SimpleHTTPServer 2000  # Python 2
$ python3 -m http.server 2000      # Python 3

Open http://localhost:2000 or http://localhost:2000/bundle.html

About

ES modules in the browser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published