Simon VerhoevenS
Convex Community13mo ago
4 replies
Simon Verhoeven

Issue using externalPackages Not Excluding Dependencies

I am trying to use fabric
fabric/node
in a convex node action and it seems it's dependency
canvas
cannot be bundled and will produce this issue when deploying convex functions

 No loader is configured for ".node" files: node_modules/fabric/node_modules/canvas/build/Release/canvas.node

    node_modules/fabric/node_modules/canvas/lib/bindings.js:3:25:
      3 │ const bindings = require('../build/Release/canvas.node')


It seems to me that the solution should be to add this to
convex.json
as shown here https://docs.convex.dev/functions/bundling#external-packages

{
  "node": {
    "externalPackages": ["canvas"]
  }
}


However this does not solve the issue

Also I think that adding
node.externalPackages
does nothing as I did an experiment

{
  "node": {
    "externalPackages": ["lodash"]
  }
}


But when I
npx convex dev --once --debug-bundle-path /tmp/myBundle
I still see
lodash
being bundled. I would have expected
myBundle
to contain a
node_modules
folder with lodash there separately (if I have understood this correctly).


Sample Code


I created a minimal reconstruction branched from one of the convex-samples, and put my node action in
convex/issue.ts

Steps to reproduce
Checkout repo
npx convex dev --once --debug-bundle-path /tmp/myBundle


You can see my failed debugging attempt to externalize
lodash
here https://github.com/ziggy6792/convex-issue/tree/debug/bundle-lodash

And my failed attempt to externalize
canvas
here https://github.com/ziggy6792/convex-issue.git


Any help would be greatly appreciated or if someone has a sample repo where
node.externalPackages
is demonstrated that would be great (maybe I do not understand how it should work)

Thanks!
GitHub
Contribute to ziggy6792/convex-issue development by creating an account on GitHub.
GitHub
Contribute to ziggy6792/convex-issue development by creating an account on GitHub.
GitHub - ziggy6792/convex-issue
Bundling is the process of gathering, optimizing and transpiling the JS/TS
Bundling | Convex Developer Hub
Was this page helpful?