CLI: Rollup does not build some packages correctly #6288
Labels
bug
Something isn't working
cli
CLI tool for plugins and apps
help wanted
Help/Contributions wanted from community members
I have been having issues with using AWS SDK v3 from the backend, since it depends on uuidjs. uuidjs targets browser by default, and must explicitly use a
exportConditions: ['node']
flag to build the correct version. If I am understanding the Backstage code correctly, this is missing from the rollup args used in the bundler.This Rollup issue is propagating into Backstage since users do not have control over the rollup config (at least to my knowledge).
Expected Behavior
When the backend is built, it should select the node version of uuidjs.
Current Behavior
The browser version is built instead, which leads to this error message from AWS SDK.
From looking at the uuidjs code, this error is only possible on the browser version.
Possible Solution
I am a total rollup novice, but I think it would be possible to globally configure
exportConditions: ['node']
in the backend/bundler code. If I am misunderstanding how that flag works, it may be a question of analyzing the package.json of each module and checking for a "node" export. Kind of a pain so I hope the first one works.For now I am using a crypto polyfill, which works just fine, but this issue really stumped me for a while and I would like to save some future devs the frustration.
Steps to Reproduce
uuid.v4()
function from within the express routerContext
Using AWS SDK v3. See error message above.
Here's the package.json for uuidjs for more context.
Your Environment
The text was updated successfully, but these errors were encountered: