Skip to content
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

fix: strip comment for syntax detection #196

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

huang-julien
Copy link
Contributor

@huang-julien huang-julien commented Sep 23, 2023

πŸ”— Linked issue

resolve #195

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

hi πŸ‘‹ this PR fix the syntax detection by removing comments before testing the code string.

There's another solution, much safer but not the best perfomance wise. It's to use an AST combined with magic-string

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@Hebilicious
Copy link
Member

Great, this will fix a bunch of downstream issues πŸ‘πŸ½

Copy link

codecov bot commented Jan 11, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Comparison is base (7c8af63) 86.99% compared to head (b6f0452) 86.99%.
Report is 1 commits behind head on main.

❗ Current head b6f0452 differs from pull request most recent head 7305f39. Consider uploading reports for the commit 7305f39 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #196   +/-   ##
=======================================
  Coverage   86.99%   86.99%           
=======================================
  Files           8        8           
  Lines        1007     1007           
  Branches      165      165           
=======================================
  Hits          876      876           
  Misses        131      131           

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks πŸ’―

@pi0 pi0 merged commit 4ffc601 into unjs:main Jan 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESM syntax detection and CJS syntax detection goes through comments
3 participants