Skip to content

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Jan 17, 2026

Summary

Fixes: USER-4353

Vue SFC files require different prop syntax than React JSX when binding objects to props:

React JSX Vue Template
<Protect role="admin"> <Protect role="admin">
<Show when={{ role: 'admin' }}> <Show :when="{ role: 'admin' }">

This PR adds a Vue-specific codemod (transform-protect-to-show-vue) that handles .vue SFC files with proper Vue v-bind syntax.

Changes

  • New codemod: transform-protect-to-show-vue.cjs - Handles Vue SFC files
  • Test coverage: 20 test cases covering various Vue scenarios
  • Config update: core-3 config now routes SDKs to appropriate codemods:
    • transform-protect-to-shownextjs, react, expo, react-router, tanstack-react-start, astro
    • transform-protect-to-show-vuevue, nuxt

Vue Codemod Features

  • Transforms <script> imports (Protect → Show, ProtectProps → ShowProps)
  • Transforms <template> components with Vue v-bind syntax
  • Handles static props (role="admin") → :when="{ role: 'admin' }"
  • Handles dynamic props (:role="dynamicRole") → :when="{ role: dynamicRole }"
  • Handles condition callbacks (:condition="...":when="...")
  • Preserves fallback and other attributes
  • Only transforms templates when clerk imports are detected
  • Properly handles > and / inside quoted attribute values (like arrow functions)

Test plan

  • All 201 upgrade package tests pass
  • 20 new Vue-specific test cases added
  • Manual test with a Vue project using @clerk/vue
  • Manual test with a Nuxt project using @clerk/nuxt

Summary by CodeRabbit

  • New Features

    • Added a Vue-specific codemod to migrate Protect/SignedIn/SignedOut to Show in .vue files, converting auth props into proper when bindings and preserving other attributes.
  • Tests

    • Added a comprehensive test suite with 22+ fixtures covering diverse Vue transformation scenarios and edge cases.
  • Chores

    • Registered the Vue codemod alongside the existing transform and added a changeset for the upgrade.

✏️ Tip: You can customize this high-level summary in your review settings.

Vue SFC files require different prop syntax than React JSX:
- React: `<Protect role="admin">` → `<Show when={{ role: 'admin' }}>`
- Vue: `<Protect role="admin">` → `<Show :when="{ role: 'admin' }">`

This adds a Vue-specific codemod that:
- Transforms script imports (Protect → Show, ProtectProps → ShowProps)
- Transforms template components with Vue v-bind syntax
- Handles static and dynamic prop bindings
- Handles condition callbacks
- Only transforms when clerk imports are detected

The core-3 config is updated to run the appropriate codemod:
- `transform-protect-to-show` for React-based SDKs
- `transform-protect-to-show-vue` for Vue/Nuxt SDKs
@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2026

🦋 Changeset detected

Latest commit: 61c025d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/upgrade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
clerk-js-sandbox Skipped Skipped Jan 17, 2026 4:03am

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Adds a Vue-specific codemod and supporting tests/metadata to the upgrade package. New files: a changeset, packages/upgrade/src/codemods/transform-protect-to-show-vue.cjs (exports transformProtectToShowVue and sets module.exports.parser = 'tsx'), a fixtures file exporting fixtures, and a Vitest test suite exercising those fixtures. Updates packages/upgrade/src/versions/core-3/index.js to replace a single codemod entry with two entries: one for transform-protect-to-show (React/JSX targets) and one for transform-protect-to-show-vue (Vue targets). No public API removals.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a Vue-specific codemod for Protect to Show transformations.
Linked Issues check ✅ Passed The PR implements framework-specific codemod targeting [USER-4353] by creating a Vue-specific transform-protect-to-show-vue codemod and routing SDKs appropriately via core-3 config.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective: Vue codemod implementation, test fixtures/cases, codemod configuration, and framework routing—no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 17, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7615

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7615

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7615

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7615

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7615

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7615

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@7615

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7615

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7615

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7615

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7615

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7615

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7615

@clerk/react

npm i https://pkg.pr.new/@clerk/react@7615

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7615

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7615

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7615

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7615

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7615

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7615

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7615

commit: 61c025d

Copy link
Member

@wobsoriano wobsoriano left a comment

Choose a reason for hiding this comment

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

looks good here! thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants