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

Conversation

petercoulton
Copy link
Contributor

No description provided.

@@ -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.

@@ -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`
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.

@cspotcode cspotcode merged commit 5503e5d into TypeStrong:docs Oct 17, 2021
@petercoulton petercoulton deleted the patch-1 branch October 19, 2021 08:02
@cspotcode cspotcode modified the milestones: 10.3.0, 10.3.1 Oct 22, 2021
cspotcode added a commit that referenced this pull request Oct 22, 2021
* 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 <cspotcode@gmail.com>

Co-authored-by: Peter Coulton <petercoulton@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants