fix: don't fail tarball bundling on modules that don't exist if they are optional or caught#7001
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe tarball bundler now avoids including local Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
| if (module.error?.startsWith('Module not found')) { | ||
| // Module graph contains all found imported/required modules, even if they don't actually exist | ||
| // This can happen for optional dependencies (dynamic import or require in try/catch). | ||
| continue | ||
| } |
There was a problem hiding this comment.
If this was critical error that prevents code to run - we wouldn't get to this point and would crash hard at Inline Config extraction which does load the bundle and return config export.
So if we get here and we get Module not found errored modules in module graph - this should be case of optional modules (try/catch) OR "virtual" modules (like Next.js Node middleware setup before workaround applied in opennextjs/opennextjs-netlify#3448 )
…caught-missing-dynamic-import
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/edge-bundler/node/bundler.test.ts`:
- Around line 1268-1272: The test passes extra optional options that reference
non-existent files—remove the configPath and importMapPaths entries from the
bundle(...) call in bundler.test.ts so the test only provides basePath,
featureFlags, and declarations; specifically edit the bundle invocation (the
call to bundle([...], distPath, declarations, {...})) to delete the configPath
and importMapPaths properties and leave the rest unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f723daad-ef3f-4584-aadd-d5f57f454e29
📒 Files selected for processing (3)
packages/edge-bundler/node/bundler.test.tspackages/edge-bundler/node/formats/tarball.tspackages/edge-bundler/test/fixtures/caught-module-not-found-import/netlify/edge-functions/func1.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
9533e9a to
abed9be
Compare
…caught-missing-dynamic-import
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes https://linear.app/netlify/issue/FRB-2118/bundling-fails-on-caught-missing-dynamic-import
For us to review and ship your PR efficiently, please perform the following steps:
we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
something that`s on fire 🔥 (e.g. incident related), you can skip this step.
your code follows our style guide and passes our tests.
A picture of a cute animal (not mandatory, but encouraged)