Open dgoemans opened 3 weeks ago
Update: Some nicer, future proof, options to prevent the code splitting from happening with Dynamic imports:
new optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
entry: {
service1: {
import: path.resolve(__dirname, 'service1.ts'),
chunkLoading: false
}
}
This is an intentional and configurable webpack behavior. We do not plan to change it, since many users are relying on the code-splitting behavior, and configuration of webpack allows opting out.
I understand that it's intentional behavior, but it was introduced without any mention (that i could find) in the release notes. This meant that between minor updates, stuff broke. I noticed some docs (a footnote) about this eventually, but with no reasonable solution. As I found in the closed issues, seems to have affected others too, and I assume some of them have simply left it at an old version, which wasn't an option for us and is generally not a good long term thing.
At the very least, this issue, with a solution, is important as documentation for others who encounter the same problem, but I would suggest adding some expanded docs for this.
Hey @dgoemans ,
Thanks for the feedback! The code splitting behavior is introduced in our supplemental doc under performance section: https://github.com/aws/aws-sdk-js-v3/blob/main/supplemental-docs/performance/dynamic-imports.md
I recognize searching for this topic may not be straightforward. I'll discuss with the team about potentially highlighting or linking directly to this specific section from our main page readme file to help make it more discoverable.
Thanks! Maggie
Updates:
We will add a link to supplemental doc from developer guide. Some other updates will also be made to make supplemental doc more discoverable.
That would help, thanks! I eventually found the docs you linked here, but it took a lot of searching, since they were not referenced in the release notes or any other "normal entry point" docs I found. Didn't even know those supplemental docs existed!
internal ref : V1578398855
Checkboxes for prior research
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
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
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:
Additional Information/Context
Issue was already reported here: https://github.com/aws/aws-sdk-js-v3/issues/5990 by @nikimicallef