From 987e415da862b8e4bff9419de3a3df56c391753b Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Fri, 31 Dec 2021 10:57:58 +0100 Subject: [PATCH] [docs] Document how to execute `node` using `--experimental-vm-modules` using Yarn PnP (#12194) --- docs/ECMAScriptModules.md | 7 ++++++- website/versioned_docs/version-25.x/ECMAScriptModules.md | 7 ++++++- website/versioned_docs/version-26.x/ECMAScriptModules.md | 7 ++++++- website/versioned_docs/version-27.0/ECMAScriptModules.md | 7 ++++++- website/versioned_docs/version-27.1/ECMAScriptModules.md | 7 ++++++- website/versioned_docs/version-27.2/ECMAScriptModules.md | 7 ++++++- website/versioned_docs/version-27.4/ECMAScriptModules.md | 7 ++++++- 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/docs/ECMAScriptModules.md b/docs/ECMAScriptModules.md index 64a1e003b502..b4ad17d411b4 100644 --- a/docs/ECMAScriptModules.md +++ b/docs/ECMAScriptModules.md @@ -12,7 +12,12 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. + + On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. + + If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp). + 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `.mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details. 1. If you want to treat other file extensions (such as `.jsx` or `.ts`) as ESM, please use the [`extensionsToTreatAsEsm` option](Configuration.md#extensionstotreatasesm-arraystring). diff --git a/website/versioned_docs/version-25.x/ECMAScriptModules.md b/website/versioned_docs/version-25.x/ECMAScriptModules.md index b874feb43f9e..7c01cb606358 100644 --- a/website/versioned_docs/version-25.x/ECMAScriptModules.md +++ b/website/versioned_docs/version-25.x/ECMAScriptModules.md @@ -12,7 +12,12 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. + + On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. + + If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp). + 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details ## Differences between ESM and CommonJS diff --git a/website/versioned_docs/version-26.x/ECMAScriptModules.md b/website/versioned_docs/version-26.x/ECMAScriptModules.md index b874feb43f9e..7c01cb606358 100644 --- a/website/versioned_docs/version-26.x/ECMAScriptModules.md +++ b/website/versioned_docs/version-26.x/ECMAScriptModules.md @@ -12,7 +12,12 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. + + On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. + + If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp). + 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details ## Differences between ESM and CommonJS diff --git a/website/versioned_docs/version-27.0/ECMAScriptModules.md b/website/versioned_docs/version-27.0/ECMAScriptModules.md index 42b5f1641e0d..a2f513282a09 100644 --- a/website/versioned_docs/version-27.0/ECMAScriptModules.md +++ b/website/versioned_docs/version-27.0/ECMAScriptModules.md @@ -12,7 +12,12 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. + + On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. + + If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp). + 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details. 1. If you want to treat other file extensions (such as `.jsx` or `.ts`) as ESM, please use the [`extensionsToTreatAsEsm` option](Configuration.md#extensionstotreatasesm-arraystring). diff --git a/website/versioned_docs/version-27.1/ECMAScriptModules.md b/website/versioned_docs/version-27.1/ECMAScriptModules.md index 64a1e003b502..b4ad17d411b4 100644 --- a/website/versioned_docs/version-27.1/ECMAScriptModules.md +++ b/website/versioned_docs/version-27.1/ECMAScriptModules.md @@ -12,7 +12,12 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. + + On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. + + If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp). + 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `.mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details. 1. If you want to treat other file extensions (such as `.jsx` or `.ts`) as ESM, please use the [`extensionsToTreatAsEsm` option](Configuration.md#extensionstotreatasesm-arraystring). diff --git a/website/versioned_docs/version-27.2/ECMAScriptModules.md b/website/versioned_docs/version-27.2/ECMAScriptModules.md index 64a1e003b502..b4ad17d411b4 100644 --- a/website/versioned_docs/version-27.2/ECMAScriptModules.md +++ b/website/versioned_docs/version-27.2/ECMAScriptModules.md @@ -12,7 +12,12 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. + + On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. + + If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp). + 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `.mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details. 1. If you want to treat other file extensions (such as `.jsx` or `.ts`) as ESM, please use the [`extensionsToTreatAsEsm` option](Configuration.md#extensionstotreatasesm-arraystring). diff --git a/website/versioned_docs/version-27.4/ECMAScriptModules.md b/website/versioned_docs/version-27.4/ECMAScriptModules.md index 64a1e003b502..b4ad17d411b4 100644 --- a/website/versioned_docs/version-27.4/ECMAScriptModules.md +++ b/website/versioned_docs/version-27.4/ECMAScriptModules.md @@ -12,7 +12,12 @@ Jest ships with _experimental_ support for ECMAScript Modules (ESM). With the warnings out of the way, this is how you activate ESM support in your tests. 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). -1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/jest/bin/jest.js` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc.. + + On Windows, you can use [`cross-env`](https://github.com/kentcdodds/cross-env) to be able to set environment variables. + + If you use Yarn, you can use `yarn node --experimental-vm-modules $(yarn bin jest)`. This command will also work if you use [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp). + 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `.mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details. 1. If you want to treat other file extensions (such as `.jsx` or `.ts`) as ESM, please use the [`extensionsToTreatAsEsm` option](Configuration.md#extensionstotreatasesm-arraystring).