Skip to content

Commit

Permalink
Improve README (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
sisp authored Mar 4, 2022
1 parent f95b218 commit 4660359
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @swc/jest

[swc][] binding for the jest
[SWC][] binding for Jest.

## Installation

Expand All @@ -23,7 +23,7 @@ module.exports = {
}
```

It will load swc configuration from `.swcrc` in default. You also can custom it:
It will load the SWC configuration from `.swcrc` by default. You also can customize it:

```js
const fs = require('fs')
Expand All @@ -32,18 +32,18 @@ const config = JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, 'utf-8'))

module.exports = {
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, /* custom configuration in jest */ }],
'^.+\\.(t|j)sx?$': ['@swc/jest', { ...config, /* custom configuration in Jest */ }],
},
}
```

## Q & A

### Q: Jest use CommonJS in default. But I want to use ESM.
### Q: Jest uses CommonJS by default. But I want to use ESM.

A: Setup Jest following this [Guide](https://jestjs.io/docs/ecmascript-modules).

For JavaScript, it need to configure `package.json`:
For JavaScript, edit `package.json` as follows:

```json
{
Expand All @@ -52,7 +52,7 @@ A: Setup Jest following this [Guide](https://jestjs.io/docs/ecmascript-modules).
}
```

For TypeScript, it need some configuration in `jest.config.js`:
For TypeScript, edit `jest.config.js` as follows:

```js
module.exports = {
Expand Down Expand Up @@ -83,7 +83,7 @@ A: By default, the version supported by your Node runtime.
| 16 | 'es2021' |
| 17 | 'es2022' |

You can customize this by setting an explicit version in your config:
You can customize this by setting an explicit version in `jest.config.js`:

```js
module.exports = {
Expand All @@ -104,4 +104,4 @@ module.exports = {

MIT

[swc]: https://swc.rs
[SWC]: https://swc.rs

0 comments on commit 4660359

Please sign in to comment.