feat: Ensure module-sync conditions also trace cjs fallback#550
Merged
feat: Ensure module-sync conditions also trace cjs fallback#550
Conversation
…odule-sync condition, causing runtimes with the require(esm) flag disabled to be unable to find a module
styfle
reviewed
Nov 19, 2025
styfle
reviewed
Nov 19, 2025
… into fix-module-sync-for-cjs
styfle
reviewed
Nov 20, 2025
styfle
reviewed
Nov 20, 2025
styfle
reviewed
Nov 20, 2025
styfle
reviewed
Nov 21, 2025
styfle
reviewed
Nov 21, 2025
styfle
approved these changes
Nov 21, 2025
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
jeffsee55
added a commit
that referenced
this pull request
Nov 26, 2025
…allback (#557) The code (added [here](#550)) was previously only adding the fallback when the condition was a string, but wasn't handling `{`"default": {"default": "./fallback.js"}}`, as is used in [this package](https://www.npmjs.com/package/@mjackson/node-fetch-server/v/0.2.0?activeTab=code)
1 task
5 tasks
serhalp
added a commit
to netlify/build
that referenced
this pull request
Dec 4, 2025
We had [previously pinned to 0.29.4](#6610) because [0.30 introduced a bug](https://answers.netlify.com/t/react-router-app-crashing-because-it-cant-find-package/155391). This was fixed in vercel/nft#550, released in 1.1.0. I've confirmed this: 1. Clone https://github.com/netlify/react-router-template/ 2. `npm i` 4. ✅ `rm -rf .netlify/ && npx -y netlify@latest deploy --skip-functions-cache` 5. ✅ `rm -rf .netlify/ && npx -y netlify@23.0.0 deploy --skip-functions-cache` 6. ✅ `rm -rf .netlify/ && npx -y netlify@23.1.3 deploy --skip-functions-cache` 7. ❌ `rm -rf .netlify/ && npx -y netlify@23.1.2 deploy --skip-functions-cache` 8. Clone this branch, `npm i && npm run build`. Clone netlify-cli, `npm link ../build/packages/zip-it-and-ship-it`. 9. ✅ `rm -rf .netlify/ && ../cli/bin/run.js deploy --skip-functions-cache`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: Include fallback condition when evaluating module-sync exports
Previously, when resolving the
module-synccondition, we only traced themodule-syncfile itself, not the fallback (requireordefaultcondition). This caused runtimes with require(esm) disabled to be unable to find the module.Also, fixed a bug in the
module-sync-condition-cjstest where:test-pkg-sync-esinstead oftest-pkg-sync-cjs(wrong package name)require()syntax (appropriate for CJS packages)module-sync-condition-cjs-node20test for Node 20 behaviorTest Coverage
module-sync-condition-cjsrequire()module-sync.js,fallback.jsmodule-sync-condition-cjs-node20require()fallback.jsmodule-sync-condition-esimportmodule-sync.js,fallback.jsmodule-sync-condition-es-node20importimport.jsAlso adjusts jest thresholds, here are the main paths this PR added that it did not add test coverage for, mostly error handling