-
Notifications
You must be signed in to change notification settings - Fork 278
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(vite-import): fix the issue of escaping comment code in on-demand packaging plugin #2726
Conversation
… packaging plugin
WalkthroughThe pull request introduces a modification to the Changes
Sequence DiagramsequenceDiagram
participant Code as Source Code
participant Regex as Import Regex
participant Transform as Code Transformer
Code ->> Regex: Match import statements
Regex -->> Code: Filter out commented imports
Regex ->> Transform: Process only active imports
Possibly related PRs
Suggested Labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThis pull request addresses an issue in the on-demand packaging plugin for Vite by modifying the regular expression used to import components. The change ensures that comment lines are not mistakenly interpreted as import statements, thereby preventing potential errors during the import process. Changes
|
const getCompRegExp = (libraryName: any) => | ||
new RegExp(`import\\s+?{*([\\w ,\\s]+)}*\\s+?from\\s+?('|")${libraryName}('|")`, 'g') | ||
new RegExp(`(?<!//\\s*)import\\s+?{*([\\w ,\\s]+)}*\\s+?from\\s+?('|")${libraryName}('|")`, 'g') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated regular expression now correctly excludes lines that are comments from being matched as import statements. This change prevents potential issues where commented-out code could be mistakenly processed, leading to errors in the on-demand packaging plugin.
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internals/vue-vite-import/src/index.ts (1)
157-157
: Consider clarifying or extending this comment.Currently, it only mentions excluding commented code with
//
. If you also want to exclude other comment types (e.g.,/* ... */
), clarify that in the comment, or update the RegExp accordingly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internals/vue-vite-import/src/index.ts
(1 hunks)
🔇 Additional comments (1)
internals/vue-vite-import/src/index.ts (1)
159-159
: Verify environment support for negative lookbehind.The negative lookbehind syntax
(?<! ...)
in the regex is not universally supported in older Node or browser versions. Ensure that the environment in which this plugin runs supports this feature. If backward compatibility is required, consider an alternative regex pattern or a simple substring check to skip lines beginning with//
.
fix(vite-import): 修复按需打包插件转义注释代码问题
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
#2564
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit