-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add node:* to external whitelist #11665
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
Conversation
|
|
@benmccann could we go ahead and merge this one in? I could open a PR for workers shortly thereafter. |
I'd rather just have one PR It looks like #10544 does the same thing, but behind a flag. My first impression is that it seems reasonable to merge one of these, but I'm not sure which approach is better. What happens if you don't have |
Without the The |
I want to know what the user experience is though. What's the error message a user will get and will it occur when building or running? CC @chientrm |
The error will occur when building without |
i.e. same as what happens when trying to import any other non-existing module... |
packages/adapter-cloudflare/index.js
Outdated
@@ -66,7 +66,7 @@ export default function (options = {}) { | |||
loader: { | |||
'.wasm': 'copy' | |||
}, | |||
external: ['cloudflare:*'] | |||
external: ['cloudflare:*', 'node:*'] |
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.
Whitelisting node:*
may be too aggressive. I think if we do that and someone uses an API like node:fs
then they won't find out their app is broken until they go to deploy it and it'd be better for that to occur during build. How about we switch it to just the list of APIs that Cloudflare supports with their node compatibility?
'node:assert', 'node:async_hooks', 'node:buffer', 'node:crypto', node:diagnostics_channel', node:events', node:path', node:process', node:stream', node:string_decoder', node:util'
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.
According to Cloudflare's docs, node:fs
isn't available. Are you seeing otherwise?
Also keep in mind that node_compat
is disabled by default. Users need to explicitly enable it.
While I'm not against an explicit list of whitelisted APIs, it seems unnecessary (and increases maintance burden as more APIs are gradually added).
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.
According to Cloudflare's docs, node:fs isn't available. A
Yes, that's my point. If you whitelist node:*
then an app using node:fs
will pass the build and then fail during deployment. By whitelisting just the supported APIs we could save people by discovering this sooner
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.
@benmccann good point. I've updated the PR to include the curated list of modules.
Thanks — closing this in favour of #10544 which does the same thing but also updates |
Allows for running supported Node packages on Cloudflare.
This is a rather serious oversight, given that no official solution has been rolled out after ~8 months of user attempts.
This PR is based on @chientrm's efforts (among others) at getting this pushed through.
Prior attempts:
#10028 -- support node compat in CF adapter
#10110 -- expose
external
esbuild option#10214 -- allow override esbuild option
#10424 -- pass
external
to esbuild#10521 -- pass
alias
andexternal
to esbuildThe proposals to expose data to esbuild sound great... but for most use-cases, it's overkill for the simple need to access Node packages on Cloudflare.
@benmccann Can we please just add
node:*
to theexternal
array?Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits