-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Conversation
website/docs/transpilers.md
Outdated
@@ -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`. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
website/docs/transpilers.md
Outdated
@@ -20,7 +20,7 @@ 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`, and if using `dynamicImports` also install `regenerator-runtime`. | |||
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` |
There was a problem hiding this comment.
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.
* Fix inconsistent reference to ts-node in docs * docs: regenerator-runtime dependency for swc (#1508) (#1509) * docs: regenerator-runtime dependency for swc (#1508) * docs(transpilers): update advice for installing regenerator-runtime * Update transpilers.md Co-authored-by: Andrew Bradley <[email protected]> Co-authored-by: Peter Coulton <[email protected]>
No description provided.