Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 22, 2025

  • Add strip-literal dependency to packages/plugin-rsc/package.json
  • Import stripLiteral function in packages/plugin-rsc/src/plugin.ts
  • Apply stripLiteral() to code before matchAll for import.meta.viteRsc.loadModule
  • Apply stripLiteral() to code before matchAll for import.meta.viteRsc.loadBootstrapScriptContent
  • Apply stripLiteral() to code before matchAll for import.meta.viteRsc.loadCss
  • Extract arguments using indices from original code (not from stripped code)
  • Remove strip-literal.test.ts file per maintainer feedback
  • Run pnpm install to update lockfile
  • Run build to ensure everything compiles
  • Run all unit tests (57 tests passing)
  • Run linting checks
  • Run TypeScript compiler checks
  • Run CodeQL security check (no vulnerabilities found)

Summary

Fixed false detection of import.meta.viteRsc API calls inside comments and strings by:

  1. Added strip-literal@^3.1.0 dependency to strip comments and string literals before pattern matching
  2. Updated three transform functions to use stripLiteral(code).matchAll() instead of code.matchAll()
  3. Used match indices to extract arguments from original code (not stripped version) to preserve actual values

The fix ensures that API calls in comments like // import.meta.viteRsc.loadModule("test") and strings like "import.meta.viteRsc.loadCss('test')" are correctly ignored, while actual API calls are properly detected and transformed.

Original prompt

take over to fix #931


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix issues in pull request #931 for vite-plugin-react fix(rsc): fix false detection of import.meta.viteRsc API inside comments and strings Oct 22, 2025
Copilot AI requested a review from hi-ogawa October 22, 2025 11:22
Copilot finished work on behalf of hi-ogawa October 22, 2025 11:22
Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

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

@copilot remove packages/plugin-rsc/src/plugins/strip-literal.test.ts.

Copy link
Contributor Author

Copilot AI commented Oct 22, 2025

@copilot remove packages/plugin-rsc/src/plugins/strip-literal.test.ts.

Removed in f13b79a

Copilot AI requested a review from hi-ogawa October 22, 2025 11:44
Copilot finished work on behalf of hi-ogawa October 22, 2025 11:44
@hi-ogawa hi-ogawa marked this pull request as ready for review October 22, 2025 13:45
@hi-ogawa hi-ogawa merged commit a212cd5 into main Oct 22, 2025
25 of 40 checks passed
@hi-ogawa hi-ogawa deleted the copilot/fix-pull-request-931 branch October 22, 2025 23:43
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.

2 participants