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

When using vite to build the browser environment package, an unrelated package(@aws-sdk/signature-v4-crt) is added #4464

Closed
3 tasks done
ZengTianShengZ opened this issue Feb 23, 2023 · 3 comments · Fixed by #5203
Assignees
Labels
bug This issue is a bug. investigating Issue is being investigated and/or work is in progress to resolve the issue. p3 This is a minor priority issue

Comments

@ZengTianShengZ
Copy link

Checkboxes for prior research

Describe the bug

I use aws-sdk-js-v3 sdk as a file upload tool. When I use vite to build this tool, the build product adds an unrelated package (@aws-sdk/signature-v4-crt). I see that this package is used in the nodejs environment. But I use the browser environment. Why is this package used, and how can I troubleshoot this package. And this package(@aws-sdk/signature-v4-crt) is built in commonjs module mode, what I need is es module mode

image

![image](https://user-images.githubusercontent.com/15622519/220857069-7237f6f3-86c2-483e-89a8-e9f11479e919.png)

SDK version number

"@aws-sdk/client-s3": "^3.137.0", "vite": "^2.9.13",

Which JavaScript Runtime is this issue in?

Browser

Details of the browser/Node.js/ReactNative version

node v16.15.1

Reproduction Steps

my vite build config

import { defineConfig } from 'vite';
import lerna from '../../lerna.json';
import dts from 'vite-plugin-dts';

export default defineConfig({
    plugins: [
        dts(),
    ],
    build: {
        rollupOptions: {
            external: ['axios'],
        },
        lib: {
            entry: './src/index.ts',
            formats: ['es'],
            fileName: () => {
                return 'index.es.js';
            },
        },
    },
});

Observed Behavior

Please check if you have installed "@aws-sdk/signature-v4-crt" package explicitly

Expected Behavior

Do not import the @aws-sdk/signature-v4-crt package, or the imported @aws-sdk/signature-v4-crt package is in es module mode

Possible Solution

No response

Additional Information/Context

No response

@ZengTianShengZ ZengTianShengZ added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 23, 2023
@RanVaknin RanVaknin self-assigned this Feb 23, 2023
@RanVaknin
Copy link
Contributor

RanVaknin commented Feb 23, 2023

Hi @ZengTianShengZ ,

This is indeed odd, that package should only be added explicitly, I'm not sure how it is getting installed automatically for you. Usage of MRAP requires installation of that package explicitly and this is documented here #2822
Regarding vite, since its a 3rd party tool Im not sure why they would add the crt package, you are using a browser environment and it's not even relevant.

Can you explicitly remove the package npm uninstall @aws-sdk/signature-v4-crt?

In addition can you share a code snippet so we can better understand your use of s3?

Thanks,
Ran~

@RanVaknin RanVaknin added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Feb 23, 2023
@ZengTianShengZ
Copy link
Author

I uploaded the sample code on github, you can git clone locally and build it

https://github.com/ZengTianShengZ/aws-sdk-js-v3-demo

@RanVaknin RanVaknin added investigating Issue is being investigated and/or work is in progress to resolve the issue. and removed response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. labels Feb 24, 2023
@github-actions
Copy link

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 Sep 28, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. investigating Issue is being investigated and/or work is in progress to resolve the issue. p3 This is a minor priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants