1.0.0-rc • Published 5 years ago

babel-preset-browser-esm v1.0.0-rc

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Babel Preset: Browser ESM

Build Status

A Babel 7 compatible preset to fully support loading modules as ESM in the browser natively. This preset will:

  • Automatically inline environment variables
  • Runs dead code elimination
  • Transforms CommonJS to ESM
  • Converts global imports to relative paths using require.resolve
  • Adds missing .js extension

Usage

npm install --save-dev babel-preset-browser-esm

Update your babel configuration, ensure you use babel.config.js over .babelrc to ensure node_modules get properly updated:

module.exports = {
  presets: ['browser-esm']
};

Run server

This module pairs very nicely with bserve to run a static server and automatically transpile the JavaScript files.