Skip to content

Commit

Permalink
Transform global imported from 'aws-sdk/global' (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Apr 11, 2024
1 parent 1d35766 commit 98790a3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-crabs-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Transform global imported from 'aws-sdk/global'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import AWS from "aws-sdk/global";

const client = new AWS.DynamoDB();
const data = await client.listTables().promise();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { DynamoDB } from "@aws-sdk/client-dynamodb";

const client = new DynamoDB();
const data = await client.listTables();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const AWS = require("aws-sdk/global");

const client = new AWS.DynamoDB();
const data = await client.listTables().promise();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { DynamoDB } = require("@aws-sdk/client-dynamodb");

const client = new DynamoDB();
const data = await client.listTables();
1 change: 1 addition & 0 deletions src/transforms/v2-to-v3/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const transformer = async (file: FileInfo, api: API) => {
return file.source;
}

replaceDeepImport(j, source, { fromPath: "aws-sdk/global", toPath: PACKAGE_NAME });
replaceDeepImport(j, source, { fromPath: "aws-sdk/clients/all", toPath: PACKAGE_NAME });

const v2GlobalName = getGlobalNameFromModule(j, source);
Expand Down

0 comments on commit 98790a3

Please sign in to comment.