From 1a29b41ca87c3463f2859208e3f244e6f9f3db19 Mon Sep 17 00:00:00 2001 From: Ahn Date: Mon, 8 Feb 2021 12:27:20 +0100 Subject: [PATCH] docs(devs-infra): remove ESM docs for 26.5 documentation (#2334) --- website/docs/getting-started/installation.md | 6 +- website/docs/introduction.md | 7 +- .../getting-started/installation.md | 6 +- .../version-26.5/getting-started/options.md | 2 - .../getting-started/options/useESM.md | 35 ---------- .../version-26.5/getting-started/presets.md | 16 ++--- .../version-26.5/guides/esm-support.md | 68 +------------------ .../version-26.5/introduction.md | 7 +- 8 files changed, 28 insertions(+), 119 deletions(-) delete mode 100644 website/versioned_docs/version-26.5/getting-started/options/useESM.md diff --git a/website/docs/getting-started/installation.md b/website/docs/getting-started/installation.md index b69a516310..e67daabb08 100644 --- a/website/docs/getting-started/installation.md +++ b/website/docs/getting-started/installation.md @@ -19,7 +19,11 @@ npm install --save-dev jest typescript ts-jest yarn add --dev jest typescript ts-jest ``` -> Tip: If you get an error with the following `npm` commands such as `npx: command not found`, you can replace `npx XXX` with `node node_modules/.bin/XXX` from the root of your project. +:::tip + +Tip: If you get an error with the following `npm` commands such as `npx: command not found`, you can replace `npx XXX` with `node node_modules/.bin/XXX` from the root of your project. + +::: ### Jest config file diff --git a/website/docs/introduction.md b/website/docs/introduction.md index 71668d636b..a440a9b289 100644 --- a/website/docs/introduction.md +++ b/website/docs/introduction.md @@ -9,5 +9,8 @@ slug: / It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript` **vs** TypeScript (and `ts-jest`)](babel7-or-ts). -| We are not doing semantic versioning and `23.10` is a re-write, run `npm i -D ts-jest@"<23.10.0"` to go back to the previous version | -| ------------------------------------------------------------------------------------------------------------------------------------ | +:::important + +We are not doing semantic versioning and \*\*23.10 is a re-write, run `npm i -D ts-jest@"<23.10.0"` to go back to the previous version + +::: diff --git a/website/versioned_docs/version-26.5/getting-started/installation.md b/website/versioned_docs/version-26.5/getting-started/installation.md index b69a516310..e67daabb08 100644 --- a/website/versioned_docs/version-26.5/getting-started/installation.md +++ b/website/versioned_docs/version-26.5/getting-started/installation.md @@ -19,7 +19,11 @@ npm install --save-dev jest typescript ts-jest yarn add --dev jest typescript ts-jest ``` -> Tip: If you get an error with the following `npm` commands such as `npx: command not found`, you can replace `npx XXX` with `node node_modules/.bin/XXX` from the root of your project. +:::tip + +Tip: If you get an error with the following `npm` commands such as `npx: command not found`, you can replace `npx XXX` with `node node_modules/.bin/XXX` from the root of your project. + +::: ### Jest config file diff --git a/website/versioned_docs/version-26.5/getting-started/options.md b/website/versioned_docs/version-26.5/getting-started/options.md index 20fab404be..25747302ea 100644 --- a/website/versioned_docs/version-26.5/getting-started/options.md +++ b/website/versioned_docs/version-26.5/getting-started/options.md @@ -65,7 +65,6 @@ All options have default values which should fit most of the projects. Click on | [**`diagnostics`**][diagnostics] | [Diagnostics related configuration.][diagnostics] | `boolean`\|`object` | _enabled_ | | [**`babelConfig`**][babelconfig] | [Babel(Jest) related configuration.][babelconfig] | `boolean`\|`string`\|`object` | _disabled_ | | [**`stringifyContentPathRegex`**][stringifycontentpathregex] | [Files which will become modules returning self content.][stringifycontentpathregex] | `string`\|`RegExp` | _disabled_ | -| [**`useESM`**][useesm] | [Enable ESM support][useesm] | `boolean` | _auto_ | [compiler]: options/compiler [tsconfig]: options/tsconfig @@ -75,4 +74,3 @@ All options have default values which should fit most of the projects. Click on [diagnostics]: options/diagnostics [babelconfig]: options/babelConfig [stringifycontentpathregex]: options/stringifyContentPathRegex -[useesm]: options/useESM diff --git a/website/versioned_docs/version-26.5/getting-started/options/useESM.md b/website/versioned_docs/version-26.5/getting-started/options/useESM.md deleted file mode 100644 index 7c0a5eadec..0000000000 --- a/website/versioned_docs/version-26.5/getting-started/options/useESM.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: useESM option ---- - -The `useESM` option allows `ts-jest` to transform codes to ESM syntax **if possible**. - -The default value is **false**, `ts-jest` will transform codes to `CommonJS` syntax. - -### Examples - -```js -// jest.config.js -module.exports = { - // [...] - globals: { - 'ts-jest': { - useESM: true, - }, - }, -} -``` - -```json -// OR package.json -{ - // [...] - "jest": { - "globals": { - "ts-jest": { - "useESM": true - } - } - } -} -``` diff --git a/website/versioned_docs/version-26.5/getting-started/presets.md b/website/versioned_docs/version-26.5/getting-started/presets.md index 4aecc89042..3f79ad4c33 100644 --- a/website/versioned_docs/version-26.5/getting-started/presets.md +++ b/website/versioned_docs/version-26.5/getting-started/presets.md @@ -7,14 +7,11 @@ title: Presets `ts-jest` comes with several presets, covering most of the project's base configuration: -| Preset name | Description | -| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `ts-jest/presets/default`
or `ts-jest` | TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **CommonJS** syntax, leaving JavaScript files (`.js`, `jsx`) as-is. | -| `ts-jest/presets/default-esm`
| TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **ESM** syntax, leaving JavaScript files (`.js`, `jsx`) as-is. | -| `ts-jest/presets/js-with-ts` | TypeScript and JavaScript files (`.ts`, `.tsx`, `.js`, `.jsx`) will be transformed by `ts-jest` to **CommonJS** syntax.
You'll need to set `allowJs` to `true` in your `tsconfig.json` file. | -| `ts-jest/presets/js-with-ts-esm` | TypeScript and JavaScript files (`.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`) will be transformed by `ts-jest` to **ESM** syntax.
You'll need to set `allowJs` to `true` in your `tsconfig.json` file. | -| `ts-jest/presets/js-with-babel` | TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **CommonJS** syntax, and JavaScript files (`.js`, `jsx`) will be transformed by `babel-jest`. | -| `ts-jest/presets/js-with-babel-esm` | TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **ESM** syntax, and JavaScript files (`.js`, `jsx`, `.mjs`) will be transformed by `babel-jest`. | +| Preset name | Description | +| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `ts-jest/presets/default`
or `ts-jest` | TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **CommonJS** syntax, leaving JavaScript files (`.js`, `jsx`) as-is. | +| `ts-jest/presets/js-with-ts` | TypeScript and JavaScript files (`.ts`, `.tsx`, `.js`, `.jsx`) will be transformed by `ts-jest` to **CommonJS** syntax.
You'll need to set `allowJs` to `true` in your `tsconfig.json` file. | +| `ts-jest/presets/js-with-babel` | TypeScript files (`.ts`, `.tsx`) will be transformed by `ts-jest` to **CommonJS** syntax, and JavaScript files (`.js`, `jsx`) will be transformed by `babel-jest`. | ### Basic usage @@ -53,11 +50,8 @@ In this case you'll need to use the JavaScript version of Jest config (comment/u ```js // jest.config.js const { defaults: tsjPreset } = require('ts-jest/presets') -// const { defaultsESM: tsjPreset } = require('ts-jest/presets'); // const { jsWithTs: tsjPreset } = require('ts-jest/presets'); -// const { jsWithTsESM: tsjPreset } = require('ts-jest/presets'); // const { jsWithBabel: tsjPreset } = require('ts-jest/presets'); -// const { jsWithBabelESM: tsjPreset } = require('ts-jest/presets'); module.exports = { // [...] diff --git a/website/versioned_docs/version-26.5/guides/esm-support.md b/website/versioned_docs/version-26.5/guides/esm-support.md index ab0648800c..9adf87a23d 100644 --- a/website/versioned_docs/version-26.5/guides/esm-support.md +++ b/website/versioned_docs/version-26.5/guides/esm-support.md @@ -3,70 +3,8 @@ id: esm-support title: ESM Support --- -To use `ts-jest` with ESM support, you'll first need to check [ESM Jest documentation](https://jestjs.io/docs/en/ecmascript-modules). +:::important -`ts-jest` supports ESM via a config option [useESM](../getting-started/options/useESM) in combination with jest config option [extensionsToTreatAsEsm](https://jestjs.io/docs/en/next/configuration#extensionstotreatasesm-arraystring). +ESM support is only available in **v27** -There are also [3 presets](../getting-started/presets.md) to work with ESM. - -### Examples - -#### Manual configuration - -```js -// jest.config.js -module.exports = { - // [...] - extensionsToTreatAsEsm: ['.ts'], - globals: { - 'ts-jest': { - useESM: true, - }, - }, -} -``` - -```json -// OR package.json -{ - // [...] - "jest": { - "extensionsToTreatAsEsm": [".ts"], - "globals": { - "ts-jest": { - "useESM": true - } - } - } -} -``` - -#### Use ESM presets - -```js -// jest.config.js -module.exports = { - // [...] - preset: 'ts-jest/presets/default-esm', // or other ESM presets - globals: { - 'ts-jest': { - useESM: true, - }, - }, -} -``` - -```json -// OR package.json -{ - // [...] - "jest": { - "preset": "ts-jest/presets/default-esm", // or other ESM presets, - "globals": { - "ts-jest": { - "useESM": true - } - } - } -} -``` +::: diff --git a/website/versioned_docs/version-26.5/introduction.md b/website/versioned_docs/version-26.5/introduction.md index 71668d636b..a7494e3430 100644 --- a/website/versioned_docs/version-26.5/introduction.md +++ b/website/versioned_docs/version-26.5/introduction.md @@ -9,5 +9,8 @@ slug: / It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript` **vs** TypeScript (and `ts-jest`)](babel7-or-ts). -| We are not doing semantic versioning and `23.10` is a re-write, run `npm i -D ts-jest@"<23.10.0"` to go back to the previous version | -| ------------------------------------------------------------------------------------------------------------------------------------ | +:::important + +We are not doing semantic versioning and `23.10` is a re-write, run `npm i -D ts-jest@"<23.10.0"` to go back to the previous version + +:::