Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(credential-provider-node): use dynamic import for credential providers #5677

Merged
merged 5 commits into from
Jan 19, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Jan 11, 2024

Description

  • this PR uses dynamic imports in the node default credential provider chain
    • this reduces the number of files loaded during app initialization
    • Node.js has good support for dynamic imports whether via await import() or simple dynamic require() calls.

This avoids the issue of browser/bundler and react-native compatibility.

Testing

  • cucumber-js e2e
  • yarn test:e2e
  • yarn test:integration
  • check Node.js 14.x support (yes, supported, but also TS compiles import() to a require) so there is no difference. ESBuild if used in the future does not convert import() to require(), but it does not need to.

effects on SDK initialization times:

  • dynamic imports that are avoided save time for SDK init
  • dynamic imports are not slower than regular imports (in dist-cjs they are all require at this point anyway)

@kuhe
Copy link
Contributor Author

kuhe commented Jan 11, 2024

Example in conjunction with "package-bundling":
Loading S3 and making 1 request. Initially only 135 files are loaded. After 3 providers are invoked, the loaded number of files reaches 151.

files 135
AWS SDK loading env provider
AWS SDK loading sso provider
AWS SDK loading ini provider
{
  httpStatusCode: 200,
  requestId: '...',
  extendedRequestId: '...+...+...+...=',
  cfId: undefined,
  attempts: 1,
  totalRetryDelay: 0
}
files after init 151

@kuhe kuhe force-pushed the feat/dynamic-import branch 3 times, most recently from c9504c7 to 348c283 Compare January 12, 2024 16:37
@kuhe kuhe marked this pull request as ready for review January 12, 2024 16:38
@kuhe kuhe requested a review from a team as a code owner January 12, 2024 16:38
@kuhe kuhe merged commit 7841411 into aws:main Jan 19, 2024
3 checks passed
@kuhe kuhe deleted the feat/dynamic-import branch January 19, 2024 16:24
kuhe added a commit to kuhe/aws-sdk-js-v3 that referenced this pull request Jan 19, 2024
kuhe added a commit that referenced this pull request Jan 19, 2024
Copy link

github-actions bot commented Feb 3, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants