shadow-cljs

2025-03-16T04:10:34.749649Z

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

cormacc 2025-03-17T12:22:49.115599Z

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.

2025-03-17T15:22:02.977479Z

I didn’t manage to get this working yet, I wonder if doing ‘:js-provider :external’ and then using esbuild would help

thheller 2025-03-17T15:22:27.746889Z

that is the alternate option yes

2025-03-18T04:27:47.682649Z

Thanks for the help, I'm making progress now and able to bundle in the aws sdk using webpack

thheller 2025-03-16T07:34:12.196209Z

> stream is meant to be automatically polyfilled in the browser

thheller 2025-03-16T07:34:51.669459Z

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

thheller 2025-03-16T07:38:00.508839Z

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

thheller 2025-03-16T07:41:12.946989Z

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.

thheller 2025-03-16T07:42:13.478209Z

in the :js-options the default :entry-keys ["browser" "main" "module"] can be overriden to place "module" first instead

thheller 2025-03-16T07:43:04.313469Z

as well as :export-conditions ["browser" "require" "default" "module" "import"] moving "module" "import" in front of "require"

thheller 2025-03-16T07:44:00.524079Z

so :js-options {:entry-keys ["module" "browser" "main"] :export-conditions ["module" "import" "browser" "require" "default"]}

thheller 2025-03-16T07:44:18.949139Z

some packages would be unhappy with this and might warrant moving "browser" to first position

thheller 2025-03-16T07:44:26.408159Z

its a mess ...

2025-03-17T01:41:23.297029Z

Thanks for the response, I’ll try your suggestions!

2025-03-16T04:11:42.654249Z

This is the line that I causes the failure: https://github.com/danielmartincraig/surprisebuildweb/blob/main/src/app/core.cljs#L18

2025-03-16T04:11:57.338079Z

This is the link to my project https://github.com/danielmartincraig/surprisebuildweb