You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes slow import of top-level aws-cdk-lib.
At the very end of the build, the compiled `index.js` file is replaced with a version optimized for import performance.
Instead of loading submodules directly at the top level, exports are defined as getter functions.
This way they will only be required when actually imported from `aws-cdk-lib`.
Improves AWS CDK app performance by ~400ms.
Background reading: https://medium.com/trabe/exporting-getters-in-commonjs-modules-dd8f98b7d85e
----
```console
$ hyperfine -i "node -e \"const { App } = require('aws-cdk-lib');\"" "node -e \"const { App } = require('aws-cdk-lib-candidate');\"" --warmup 5
Benchmark 1: node -e "const { App } = require('aws-cdk-lib');"
Time (mean ± σ): 1.227 s ± 0.125 s [User: 1.102 s, System: 0.262 s]
Range (min … max): 1.110 s … 1.508 s 10 runs
Benchmark 2: node -e "const { App } = require('aws-cdk-lib-candidate');"
Time (mean ± σ): 251.9 ms ± 19.7 ms [User: 226.6 ms, System: 51.0 ms]
Range (min … max): 224.6 ms … 278.3 ms 10 runs
Summary
'node -e "const { App } = require('aws-cdk-lib-candidate');"' ran
4.87 ± 0.62 times faster than 'node -e "const { App } = require('aws-cdk-lib');"'
```
----
### All Submissions:
* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)
### Adding new Construct Runtime Dependencies:
* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)
### New Features
* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
0 commit comments