remix icon indicating copy to clipboard operation
remix copied to clipboard

Cannot deploy remix-utils to edge

Open penx opened this issue 1 year ago • 8 comments

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

penx avatar Mar 19 '24 12:03 penx

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

TooTallNate avatar Mar 21 '24 06:03 TooTallNate

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

TooTallNate avatar Apr 17 '24 19:04 TooTallNate

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

Screenshot 2024-04-18 at 16 24 06

penx avatar Apr 18 '24 15:04 penx

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.

TooTallNate avatar Apr 18 '24 17:04 TooTallNate

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

penx avatar May 23 '24 12:05 penx

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?

TooTallNate avatar May 23 '24 17:05 TooTallNate

@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

penx avatar Jun 10 '24 14:06 penx

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

TooTallNate avatar Jun 19 '24 00:06 TooTallNate