Hi, I'm trying to use "@aws-sdk/client-cognito-identity-provider" and https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/cognito-identity-provider/actions/sign-up.js, but I'm getting the follow error: The required JS dependency "node:stream" is not available. But, stream is meant to be automatically polyfilled in the browser, as I understand it. I'm new to this world, could you help me understand how to satisfy this dependency? Link to repro in the thread
My (limited) experience with AWS dependencies would tend to confirm that they pull in the entire world -- added AWS amplify auth to a project a while back and my build went from 200 and something source files to 1200 and something. Played with supabase auth a bit since and their packages are much lighter. You can also develop against an instance running locally in docker, which is nice.
I didn’t manage to get this working yet, I wonder if doing ‘:js-provider :external’ and then using esbuild would help
that is the alternate option yes
Thanks for the help, I'm making progress now and able to bundle in the aws sdk using webpack
> stream is meant to be automatically polyfilled in the browser
there is no such thing as automatic polyfilling by browsers, this node:stream basically means that the package is expecting to run in node and will not work in the browser
the aws packages are kinda setup to just pull in the entire world and then have the build tool figure out what is actually needed, relying on some specific JS build tool quirks that shadow doesn't support
in this case you might get lucky by switching which files shadow-cljs uses. shadow still uses commonjs by default, since that is generally the more compatible set of files. you can switch it to ESM, but please note that this will affect all used packages. so it might break others in the process, really depends on which packages you use. either way, doesn't hurt to try.
in the :js-options the default :entry-keys ["browser" "main" "module"] can be overriden to place "module" first instead
as well as :export-conditions ["browser" "require" "default" "module" "import"] moving "module" "import" in front of "require"
so :js-options {:entry-keys ["module" "browser" "main"] :export-conditions ["module" "import" "browser" "require" "default"]}
some packages would be unhappy with this and might warrant moving "browser" to first position
its a mess ...
Thanks for the response, I’ll try your suggestions!
This is the line that I causes the failure: https://github.com/danielmartincraig/surprisebuildweb/blob/main/src/app/core.cljs#L18
This is the link to my project https://github.com/danielmartincraig/surprisebuildweb