You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing vite and adding aws-amplify I get following error message:
[plugin:vite:imports] Failed to resolve import "process". Does the file exist?
/Users/XXXXX/node_modules/@aws-sdk/util-user-agent-node/dist/es/index.js:1:22
1 | import process from "process";
| ^
2 | export function defaultUserAgent(packageName, packageVersion) {
3 | var engine = process.platform + "/" + process.version;
Error: Failed to resolve import "process". Does the file exist?
at TransformContext.error (C:\Users\XXXXX\node_modules\vite\dist\node\chunks\dep-262f13eb.js:59552:50)
at TransformContext.transform (C:\XXXXX\node_modules\vite\dist\node\chunks\dep-262f13eb.js:52957:30)
at async Object.transform (C:\Users\XXXXX\node_modules\vite\dist\node\chunks\dep-262f13eb.js:59742:30)
at async transformRequest (C:\Users\XXXXX\node_modules\vite\dist\node\chunks\dep-262f13eb.js:65977:29)
at async C:\Users\XXXXX\node_modules\vite\dist\node\chunks\dep-262f13eb.js:66068:32
Obviously the AWS Package can not resolve nodeBuiltins.
I tried to exclude the aws packages from dependency optimization and also tried to add them to the allowNodeBuiltins option in various combinations e.g. as follows:
This is a wont fix, because aws-amplify is legit trying to import and use Node-only builtins when it's actually intended to be a client library. Unlike webpack 4, Vite does not shim Node built-ins. Note this means aws-amplify will break in webpack 5 as well because it no longer shims Node built-ins.
aws-amplify should stop relying on Node built-ins if it actually is meant to be used in the browser.
aws-amplify depends on aws-sdk, which has upgraded itself to differentiate the node and js runtime by using the browser field. However, its browser field setting is as follows:
"browser": {
"./runtimeConfig": "./runtimeConfig.browser"
// it means if a file A encounters a relative path import
// find the "browser" file using the path relative to file A, not the root
}
Currently this relative path could confuse vite resolver.
Describe the bug
After installing vite and adding aws-amplify I get following error message:
Obviously the AWS Package can not resolve nodeBuiltins.
I tried to exclude the aws packages from dependency optimization and also tried to add them to the
allowNodeBuiltins
option in various combinations e.g. as follows:Is it more like a problem of the aws-cli package? Or are there any known workarounds?
Reproduction
Download https://github.com/sem4phor/aws-cli-bug
Run
npm run dev
See error in console
Modify vite.config to allowNodeBuiltins and nothing happens
System Info
vite
version: 2.0.0beta5The text was updated successfully, but these errors were encountered: