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: handle files with multiple comments #7202

Merged
merged 2 commits into from Mar 7, 2022
Merged

Conversation

benmccann
Copy link
Collaborator

Description

Import scan for dependency optimizer is bombing out if a file has multiple comments

Adding the g flag appeared sufficient for fixing it. I had also considered whether I should make it gims instead for consistency with the lines above it

Additional context

Originally reported as sveltejs/kit#3985


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link
Contributor

@tony19 tony19 left a comment

Choose a reason for hiding this comment

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

Regarding ims flags:

  • m (not needed) - This only affects the behavior of ^ and $, which doesn't exist in the pattern.
  • i (not needed) - This enables case insensitive matching for literal letters, which don't exist in the pattern.
  • s (consider) - This makes . match new lines, which would simplify the pattern from <!--(.|[\r\n])*?--> to /<!--.*?-->/, making it more readable. 👍 demo

packages/vite/src/node/optimizer/scan.ts Outdated Show resolved Hide resolved
@bluwy bluwy added the p3-minor-bug An edge case that only affects very specific usage (priority) label Mar 7, 2022
@patak-dev patak-dev merged commit 3f5b645 into vitejs:main Mar 7, 2022
@benmccann benmccann deleted the commentRE branch March 7, 2022 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants