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

feat(isValidNodeImport): support stripComments option #236

Merged
merged 2 commits into from Mar 27, 2024

Conversation

huang-julien
Copy link
Contributor

πŸ”— Linked issue

huang-julien/nitro-applicationinsights#58
unjs/nitro#2308

❓ 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 adds a stripCommentsFromCode option for isValidNodeImport.

I think the stripComments option from detectSyntax was made to avoid breaking anything in the ecosystem.

The issue lies in the non-legacy externals plugin in nitro which tries to inline applicationinsights import when it shouldn't due to applicationinsights having cjs syntax and esm syntax within its comments.

The goal of the PR is to open another PR in nitro to add a stripCommentsFromCode option for the external rollup plugin.

πŸ“ Checklist

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

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

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

Project coverage is 87.34%. Comparing base (226a47b) to head (b39f7cf).
Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #236      +/-   ##
==========================================
- Coverage   88.04%   87.34%   -0.71%     
==========================================
  Files           8        8              
  Lines        1062     1098      +36     
  Branches      188      200      +12     
==========================================
+ Hits          935      959      +24     
- Misses        127      139      +12     

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

@huang-julien
Copy link
Contributor Author

huang-julien commented Mar 26, 2024

BTW any idea of a safer way to strip comments from a code so we can enable it by default in hasESMSyntax and hasCJSSyntax ?

@pi0
Copy link
Member

pi0 commented Mar 27, 2024

Thanks for the PR. I think the addition of this option is good for me but I probably won't enable it in any higher layers like Nitro because it can cause other regressions unless there are more examples like applicationinsights that are currently broken.

BTW any idea of a safer way to strip comments from a code so we can enable it by default in hasESMSyntax and hasCJSSyntax ?

#219 (in next major version)

@pi0 pi0 changed the title feat: add stripCommentsFromCode option to isValidNodeImport feat(isValidNodeImport): add stripCommentsFromCode Mar 27, 2024
src/syntax.ts Outdated Show resolved Hide resolved
src/syntax.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title feat(isValidNodeImport): add stripCommentsFromCode feat(isValidNodeImport): support stripComments option Mar 27, 2024
@pi0 pi0 merged commit daef55a into unjs:main Mar 27, 2024
5 of 6 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.

None yet

2 participants