-
-
Notifications
You must be signed in to change notification settings - Fork 781
fix(rolldown): fix CJS require handling for nodeless worker builds #4019
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
base: main
Are you sure you want to change the base?
Conversation
|
@medz is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
π WalkthroughWalkthroughThis PR introduces require-condition resolution for Rolldown in Nitro's build system. It adds a new plugin module that conditionally resolves CommonJS require calls based on export conditions, integrates it into the Rolldown configuration, and provides comprehensive unit tests for the new functionality. Changes
Estimated code review effortπ― 3 (Moderate) | β±οΈ ~25 minutes Possibly related PRs
π₯ Pre-merge checks | β 2 | β 1β Failed checks (1 warning)
β Passed checks (2 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing touches
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Caution
Some comments are outside the diff and canβt be posted inline due to platform limitations.
β οΈ Outside diff range comments (1)
src/build/rolldown/config.ts (1)
52-57:β οΈ Potential issue | π‘ MinorRemove debug
console.logβ likely a leftover.Line 54 unconditionally logs
warning.codeto stdout on every rolldown warning. This looks like a debug artifact. Thewarn(warning)call on the next line already handles emitting the warning properly. Per coding guidelines, build code should useconsolaornitro.loggerfor logging.Proposed fix
onwarn(warning, warn) { if (!base.ignoreWarningCodes.has(warning.code || "")) { - console.log(warning.code); warn(warning); } },As per coding guidelines,
src/**/*.{js,ts}: "Useconsolafor logging in build/dev code; usenitro.loggerwhen available".
commit: |
π Linked issue
#4010
β Type of change
π Description
This fixes the rolldown regression reported in #4010 for Cloudflare worker targets.
require-callto resolve package exports withrequire-first conditions (instead of accidentally selectingimportentries for CJS requires).esmExternalRequirePluginfor nodeless builds so Node builtins used via CJSrequire()are emitted as ESM-compatible externals for worker runtimes.import/require) resolution behavior.Validated with the minimal repro:
medz/nitro-issue-4010-pg-cloudflare-repro
NITRO_BUILDER=rolldown nitro build+wrangler devnow starts successfully and serves requests (norequire("events")startup failure).π Checklist