Dependencies with multiple entrypoints causes deployment error when targeting Edge runtime
Setup
I have a minimal Remix app using Vite: https://github.com/mnemitz/remix-test-app
This app imports a dummy library I've created here: https://github.com/mnemitz/my-test-lib
The library has the two module entrypoints defined in its package.json
"exports": {
"./module-a": "./dist/module-a/index.js",
"./module-b": "./dist/module-b/index.js"
},
Node deployment works
On the main branch of the test app, the deployment succeeds, and successfully outputs data from both modules: https://remix-test-onfl44vri-matt-nemitzs-projects.vercel.app/
Edge deployment fails
However on the edge branch of the app, I've added the following to routes/_index.tsx:
export const config = { runtime: "edge" };
And the deployment results in an error:
Error: The Edge Function "index" is referencing unsupported modules:
--
17:11:16.015 | - build/server/edge-eyJydW50aW1lIjoiZWRnZSJ9/index.js: my-test-lib/module-a, my-test-lib/module-b
I think this may also be causing the issue described here: https://github.com/vercel/remix/issues/94
Workaround for anyone hitting this issue is to set the following environment variable: VERCEL_EDGE_FUNCTIONS_ENHANCED_RESOLVE=1
https://github.com/vercel/remix/issues/94#issuecomment-2064655540