-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Broken polyfill on Cloudflare Pages after 1.17.1
upgrade
#6665
Comments
FYI, I downgraded to 1.7.0 but the issue remains, maybe this is related to another dependency that was updated? 🤔 |
My rollback to 1.17.0 fixed the issue with no other changes. A much simpler app in the same monorepo upgraded to v1.17.1 without issue, but it didn't need to include the I'm looking to see if I can find any upstream issues that have been reported, nothing so far. |
In my case it's a brand new app, I can't compare what modules were updated from 1.7.0 to 1.7.1, but I also only got this issue when I added |
Our smaller app still worked post-upgrade despite including On my side, if nobody else chimes in with more info, I'll try to figure out the minimal reproduction. |
You're right, I should import it from |
I am getting the same issue and i don't have any imports from @remix-run/node... 💿 Rebuilt in 1.2s
The original key "constants" is here:
▲ [WARNING] Duplicate key "constants" in object literal [duplicate-object-key]
The original key "constants" is here:
I am on 1.16.1 btw |
sorry i was on 1.17.1 i had ^1.16.1 in my package.json. I pinned it to 1.16.1 and the bugs went away. I have nothing requiring the /node i always use @remix-run/cloudflare |
@aaronadamsCA I followed your reproduction steps and I'm not seeing the local dev issue you described. Could you share a minimal repro? |
I am putting together a minimal reproduction now. |
@markdalgleish Very minimal reproduction: https://github.com/aaronadamsCA/remix-issue-6665 This crashes on |
1.17.1
upgrade1.17.1
upgrade
I've raised a couple of PRs against esbuild-plugins-node-modules-polyfill to address this issue. |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
I tried this against
import process from 'node:process';
globalThis.process = process;
export default function Index() {
const sanitizeHtml = require('sanitize-html'); // Ugh
return (
<div
dangerouslySetInnerHTML={{
__html: sanitizeHtml("<p>Hello world</p>"),
}}
></div>
);
} This seems to be because This feels like a pretty big hack to me though. You might want to look for a lighter-weight alternative to |
Can we maybe get this issue reopened for now until we can figure out a resolution? You won't get any disagreement on my part that With your help, here's what I think I know so far, please correct anything that isn't right:
Let me know what you think. IMHO:
|
I dug into the In order to get us back to a similar setup for you, I might need to add support for empty polyfills upstream. |
@markdalgleish Great find, thank you! That led me to look further into the underlying polyfill; patching out these two lines in it worked around the issue, so I agree that passing an empty polyfill will "solve" the problem. (I don't understand why an IMHO, the ability for Remix apps to "officially" opt into/out of specific polyfills seems like it could be a good long-term solution for all of these ecosystem challenges. If I could set Until then, with your help I've got a two-patch workaround that lets me get back onto Remix latest, so thanks again!
|
@aaronadamsCA Relating to your issue around globals, have you tried adding this to import process from 'node:process';
globalThis.process = process; I realise I posted earlier that I added this to |
🤖 Hello there, We just published version Thanks! |
@markdalgleish Thank you for the help and the update. I've managed to update the reproduction repository so that it works correctly without any patched packages. 🙌 Some quick observations:
|
🤖 Hello there, We just published version Thanks! |
1 similar comment
🤖 Hello there, We just published version Thanks! |
tried 1.19.0 with serverNodeBuiltinsPolyfill: {
modules: {
fs: "empty",
buffer: "empty",
"fs/promises": "empty",
},
}, but it still errors when
|
You'll need to add the import { Buffer } from 'buffer';
globalThis.Buffer = Buffer; Note that this won't work if you've set the |
What version of Remix are you using?
1.17.1
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
remix dev
or deploy to Cloudflare Pages.Expected Behavior
Works the same as v1.17.0.
Actual Behavior
When I use library
sanitize-html
, this results in the inclusion of polyfill"node-modules-polyfills-commonjs:tty"
, which crashes the Cloudflare Workers runtime.Local dev using Wrangler v2.20.0
First a warning:
Then an error:
Deploying to Cloudflare Pages results in "this deployment failed" with no details
The text was updated successfully, but these errors were encountered: