0.26.0 • Published 6 years ago

@std/esm v0.26.0

Weekly downloads
7,705
License
MIT
Repository
github
Last release
6 years ago

@std/esm

This fast, small, zero-dependency package is all you need to enable ES modules in Node 6+ today!

See the release post :book: and video :movie_camera: for all the details.

Discontinued

This package has been discontinued in favor of esm.

Getting started

Run npm i --save @std/esm in your app or package directory.

There are three ways to enable ESM with @std/esm.

  1. Enable ESM with a CJS bridge:

    index.js

    // Provide options as a parameter, environment variable, or rc file.
    require = require("@std/esm")(module/*, options*/)
    module.exports = require("./main.mjs").default
  2. Enable ESM in the Node CLI with the -r option:

    node -r @std/esm main.mjs
  3. Enable ESM in the Node REPL:

    node -r @std/esm

    or upon entering:

    $ node
    > require("@std/esm")
    @std/esm enabled

Note: All "cjs" options are unlocked in the Node REPL.

Standard Features

The @std/esm loader is as spec-compliant as possible and follows Node’s ESM rules.

:point_right: This means, by default, ESM requires the use of the .mjs file extension. :unlock: You can unlock ESM with the .js file extension using the "js" ESM mode.

Out of the box @std/esm just works, no configuration necessary, and supports:

Unlockables

Unlock features with options specified as one of the following:

  • The "@std/esm" field in your package.json
  • JSON6 in an .esmrc or .esmrc.json file
  • JSON6 or file path in the ESM_OPTIONS environment variable
  • CJS/ESM in an .esmrc.js or .esmrc.mjs file

Commonly used options may be specified in shorthand form:

  • "@std/esm":"js" is shorthand for "@std/esm":{"mode":"js"}
  • "@std/esm":"cjs" is shorthand for "@std/esm":{"cjs":true,"mode":"js"}

DevOpts

Tips

  • Load @std/esm before @babel/register v7+
  • Load @std/esm with the “require” option of ava, mocha, nyc, and tape
  • Load @std/esm with the --node-arg=-r --node-arg=@std/esm option of node-tap
  • Load @std/esm with the --node-args="-r @std/esm" option of pm2
  • Load @std/esm with wallaby.js
  • Use @std/esm to load jasmine
  • Use "@std/esm":"cjs" for the --watch and --watch-extensions options of mocha
  • Use "@std/esm":"cjs" for ava and webpack
  • When in doubt, use "@std/esm":"cjs"
0.26.0

6 years ago

0.25.5

6 years ago

0.25.4

6 years ago

0.25.3

6 years ago

0.25.2

6 years ago

0.25.1

6 years ago

0.25.0

6 years ago

0.24.0

6 years ago

0.23.4

6 years ago

0.23.3

6 years ago

0.23.2

6 years ago

0.23.1

6 years ago

0.23.0

6 years ago

0.22.0

6 years ago

0.21.7

6 years ago

0.21.6

6 years ago

0.21.5

6 years ago

0.21.4

6 years ago

0.21.3

6 years ago

0.21.2

6 years ago

0.21.1

6 years ago

0.21.0

6 years ago

0.20.0

6 years ago

0.19.7

6 years ago

0.19.6

6 years ago

0.19.5

6 years ago

0.19.4

6 years ago

0.19.3

6 years ago

0.19.2

6 years ago

0.19.1

6 years ago

0.19.0

6 years ago

0.18.0

6 years ago

0.17.3

6 years ago

0.17.2

6 years ago

0.17.1

6 years ago

0.17.0

6 years ago

0.16.0

6 years ago

0.15.0

6 years ago

0.14.0

6 years ago

0.13.0

6 years ago

0.12.5

7 years ago

0.12.4

7 years ago

0.12.3

7 years ago

0.12.2

7 years ago

0.12.1

7 years ago

0.12.0

7 years ago

0.11.3

7 years ago

0.11.2

7 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.2

7 years ago

0.10.1

7 years ago

0.10.0

7 years ago

0.9.2

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago