Skip to content

Conversation

@AllanZhengYP
Copy link
Contributor

Webpack5 fails when bundler lib-storage because it requires 'fs' module. This change explicitly disable bundling fs module in browsers.

Issue

When bundling code bellow with Webpack 5:

import { S3Client } from "@aws-sdk/client-s3";
import { Upload } from "@aws-sdk/lib-storage";

const Bucket = "xxx";
const Body = "xxx"

const s3 = new S3Client({
  credentials: {
    accessKeyId: "key",
    secretAccessKey: "secret"
  },
  region: "us-west-2"
});

const upload = new Upload({
  client: s3,
  params: {
    Bucket,
    Key: "xxx",
    Body
  }
})

upload.done().then(console.log).catch(console.error)

Webpack fail to bundle it out-of-box:

Module not found: Error: Can't resolve 'fs' in '/xxx/workspace/tmp/sdk-test/lib-dynamodb'

This change fix the issue.

Additional context

Add any other context about the PR here.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Webpack5 fails when bundler lib-storage because it requires 'fs' module. This change explicitly disable bundling fs module in browsers.
@codecov-commenter
Copy link

Codecov Report

Merging #2818 (4067730) into main (4986bab) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2818   +/-   ##
=======================================
  Coverage   60.17%   60.17%           
=======================================
  Files         548      548           
  Lines       28592    28592           
  Branches     7000     7000           
=======================================
  Hits        17204    17204           
  Misses      11388    11388           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4986bab...4067730. Read the comment docs.

@AllanZhengYP AllanZhengYP merged commit ae0e206 into aws:main Sep 24, 2021
@github-actions
Copy link

github-actions bot commented Oct 9, 2021

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 Oct 9, 2021
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.

3 participants