Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: regenerator-runtime dependency for swc (#1508) #1509

Merged
merged 3 commits into from
Oct 17, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions website/docs/transpilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ We have bundled an experimental `swc` integration.
[`swc`](https://swc.rs) is a TypeScript-compatible transpiler implemented in Rust. This makes it an order of magnitude faster
than `transpileModule`.

To use it, first install `@swc/core` or `@swc/wasm`. If using `importHelpers`, also install `@swc/helpers`.
To use it, first install `@swc/core` or `@swc/wasm`, and `regenerator-runtime` which `swc` requires for `async`/`await` support. If using `importHelpers`, also install `@swc/helpers`
Copy link
Collaborator

@cspotcode cspotcode Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @swc/helpers advice should come first since users are more likely to need it than regenerator-runtime.

Does it always require regenerator runtime? Or is it only required when using an older "target" config?

When you don't have a tsconfig, we default to using @tsconfig/node12, @tsconfig/node14, or @tsconfig/node16. Those configs use target: es2019 or higher. Which targets require regenerator-runtime?
https://github.com/tsconfig/bases/blob/main/bases/node12.json

If only certain targets require it, we can amend this guidance to say that you can either a) increase your target or b) add the dependency. Increasing target is probably the better option, but either will work.


```shell
npm i -D @swc/core @swc/helpers
npm i -D @swc/core @swc/helpers regenerator-runtime
```

Then add the following to your `tsconfig.json`.
Expand Down