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 1 commit
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
5 changes: 3 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`. If using `importHelpers`, also install `@swc/helpers`, and if using `dynamicImports` also install `regenerator-runtime`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Referring to dynamicImports might confuse users because, when using swc with ts-node, the user never writes dynamicImports anywhere. Is there another way we can phrase this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about this with a link to the typescript release notes for the feature:

if using dynamic imports statements also install regenerator-runtime

Copy link
Collaborator

Choose a reason for hiding this comment

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

Come to think of it, are we sure that dynamic imports are the only thing that use regenerator-runtime? Or is it any usage of async/await in general?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout, you're right, I get the same error with a simple async example. I guess the dynamic import was just the first async usage to fail in my case.


```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 All @@ -38,6 +38,7 @@ Then add the following to your `tsconfig.json`.
```

> `swc` uses `@swc/helpers` instead of `tslib`. If you have enabled `importHelpers`, you must also install `@swc/helpers`.
> If you are using `dynamicImports`, you must install `regenerator-runtime`.

## Writing your own integration

Expand Down