vercel / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
55 stars 20 forks source link

Cannot deploy remix-utils to edge #94

Open penx opened 4 months ago

penx commented 4 months ago

I am using remix-utils/client-only in a route:

https://github.com/sergiodxa/remix-utils

import { ClientOnly } from "remix-utils/client-only";

export const config = { runtime: "edge" };

export default function Index() {
  return <ClientOnly>{() => <div>Example</div>}</ClientOnly>;
}

This errors during deployment:

Error: The Edge Function "example" is referencing unsupported modules:
    - __vc__ns__/0/build/server/edge-abcde/index.js: remix-utils/client-only

ClientOnly does not import from node, it only imports from react:

https://github.com/sergiodxa/remix-utils/blob/main/src/react/client-only.tsx https://github.com/sergiodxa/remix-utils/blob/main/src/react/use-hydrated.ts

So this component should be usable on Vercel Edge and this seems to be a false positive.

Is the vercel pipeline flagging this due to the peer dependencies of remix-utils containing @remix-run/node?

https://github.com/sergiodxa/remix-utils/blob/main/package.json

How can I deploy a route using remix-utils to the edge?


Reproduction:

https://github.com/penx/remix-utils-vercel-edge

TooTallNate commented 4 months ago

Thank you for the reproduction. We are investigating a fix for this.

TooTallNate commented 3 months ago

@penx Can you please try again and let me know if the issue is fixed for you?

penx commented 3 months ago

@TooTallNate unfortunately not, using remix-utils 7.6.0 and @vercel/remix 2.8.1

Screenshot 2024-04-18 at 16 24 06
TooTallNate commented 3 months ago

Apologies. We had to roll back the flag for the change that was fixing this issue. If you want to test, set the environment variable VERCEL_EDGE_FUNCTIONS_ENHANCED_RESOLVE=1.

penx commented 2 months ago

@TooTallNate do you know if enhanced resolve is still planned to be rolled out?

TooTallNate commented 2 months ago

It is still planned, but some other tasks have taken priority so far. We will get to it soon. Is setting that environment variable working for you in the meantime?

penx commented 1 month ago

@TooTallNate sorry for the delay in getting back, VERCEL_EDGE_FUNCTIONS_ENHANCED_RESOLVE=1 seems to help but when this is enabled we sometimes get an error post-build and pre-deploy so haven't been able to enable this permanently

sandbox.js:422:6610: ERROR: [plugin: vc:file-system] Expected "fakePath" to be defined

TooTallNate commented 1 month ago

@penx Would you be able to share a reproduction of when that happens?