Comparing version 0.19.5 to 0.19.6
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63726
110