-
Notifications
You must be signed in to change notification settings - Fork 634
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
After upgrading to AWS SDK for JavaScript v3 (from 3.398.0 to 3.682.0), we encountered an issue where Webpack splits the build output into multiple chunks/folders containing AWS-related code (e.g., 699.js, etc).
Despite having Webpack configured to bundle all modules into a single JavaScript file, these chunks were still generated. Investigation revealed that several AWS SDK modules, such as @aws-sdk/credential-provider-env and @aws-sdk/credential-provider-http, use dynamic imports internally, triggering this behavior.
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/client-*@3.682.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
Node 18
Reproduction Steps
- Use Webpack to bundle a project that imports AWS SDK v3 components (e.g., S3Client, DynamoDBClient).
- Configure Webpack with optimization.splitChunks: false and runtimeChunk: false to prevent code splitting.
- Observe that Webpack still splits certain AWS SDK modules into separate chunks/folders.
Observed Behavior
Instead of bundling all the dependencies into a single file, the code is split into separate chunks. When enabling named chunk IDs you can see that most of them are from the credentials providers, where dynamic imports are used.
Expected Behavior
Webpack should bundle all imported AWS SDK modules into the main JavaScript output, without creating additional chunks, especially when code splitting is explicitly disabled.
Possible Solution
Modifying webpack config to add aliases to force a non-dynamic import:
resolve: {
alias: {
'@aws-sdk/credential-provider-env': path.resolve(
__dirname,
'node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js'
),
... insert all other modules here
}
}
Additional Information/Context
Issue was already reported here:
#5990
by @nikimicallef