aws-sdk-js-codemod
aws-sdk-js-codemod copied to clipboard
[Feature]: Dynamic imports
Self-service
- [ ] I'd be willing to implement this feature
Input code
import("aws-sdk")
.then((module) => {
return module.S3;
})
.then(() => {
const AWS = require("aws-sdk");
const s3 = new AWS.S3({});
});
Expected Output
import("@aws-sdk/client-s3")
.then((module) => {
return module.S3;
})
.then(async () => {
const { S3 } = require("@aws-sdk/client-s3");
const s3 = new S3({});
});
Additional context
Can be observed by checking out this change: https://github.com/awslabs/aws-sdk-js-codemod/compare/main...kuhe:aws-sdk-js-codemod:example/imports?expand=1
And running npx jest -t dynamic
Example production code: https://github.com/stream-labs/desktop/blob/428dc21e9dfe73e30640d9d3d629a65d13c30a63/app/util/slow-imports.ts#L4-L6
https://github.com/urbit/urbit/blob/410f491938b8361da59b7c5dcd02dfe08d6732ba/pkg/interface/src/logic/lib/S3Client.ts#L33