Skip to content

Commit

Permalink
docs(devs-infra): remove ESM docs for 26.5 documentation (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Feb 8, 2021
1 parent 3d3e0b4 commit 1a29b41
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 119 deletions.
6 changes: 5 additions & 1 deletion website/docs/getting-started/installation.md
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions website/docs/introduction.md
Expand Up @@ -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

:::
Expand Up @@ -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

Expand Down
Expand Up @@ -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
Expand All @@ -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

This file was deleted.

16 changes: 5 additions & 11 deletions website/versioned_docs/version-26.5/getting-started/presets.md
Expand Up @@ -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`<br/>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`<br/> | 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.<br/>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.<br/>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`<br/>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.<br/>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

Expand Down Expand Up @@ -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 = {
// [...]
Expand Down
68 changes: 3 additions & 65 deletions website/versioned_docs/version-26.5/guides/esm-support.md
Expand Up @@ -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
}
}
}
}
```
:::
7 changes: 5 additions & 2 deletions website/versioned_docs/version-26.5/introduction.md
Expand Up @@ -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

:::

0 comments on commit 1a29b41

Please sign in to comment.