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

@std/esm

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@std/esm - npm Package Compare versions

Comparing version 0.19.5 to 0.19.6

2

package.json
{
"name": "@std/esm",
"version": "0.19.5",
"version": "0.19.6",
"description": "Enable ES modules in Node today!",

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

@@ -13,32 +13,35 @@ # @std/esm

1. Run `npm i --save @std/esm` in your app or package directory.
2. Create the ESM loader to import your main ES module:
Run `npm i --save @std/esm` in your app or package directory.
**index.js**
```js
// Provide options as a parameter or options file.
require = require("@std/esm")(module, options)
module.exports = require("./main.mjs").default
```
There are three ways to enable ESM with `@std/esm`.
Enable ESM in the Node CLI with the [`-r` option](https://nodejs.org/api/cli.html#cli_r_require_module):
1. Enable ESM with a CJS bridge:
```shell
node -r @std/esm file.mjs
```
**index.js**
```js
// Provide options as a parameter or options file.
require = require("@std/esm")(module, options)
module.exports = require("./main.mjs").default
```
Enable ESM in the Node REPL:
2. Enable ESM in the Node CLI with the [`-r` option](https://nodejs.org/api/cli.html#cli_r_require_module):
```shell
node -r @std/esm
```
```shell
node -r @std/esm main.mjs
```
Or upon entering:
3. Enable ESM in the Node REPL:
```shell
$ node
> require("@std/esm")
@std/esm enabled
```
```shell
node -r @std/esm
```
or upon entering:
```shell
$ node
> require("@std/esm")
@std/esm enabled
```
*Note: All `"cjs"` options are [unlocked](#unlockables) in the Node REPL.*

@@ -104,5 +107,5 @@

* Use `@std/esm` to load [`jasmine`](https://jasmine.github.io/setup/nodejs.html#a-simple-example-using-the-library)
* Use `"@std/esm":"cjs"` with the `--watch` and `--watch-extensions` options of
* Use `"@std/esm":"cjs"` for the `--watch` and `--watch-extensions` options of
[`mocha`](https://mochajs.org/#-w---watch)
* Use `"@std/esm":"cjs"` with [`webpack`](https://github.com/webpack/webpack)
* Use `"@std/esm":"cjs"` for [`ava`](https://github.com/avajs/ava) and [`webpack`](https://github.com/webpack/webpack)
* When in doubt, use `"@std/esm":"cjs"`

Sorry, the diff of this file is not supported yet

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