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: add support for multi-line import extension normalization #120

Merged

Conversation

alexgrozav
Copy link
Contributor

@alexgrozav alexgrozav commented Jan 12, 2023

Fixes #45 and unjs/unbuild#83.

The change essentially does the following:

  • One-line imports are handled as they were before
  • Multi-line imports are handled only if brackets are present, allowing full control over the multi-line capture group, so that we don't mistakenly capture functions and objects that use brackets.

The simplest solution of using [\s\S] instead of .* will spill over to export function() {} and export {};, therefore it's not feasible.

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

This looks good to me - thanks!

@danielroe danielroe requested a review from pi0 January 26, 2023 10:03
@codecov
Copy link

codecov bot commented Jan 26, 2023

Codecov Report

Merging #120 (0fa3d1e) into main (01f72a5) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #120   +/-   ##
=======================================
  Coverage   96.09%   96.09%           
=======================================
  Files           8        8           
  Lines         487      487           
  Branches       98       98           
=======================================
  Hits          468      468           
  Misses         19       19           
Impacted Files Coverage Δ
src/make.ts 89.70% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0
Copy link
Member

pi0 commented Feb 6, 2023

Thanks for the fix and sorry for delay. Later, we might change this to mlly utils for more stable impl.

@pi0 pi0 merged commit 53ff281 into unjs:main Feb 6, 2023
@alexgrozav alexgrozav deleted the 45-multiline-import-extension-normalization branch February 7, 2023 10:46
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.

Improve import extension normalization
3 participants