When using vite to build the browser environment package, an unrelated package(@aws-sdk/signature-v4-crt) is added
ZengTianShengZ opened this issue · 3 comments
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
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
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
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~
I uploaded the sample code on github, you can git clone locally and build it