3.2.25 • Published 4 years ago

esm v3.2.25

Weekly downloads
1,739,254
License
MIT
Repository
github
Last release
4 years ago

esm

The brilliantly simple, babel-less, bundle-less ECMAScript module loader.

esm is the world’s most advanced ECMAScript module loader. This fast, production ready, zero dependency loader is all you need to support ECMAScript modules in Node 6+. See the release post and video for details!

Install

  • New projects

    Run npm init esm or yarn create esm.

    :bulb: Use the -y flag to answer “yes” to all prompts.

  • Existing projects

    Run npm i esm or yarn add esm.

Getting started

There are two ways to enable esm.

  1. Enable esm for packages:

    Use esm to load the main ES module and export it as CommonJS.

    index.js

    // Set options as a parameter, environment variable, or rc file.
    require = require("esm")(module/*, options*/)
    module.exports = require("./main.js")

    main.js

    // ESM syntax is supported.
    export {}

    :bulb: These files are automagically created with npm init esm or yarn create esm.

  2. Enable esm for local runs:

    node -r esm main.js

    :bulb: Omit the filename to enable esm in the REPL.

Features

:clap: By default, :100: percent CJS interoperability is enabled so you can get stuff done. :lock: .mjs files are limited to basic functionality without support for esm options.

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

Options

Specify options with one of the following:

  • "esm" field in package.json
  • CJS/ESM in an .esmrc.js, .esmrc.cjs, or .esmrc.mjs file
  • JSON6 in an .esmrc or .esmrc.json file
  • JSON6 or file path in the ESM_OPTIONS environment variable
  • ESM_DISABLE_CACHE environment variable

DevOpts

Tips

Bundling

  • For bundlers like browserify+esmify, parcel-bundler, and webpack add a "module" field to package.json pointing to the main ES module.

    "main": "index.js",
    "module": "main.js"

    :bulb: This is automagically done with npm init esm or yarn create esm.

Extensions

Loading

  • Load esm before loaders/monitors like @babel/register, newrelic, sqreen, and ts-node.

  • Load esm for jasmine using the "helpers" field in jasmine.json:

    "helpers": [
      "node_modules/esm"
    ]
  • Load esm with “node-args" options of:

    • pm2: --node-args="-r esm"
  • Load esm with “require” options of ava, mocha, nodemon, nyc, qunit, tape, and webpack.

    :bulb: Builtin require cannot sideload .mjs files. However, .js files can be sideloaded or .mjs files may be loaded with dynamic import.

blob@felicienfouillet/dev-toolsx2fafldistinit-log4brainsvue-cli-plugin-vtec-admin@exomath/math-nodesrest-api-appcreate-blitz-projecttest-universepkg-avalon-dev-server@tiagoboeing/styleguide-cli@raisin/mf-generator-clicurlify-api-gatewaymatercolorweb-component-reactflowfinderrestful-directorybiobank-cliplacepass-dibs-cli@corinty/proxmaneo4j-simple-datasvgtojscli@keanucode/initprj@toology/use-event-listenersm-flex-nssm-flex-ns-00@atao60/dummy-cli-starter-kit@omger/create-node-appjs-code-format@yaitmou/create-web-projectemail-worker-corecreate_your_simple_webapp@wearearchangel/create-hcf-frontend@manuelosorio/test@csuriel/js-startewa-ts-cligulp-starter-kit-clizen-project@nodea/universulcreate-qoala-app@nodea/universal@sumcoding/svgtojs@modevel/cli@sazukegu/ufabclikafka-publisher-ss@eam-k/exec-multiple-process@eam-k/run-multi-process@foody-cy/cli@tripheo2410/create-gatsby-appvuepress-theme-dva@lrfmedia/lrfmedia_climuil-2tirain3d@pythonpete32/power-tools@thanoshanmv/create-appcodebase-initddavel-express-sdk@finerweb/refinerboarder-brainzcreate-codebasedelay-watchboard-meetingcyberdrop-dl@oliv76/projects@amrsaber/rand-stringwebresources-toolphabimuil-1truffle-plugin-web3-generator@snuffish/delay-watchfaucet-gorgeon@ssead/serverless-clicloud-directory@node-plex/plex-api-authcloudos-sdk-nodecli-serverlesstwohundred@malopez1578/gamesclichannels_transformercreate-algoorbit-monstrasuhail-first-package@seidya/create-app-builder@pixelfactory/privatebin-cliencryptii-clibst-map-gldeicoform-handlediscordjs-bootstrapidentity-sync-lambdasbc_cli@particle/device-os-testavailability-graphql-api@material-ui-x/grid-data-generatorsoltivo-create-servicecrud-generator-node-graphql-and-rest-api@diva.exchange/signal-server@curefit/genesisagrotis-cli
3.2.25

4 years ago

3.2.24

4 years ago

3.2.23

4 years ago

3.2.22

4 years ago

3.2.21

4 years ago

3.2.20

4 years ago

3.2.19

4 years ago

3.2.18

4 years ago

3.2.17

4 years ago

3.2.16

4 years ago

3.2.15

4 years ago

3.2.14

4 years ago

3.2.13

4 years ago

3.2.12

4 years ago

3.2.11

4 years ago

3.2.10

4 years ago

3.2.9

4 years ago

3.2.8

4 years ago

3.2.7

4 years ago

3.2.6

4 years ago

3.2.5

4 years ago

3.2.4

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.84

4 years ago

3.0.83

4 years ago

3.0.82

4 years ago

3.0.81

4 years ago

3.0.80

4 years ago

3.0.79

4 years ago

3.0.78

4 years ago

3.0.77

4 years ago

3.0.76

4 years ago

3.0.75

4 years ago

3.0.74

4 years ago

3.0.73

4 years ago

3.0.72

4 years ago

3.0.71

4 years ago

3.0.70

4 years ago

3.0.69

4 years ago

3.0.68

4 years ago

3.0.67

4 years ago

3.0.66

4 years ago

3.0.65

4 years ago

3.0.64

4 years ago

3.0.63

4 years ago

3.0.62

4 years ago

3.0.61

4 years ago

3.0.60

4 years ago

3.0.59

4 years ago

3.0.58

4 years ago

3.0.56

4 years ago

3.0.57

4 years ago

3.0.55

4 years ago

3.0.54

4 years ago

3.0.53

4 years ago

3.0.52

4 years ago

3.0.51

4 years ago

3.0.50

4 years ago

3.0.49

4 years ago

3.0.48

4 years ago

3.0.47

4 years ago

3.0.46

4 years ago

3.0.45

4 years ago

3.0.44

4 years ago

3.0.43

5 years ago

3.0.42

5 years ago

3.0.41

5 years ago

3.0.40

5 years ago

3.0.39

5 years ago

3.0.38

5 years ago

3.0.37

5 years ago

3.0.36

5 years ago

3.0.35

5 years ago

3.0.34

5 years ago

3.0.33

5 years ago

3.0.32

5 years ago

3.0.31

5 years ago

3.0.30

5 years ago

3.0.29

5 years ago

3.0.28

5 years ago

3.0.27

5 years ago

3.0.26

5 years ago

3.0.25

5 years ago

3.0.24

5 years ago

3.0.23

5 years ago

3.0.22

5 years ago

3.0.21

5 years ago

3.0.20

5 years ago

3.0.19

5 years ago

3.0.18

5 years ago

3.0.17

5 years ago

3.0.16

5 years ago

3.0.15

5 years ago

3.0.14

5 years ago

3.0.13

5 years ago

3.0.12

5 years ago

3.0.11

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.2.0

5 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago