Skip to content

Commit

Permalink
feat(aws-cdk-lib): reduce JavaScript load time, second attempt (#27362)
Browse files Browse the repository at this point in the history
This is a re-roll of #27217 which had to be reverted (first attempt to fix forward in #27314, then reverted in #27353).

The issue with the previous change were:

- The mutation was accidentally switched off at the last second.
- It did not work for ESM modules, because the code were were generating was not recognized as a CommonJS export by `cjs-module-lexer`.

We now generate code that passes the `cjs-module-lexer`, and have tests in place to prove it.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Oct 3, 2023
1 parent 75da672 commit f2905c5
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ integTest('Test importing CDK from ESM', withTemporaryDirectory(withPackages(asy

// Rewrite some files
await fs.writeFile(path.join(context.integTestDir, 'new-entrypoint.mjs'), `
// Test two styles of imports
import { Stack, aws_sns as sns, aws_sns_subscriptions as subs, aws_sqs as sqs } from 'aws-cdk-lib';
// Test multiple styles of imports
import { Stack, aws_sns as sns } from 'aws-cdk-lib';
import { SqsSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import * as cdk from 'aws-cdk-lib';
class TestjsStack extends Stack {
Expand All @@ -39,7 +41,7 @@ class TestjsStack extends Stack {
const topic = new sns.Topic(this, 'TestjsTopic');
topic.addSubscription(new subs.SqsSubscription(queue));
topic.addSubscription(new SqsSubscription(queue));
}
}
Expand Down

0 comments on commit f2905c5

Please sign in to comment.