fix: handle multiline comments in stripComments#344
Conversation
The COMMENT_RE regex used `.+?` which does not match newline characters, causing multiline block comments to not be stripped. Changed to `[\s\S]*?` which matches any character including newlines. Before: `/* \n export * \n*/` was not stripped → false ESM detection After: `/* \n export * \n*/` is correctly stripped Fixes unjs#279
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughUpdated the block-comment stripping regex in syntax detection functions to properly match Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Summary
Fixes #279
Multiline block comments were not being stripped because the regex used
.+?which doesn't match newline characters.Reproduction
Fix
.+?→[\s\S]*?matches any character including newlines (non-greedy).Tests
Added 3 test cases for multiline block comments. All 201 tests pass.
Summary by CodeRabbit
Bug Fixes
Tests