-
Notifications
You must be signed in to change notification settings - Fork 579
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
Unable to use with vite #2478
Comments
Related: #1164 (comment) |
Related: aws/aws-sdk-js#3673 |
Is there any updates? I run into the same issue. |
@klarkc did you solve this? |
@mdhelaluddin-ctg-bd in #2491 I solved only the occurrences in |
Some the techniques used to get AWS Amplify working with vite may be applicable. |
Workaround for a vue 2 project. Add this to your export default defineConfig({
resolve: {
alias: {
"./runtimeConfig": "./runtimeConfig.browser"
}
}
}) And this to <script>
window.global = window;
</script> |
I can't reproduce this problem with vite 2.9.9 and The distributable file structure has changed since the original issue was reported. Most browser/node incompatibility issues can be resolved by ensuring any bundlers involved are following the runtimeConfig.browser alias specified in each |
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing. |
I have this issue with |
What is the status on this? I'm seeing similar issues with Vite 3.0.0 and @AWS-SDK
|
There is a workaround in amplify docs. https://ui.docs.amplify.aws/react/getting-started/troubleshooting#vite |
@takayamaki it's great that a workaround exists, but it's quite a demand that users pollute their globals just to get some random library to work. The library shouldn't be written in such a way that makes this necessary |
@MagnusHJensen Did you ever find a solution to this? |
There is no error in vite 3.2.4 dev/build command with $ yarn create vite
...
success Installed "create-vite@3.2.1" with binaries:
- create-vite
- cva
✔ Project name: … vite-project
✔ Select a framework: › Vanilla
✔ Select a variant: › TypeScript
Scaffolding project in /Users/trivikr/workspace/vite-project...
...
$ cd vite-project
$ yarn vite --version
vite/3.2.4 darwin-x64 node-v16.18.0
$ yarn add @aws-sdk/credential-provider-cognito-identity@3.210.0 --exact
...
# Add import in src/main.ts
$ sed -i "1s|^|import '@aws-sdk/credential-provider-cognito-identity';\n|" src/main.ts
$ yarn dev
... no issues
$ yarn build
...
vite v3.2.4 building for production...
✓ 360 modules transformed.
dist/assets/typescript.f6ead1af.svg 1.40 KiB
dist/index.html 0.44 KiB
dist/assets/index.acb3e620.js 1.40 KiB / gzip: 0.72 KiB
dist/assets/index.d5a34e39.css 1.19 KiB / gzip: 0.62 KiB
✨ Done in 2.90s. |
Is this issue still reproducible for you? |
@trivikr did an upgrade to vite 2.9.15 and @aws-sdk/credential-provider-cognito-identity to 3.210.0, and it's working normally now: klarkc/aws-sdk-js-v3@c182359 |
Vite 3.2.4, @aws-sdk/credential-provider-cognito-identity 3.211.0 and I still can't complete a build with Vite. Though it looks like the error might have moved to
|
@dwightwatson can you make sure that all sub-dependencies are also up-to-date? The easiest way is to do that is to uninstall the package and then reinstall it at the desired version |
Yeah, tried that. Perhaps my issue is that my entry point is the specific
|
@dwightwatson I'm not able to repro it with $ yarn create vite
...
success Installed "create-vite@3.2.1" with binaries:
- create-vite
- cva
✔ Project name: … vite-project
✔ Select a framework: › Vanilla
✔ Select a variant: › TypeScript
Scaffolding project in /Users/trivikr/workspace/vite-project...
...
$ cd vite-project
$ yarn vite --version
vite/3.2.4 darwin-x64 node-v16.18.0
$ yarn add @aws-sdk/client-cloudwatch-logs@3.213.0 --exact
...
├─ uuid@8.3.2
└─ vite@3.2.4
Done in 4.49s.
# Add import in src/main.ts
$ sed -i "1s|^|import '@aws-sdk/client-cloudwatch-logs';\n|" src/main.ts
$ yarn dev
... no issues in build or on opening webpage on http://localhost:5173/
$ yarn build
...
vite v3.2.4 building for production...
✓ 360 modules transformed.
dist/assets/typescript.f6ead1af.svg 1.40 KiB
dist/index.html 0.44 KiB
dist/assets/index.acb3e620.js 1.40 KiB / gzip: 0.72 KiB
dist/assets/index.d5a34e39.css 1.19 KiB / gzip: 0.62 KiB
✨ Done in 2.90s. |
I've got a repro repo here: https://github.com/dwightwatson/vite which fails when running |
Any news on this issue? |
Any news on this? I can't use AWS-sdk/credentials-provider with sveltekit 1.0 and vite v4. The error is: the requested module '/node_modules/.vite/deps/@AWS-SDK credential-providers doesn't export a function like "fromEnv" But this is written and it seems to be an issue by the credentials-provider |
I have the same issue with Vite 4 and the aws-sdk/credentials-provider |
This issue is not with the direct import of AWS SDK for JavaScript (v3). This issue is discussed in Amplify in aws-amplify/amplify-js#9639, and the solution is to update your vite config as follows:
@Amplitude88 Is there a repro I can look at?
@kylemichaelreaves Do you have a repro I can look at? |
There is no error in vite 4.1.0 dev/build command with $ yarn create vite
...
success Installed "create-vite@4.1.0" with binaries:
- create-vite
- cva
✔ Project name: … vite-project
✔ Select a framework: › Vanilla
✔ Select a variant: › TypeScript
Scaffolding project in /Users/trivikr/workspace/vite-project...
...
$ cd vite-project
$ yarn set version stable
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.4.1/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.4.1.cjs
➤ YN0000: Done in 0s 407ms
$ yarn
$ yarn vite --version
vite/4.1.1 darwin-arm64 node-v16.19.0
$ yarn add @aws-sdk/credential-provider-cognito-identity@3.271.0 --exact
...
# Add import in src/main.ts
$ sed -i "1s|^|import '@aws-sdk/credential-provider-cognito-identity';\n|" src/main.ts
$ yarn dev
... no issues
$ yarn build
...
vite v4.1.1 building for production...
✓ 6 modules transformed.
dist/index.html 0.45 kB
dist/assets/typescript-f6ead1af.svg 1.44 kB
dist/assets/index-3443e464.css 1.24 kB │ gzip: 0.64 kB
dist/assets/index-5f8bed07.js 1.44 kB │ gzip: 0.74 kB |
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing. |
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. |
Describe the bug
It is not possible to import the sdk using vite (which uses rollup to bundle). It fails because it imports node-only dependencies into browser environment.
Your environment
Vite 2.3.7 (rollup bundler) with Node 15.14.0
SDK version number
@aws-sdk/credential-provider-cognito-identity@3.18.0
Is the issue in the browser/Node.js/ReactNative?
Browser
Steps to reproduce
https://github.com/klarkc/aws-sdk-js-v3
cd tests/vite-project yarn install yarn build
Observed behavior
Looking in the file, I see why, it imports
request
fromhttp
that does not exists in browsers. It seems that other packages have the same problem (I've tested with@aws-sdk/client-cognito-identity
, same result).Expected behavior
Should build without errors
Additional context
Related issue: https://github.com/aws-amplify/amplify-js/issues/7499
Vite wont fix: vitejs/vite#1374 (comment)
The text was updated successfully, but these errors were encountered: