-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(remix-dev): set esbuild
's serverPlatform
to browser
for Cloudflare & Deno
#3330
Conversation
Hi @rgdelato, Welcome, and thank you for contributing to Remix! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
serverPlatform
to browser
for Cloudflare & Deno
Looking forward to this landing! Just ran into it in the context of trying to use Sanity in the workers template |
🦋 Changeset detectedLatest commit: 29181b1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
is it possible to use these changes before this is merged? i.e. by adding something to remix.config.js? or do i need to run a fork of remix until this is merged? |
@schpet There is no configuration in |
@machour thanks so much for this info! with this patch i was able to successfully get react-markdown working on remix deployed to cloudflare pages (and locally via wrangler) |
@MichaelDeBoey sorry for tagging you directly, from the source code it seems that you are the last one that worked on the file, it would be great if this fix can be integrated . Thank you |
I'm honestly a bit concerned this has been an issue for so long, is there a better way to flag important community pull requests to the Remix team? Note that this blocks being able to use @authjs in remix cloudflare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm honestly not sure if we should support "browser"
as value to serverPlatform
as the ESbuild platform
docs themselves are saying we should set it to "node"
when we're generating code for the (Node) server.
If your bundled code is intended to run in node instead, you should set the platform to
node
@rgdelato @RyKilleen @schpet @apalumbo @acoreyj I think the solution for #3120, algolia/react-instantsearch#3547, nextauthjs/next-auth#6270, Sanity, ... would be to wrap your components in something like @sergiodxa's remix-utils
' ClientOnly
component.
Hey @MichaelDeBoey for more details I think the issue stems from how cloudflare workers use V8 but not node, they do implement a lot of web apis so it seems it's more similar to deno than node? I'm guessing that's why remix currently sets the esbuild platform to "neutral" instead of "node" for cloudflare (same as for deno). The error that happens though is because the wrangler package for building to cloudflare uses a package "node-modules-polyfills" which when esbuild is in neutral can't seem to properly find the exports. So right now in my project if esbuild is "neutral" I get the error
But if it is set to "browser" it works. |
Tagging @evanw (the creator of ESbuild) to see if ESbuild's |
@MichaelDeBoey As far as I can tell, one of the main issues is that these packages specify various entry points for different platforms in their package.json (here's an example from My understanding is that Cloudflare wants to resolve "worker" or "browser" exports when they're specified. I think esbuild's conditions can cover the So maybe esbuild should support |
is this still an issue?? |
serverPlatform
to browser
for Cloudflare & Denoesbuild
's serverPlatform
to browser
for Cloudflare & Deno
Hi @rgdelato! Are you still interested in getting this one merged? If so, please rebase onto latest |
This PR has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from PRs that are unactionable. Please reach out if you have more information for us! 🙂 |
Apologies for forgetting about this, I was on an anniversary trip! But also, I wrote this PR like a year ago, and I would gladly defer to anyone else who has more familiarity with the codebase. (If not, I might try to take another look at this issue in a couple weeks.) |
Setting esbuild platform to "browser" for Cloudflare and Deno to fix errors with using various libraries on those platforms.
Closes: #3120, algolia/react-instantsearch#3547
For additional context, this setting was originally set to
neutral
in #1504Testing Strategy:
I'm having some difficulty writing a test for this. I've been able to locally run two playground apps that are fixed by this change (one that imports
react-markdown
and one that importsalgoliasearch
), but I would appreciate some help with writing an integration test!