remix icon indicating copy to clipboard operation
remix copied to clipboard

Dependencies with multiple entrypoints causes deployment error when targeting Edge runtime

Open mnemitz opened this issue 1 year ago • 2 comments

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/

Screenshot 2024-05-21 at 17 18 11

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

Screenshot 2024-05-21 at 17 21 21

mnemitz avatar May 21 '24 16:05 mnemitz

I think this may also be causing the issue described here: https://github.com/vercel/remix/issues/94

mnemitz avatar May 21 '24 16:05 mnemitz

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

mnemitz avatar Jun 10 '24 11:06 mnemitz