Conversation
Fixes #24709 When bundling code with `void import()` (side-effect only dynamic imports), the bundler was generating invalid JavaScript syntax like `.then(() => )` instead of `.then(() => void 0)`. This happened when the bundler transformed internal dynamic imports but had no content to put in the .then() callback (e.g., when the module had no exports or wrapper to call). The fix tracks whether any content was printed in the dynamic import body and ensures we print `void 0` when nothing else needs to be printed, resulting in valid syntax. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Updated 7:42 PM PT - Nov 15th, 2025
❌ Your commit
🧪 To try this PR locally: bunx bun-pr 24750That installs a local version of the PR into your bun-24750 --bun |
WalkthroughThe PR fixes incorrect code transformation during dynamic imports by tracking printed content within import bodies and ensuring syntactically valid expressions. When no content is generated, Changes
Possibly related PRs
Pre-merge checks✅ Passed checks (4 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (11)📓 Common learnings📚 Learning: 2025-10-19T02:44:46.354ZApplied to files:
📚 Learning: 2025-10-18T23:43:42.502ZApplied to files:
📚 Learning: 2025-11-14T16:07:01.064ZApplied to files:
📚 Learning: 2025-11-06T00:58:23.965ZApplied to files:
📚 Learning: 2025-10-08T13:48:02.430ZApplied to files:
📚 Learning: 2025-10-26T01:32:04.844ZApplied to files:
📚 Learning: 2025-09-20T03:39:41.770ZApplied to files:
📚 Learning: 2025-11-08T04:06:33.198ZApplied to files:
📚 Learning: 2025-11-03T20:40:59.655ZApplied to files:
📚 Learning: 2025-09-02T05:33:37.517ZApplied to files:
🧬 Code graph analysis (1)test/regression/issue/24709.test.ts (1)
🔇 Additional comments (2)
Comment |
|
Closing as duplicate - this was already fixed in PR #24710 |
Summary
Fixes #24709
When bundling code with
void import()(side-effect only dynamic imports), the bundler was generating invalid JavaScript syntax like.then(() => )instead of.then(() => void 0).Before:
After:
Root Cause
When the bundler transforms internal dynamic imports, it wraps them in
Promise.resolve().then(() => <content>). However, when the imported module has no exports or wrapper to call (e.g., pure side-effect imports that get tree-shaken), nothing was being printed in the callback body, resulting in invalid syntax.Solution
The fix tracks whether any content was printed in the dynamic import body and ensures we print
void 0when nothing else needs to be printed, resulting in valid JavaScript syntax.Test Plan
test/regression/issue/24709.test.tsUSE_SYSTEM_BUN=1 bun test(reproduces the bug)bun bd test(verifies the fix)🤖 Generated with Claude Code