workers-sdk
workers-sdk copied to clipboard
🐛 BUG: Node API missing warnings when experimental:nodejs_compat_v2 is enabled for Pages project
Which Cloudflare product(s) does this pertain to?
Pages, Wrangler
What version(s) of the tool(s) are you using?
3.65.0
What version of Node are you using?
22.3.0
What operating system and version are you using?
Mac Sonoma 14.5
Describe the Bug
This is a follow up to https://github.com/cloudflare/workers-sdk/issues/6288
Building off of the reproduction from ^ that issue, I then tried to manually add unenv to my project — see https://github.com/irvinebroque/remix-d1/pull/9
When I build and then deploy, I see the following warnings:
▲ [WARNING] The package "node:fs" wasn't found on the file system but is built into node.
Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility flag.
Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details. Imported
from:
- ../build/server/index.js
▲ [WARNING] The package "node:module" wasn't found on the file system but is built into node.
Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility flag.
Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details. Imported
from:
- ../node_modules/unenv/dist/index.mjs
✨ Compiled Worker successfully
🌍 Uploading... (7/7)
Wrangler is telling me to enable nodejs_compat, but I've already enabled experimental:nodejs_compat_v2.
Calling this out as a separate issue from https://github.com/irvinebroque/remix-d1/pull/8 since these are warnings versus the errors in that issue, and because — once we fix that, there may be more specific guidance that we may need to give people.
This also demonstrates that today, in the current state of Wrangler, it's not possible for someone to say, "unenv, let me add it in myself and deploy.
If I change this line to be 'fs' instead of 'node:fs', then I get the following error:
✘ [ERROR] 1 error(s) and 0 warning(s) when compiling Worker.
✘ [ERROR] Could not resolve "fs"
../build/server/index.js:7:15:
7 │ import fs from "fs";
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node.
Add the "nodejs_compat" compatibility flag to your Pages project and make sure to prefix the module name with "node:" to enable Node.js compatibility.
So right now, it's not possible for me to check the behavior of what would happen for a Pages project, and validate that there's a path to start experimenting with unenv and deploying to production (because we're not recognizing the experimental:nodejs_compat_v2 flag properly when deploying a Pages project.
Please provide a link to a minimal reproduction
https://github.com/irvinebroque/remix-d1/pull/9