|
1 долоо хоног өмнө | |
---|---|---|
.. | ||
esm | 1 долоо хоног өмнө | |
LICENSE | 1 долоо хоног өмнө | |
README.md | 1 долоо хоног өмнө | |
esm.js | 1 долоо хоног өмнө | |
index.js | 1 долоо хоног өмнө | |
package.json | 1 долоо хоног өмнө |
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!
Run npm init esm
or yarn create esm
.
:bulb: Use the -y
flag to answer “yes” to all prompts.
Run npm i esm
or yarn add esm
.
There are two ways to enable esm
.
esm
for packages:Use esm
to load the main ES module and export it as CommonJS.
__index.js__
```js
// Set options as a parameter, environment variable, or rc file.
require = require("esm")(module/*, options*/)
module.exports = require("./main.js")
```
__main.js__
```js
// ESM syntax is supported.
export {}
```
:bulb: These files are automagically created with `npm init esm` or `yarn create esm`.
Enable esm
for local runs:
node -r esm main.js
:bulb: Omit the filename to enable esm
in the REPL.
: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:
import
/export
import.meta
import
stdin
, --eval
, --print
flags--check
flag (Node 10+)Specify options with one of the following:
"esm"
field in package.json
.esmrc.js
, .esmrc.cjs
, or .esmrc.mjs
file.esmrc
or .esmrc.json
fileESM_OPTIONS
environment variableESM_DISABLE_CACHE
environment variable{ | |||||||||||||||||||||||||||||||||||||||||||
"cjs":true | A boolean or object for toggling CJS features in ESM. A boolean for storing ES modules in A boolean for A boolean for respecting A boolean for mutable namespace objects. A boolean for importing named exports of CJS modules. A boolean for following CJS path rules in ESM. A boolean for A boolean for requiring ES modules without the dangling A boolean for top-level An array of fields checked when importing a package. A string mode: A boolean for top-level A boolean to apply these options to all module loads. A boolean for WebAssembly module support. (Node 8+) A boolean for toggling cache creation or a cache directory path. A boolean for including inline source maps. For bundlers like :bulb: This is automagically done with Load Load Load Load :bulb: Builtin |