Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esm

Package Overview
Dependencies
Maintainers
2
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esm - npm Package Compare versions

Comparing version 3.0.9 to 3.0.10

2

package.json
{
"name": "esm",
"version": "3.0.9",
"version": "3.0.10",
"description": "Tomorrow's ESM today!",

@@ -5,0 +5,0 @@ "keywords": "commonjs, ecmascript, export, import, modules, node, require",

@@ -9,14 +9,19 @@ # esm

Install
---
Run `npx create-esm` or `yarn create esm`.
:bulb: Use the `-y` flag to answer “yes” to all prompts.
Getting started
---
Run `npm i --save esm` in your app or package directory.
There are two ways to enable `esm`.
There are three ways to enable `esm`.
1. Enable `esm` for packages:
1. Enable `esm` with a CJS bridge:
**index.js**
```js
// Provide options as a parameter, environment variable, or rc file.
// Set options as a parameter, environment variable, or rc file.
require = require("esm")(module/*, options*/)

@@ -26,3 +31,3 @@ module.exports = require("./main.js").default

2. Enable `esm` in the Node CLI with the [`-r` option](https://nodejs.org/api/cli.html#cli_r_require_module):
2. Enable `esm` for local runs:

@@ -32,17 +37,4 @@ ```shell

```
:bulb: Omit the filename to enable `esm` in the REPL.
3. Enable `esm` in the Node REPL:
```shell
node -r esm
```
or upon entering:
```shell
$ node
> require("esm")
esm enabled
```
Features

@@ -67,3 +59,2 @@ ---

* Node [`--eval`](https://nodejs.org/api/cli.html#cli_e_eval_script) and [`--print`](https://nodejs.org/api/cli.html#cli_p_print_script) flags
* Node 6+ support

@@ -80,3 +71,3 @@ Options

<table><tr><td colspan=2><code>{</code><tr><td valign=top><code>"mode":</code><td><p>A string mode:<ul><li><code>"auto"</code> detect files with <code>import</code>, <code>import.meta</code>, <code>export</code>, <a href=https://github.com/tc39/proposal-modules-pragma><code>"use module"</code></a>, or <code>.mjs</code> as ESM<li><code>"all"</code> script files are treated as ESM<li><code>"strict"</code> to treat <strong>only</strong> <code>.mjs</code> files as ESM</ul><tr><td valign=top><code>"cjs":</code><td><p>A boolean or object for toggling CJS features in ESM.<details><summary>Features</summary><table><tr><td colspan=2><code>{</code><tr><td valign=top><code>"cache":</code><td><p>A boolean for storing ES modules in <code>require.cache</code>.<tr><td valign=top><code>"extensions":</code><td><p>A boolean for respecting <code>require.extensions</code> in ESM.<tr><td valign=top><code>"interop":</code><td><p>A boolean for <code>__esModule</code> interoperability.<tr><td valign=top><code>"namedExports":</code><td><p>A boolean for <a href=https://ponyfoo.com/articles/es6-modules-in-depth#importing-named-exports>importing named exports</a> of CJS modules.<tr><td valign=top><code>"paths":</code><td><p>A boolean for following CJS <a href=https://github.com/nodejs/node-eps/blob/master/002-es-modules.md#432-removal-of-non-local-dependencies>path rules</a> in ESM.<tr><td valign=top><code>"topLevelReturn":</code><td><p>A boolean for <a href=http://stackoverflow.com/questions/28955047/why-does-a-module-level-return-statement-work-in-node-js/#28955050>top-level <code>return</code></a>.<tr><td valign=top><code>"vars":</code><td><p>A boolean for <code>__dirname</code>, <code>__filename</code>, and <code>require</code> in ESM.<tr><td colspan=2><code>}</code></table></details><tr><td valign=top><code>"await":</code><td><p>A boolean for <a href=https://github.com/MylesBorins/proposal-top-level-await#variant-c-top-level-await-can-only-be-used-in-modules-without-exports>top-level <code>await</code></a> in modules without ESM exports. <i>(requires Node 7.6+)</i><tr><td colspan=2><code>}</code></table>
<table><tr><td colspan=2><code>{</code><tr><td valign=top><code>"mode":</code><td><p>A string mode:<ul><li><code>"auto"</code> detect files with <code>import</code>, <code>import.meta</code>, <code>export</code>,<br><a href=https://github.com/tc39/proposal-modules-pragma><code>"use module"</code></a>, or <code>.mjs</code> as ESM<li><code>"all"</code> script files are treated as ESM<li><code>"strict"</code> to treat <strong>only</strong> <code>.mjs</code> files as ESM</ul><tr><td valign=top><code>"cjs":</code><td><p>A boolean or object for toggling CJS features in ESM.<details><summary>Features</summary><table><tr><td colspan=2><code>{</code><tr><td valign=top><code>"cache":</code><td><p>A boolean for storing ES modules in <code>require.cache</code>.<tr><td valign=top><code>"extensions":</code><td><p>A boolean for respecting <code>require.extensions</code> in ESM.<tr><td valign=top><code>"interop":</code><td><p>A boolean for <code>__esModule</code> interoperability.<tr><td valign=top><code>"namedExports":</code><td><p>A boolean for <a href=https://ponyfoo.com/articles/es6-modules-in-depth#importing-named-exports>importing named exports</a> of CJS modules.<tr><td valign=top><code>"paths":</code><td><p>A boolean for following CJS <a href=https://github.com/nodejs/node-eps/blob/master/002-es-modules.md#432-removal-of-non-local-dependencies>path rules</a> in ESM.<tr><td valign=top><code>"vars":</code><td><p>A boolean for <code>__dirname</code>, <code>__filename</code>, and <code>require</code> in ESM.<tr><td colspan=2><code>}</code></table></details><tr><td valign=top><code>"await":</code><td><p>A boolean for top-level <a href=https://node.green/#ES2017-features-async-functions-await><code>await</code></a> in modules <a href=https://github.com/MylesBorins/proposal-top-level-await#variant-c-top-level-await-can-only-be-used-in-modules-without-exports>without ESM exports</a>.<tr><td colspan=2><code>}</code></table>

@@ -92,3 +83,3 @@ DevOpts

[`@babel/register`](https://github.com/babel/babel/tree/master/packages/babel-register)
* Load `esm` with the *“require”* option of
* Load `esm` with the “require” option of
[`ava`](https://github.com/avajs/ava#options),

@@ -98,3 +89,3 @@ [`mocha`](https://mochajs.org/#-r---require-module-name),

[`tape`](https://github.com/substack/tape#preloading-modules), and
[`webpack`](https://github.com/webpack/webpack-cli/issues/205)
[`webpack`](https://webpack.js.org/api/cli/#config-options)
* Load `esm` with the `--node-arg=-r --node-arg=esm` option of

@@ -101,0 +92,0 @@ [`node-tap`](http://www.node-tap.org/cli/)

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc