Skip to content

Commit f05ed21

Browse files
chore(cdk): Speed up typescript app compile time (#25089)
> REPLACE THIS TEXT BLOCK > > Describe the reason for this change, what the solution is, and any > important design decisions you made. > > Remember to follow the [CONTRIBUTING GUIDE] and [DESIGN GUIDELINES] for any > code you submit. > > [CONTRIBUTING GUIDE]: https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md > [DESIGN GUIDELINES]: https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md Closes #None. The cdk init command can generate a typescript cdk app. The cdk app uses ts-node for things like cdk deploys. As a developer, it seems to take forever for the ts-node to start the cdk deploy process. Adding SWC to the tsconfig file allows ts-node to use a rust-based transpiler when doing a cdk deploy. The SWC speeds up the cdk deploy time by a lot. I have not noticed any type checking issues in vscode nor any transpile issues in deployed lambda functions. Ref: https://typestrong.org/ts-node/docs/swc/ Ref: https://aws.plainenglish.io/speed-up-aws-cdk-deploys-up-to-80-c47afad1c18c ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent c6f9fb6 commit f05ed21

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/aws-cdk/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,25 @@ The following environment variables affect aws-cdk:
811811
The CLI will attempt to detect whether it is being run in CI by looking for the presence of an
812812
environment variable `CI=true`. This can be forced by passing the `--ci` flag. By default the CLI
813813
sends most of its logs to `stderr`, but when `ci=true` it will send the logs to `stdout` instead.
814+
815+
### Changing the default TypeScript transpiler
816+
817+
The ts-node package used to synthesize and deploy CDK apps supports an alternate transpiler that might improve transpile times. The SWC transpiler is written in Rust and has no type checking. The SWC transpiler should be enabled by experienced TypeScript developers.
818+
819+
To enable the SWC transpiler, install the package in the CDK app.
820+
821+
```sh
822+
npm i -D @swc/core @swc/helpers regenerator-runtime
823+
```
824+
825+
And, update the `tsconfig.json` file to add the `ts-node` property.
826+
827+
```json
828+
{
829+
"ts-node": {
830+
"swc": true
831+
}
832+
}
833+
```
834+
835+
The documentation may be found at <https://typestrong.org/ts-node/docs/swc/>

0 commit comments

Comments
 (0)