Skip to content

CLI: Add react-vite to tanstack-react automigration#34718

Merged
huang-julien merged 24 commits into
nextfrom
feat/tanstack_automigrate
May 7, 2026
Merged

CLI: Add react-vite to tanstack-react automigration#34718
huang-julien merged 24 commits into
nextfrom
feat/tanstack_automigrate

Conversation

@huang-julien
Copy link
Copy Markdown
Contributor

@huang-julien huang-julien commented May 5, 2026

#34284

What I did

This PR adds the automigration from react(-vite to tanstack-react.

It does the basics from migration then ask if the user needs an AI prompt to migrate the whole project. It also update thhe migration.md file

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Verify on any OSS tanstack start/router project that the command works correctly

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-34718-sha-a8323eee. Try it out in a new sandbox by running npx storybook@0.0.0-pr-34718-sha-a8323eee sandbox or in an existing project with npx storybook@0.0.0-pr-34718-sha-a8323eee upgrade.

More information
Published version 0.0.0-pr-34718-sha-a8323eee
Triggered by @huang-julien
Repository storybookjs/storybook
Branch feat/tanstack_automigrate
Commit a8323eee
Datetime Wed May 6 09:25:53 UTC 2026 (1778059553)
Workflow run 25427141480

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=34718

Summary by CodeRabbit

  • New Features

    • Automated migration to upgrade projects from the React Vite Storybook package to the dedicated TanStack React Storybook framework, updating deps, configs, and imports.
    • Detects existing TanStack Router decorators and offers guided replacements with copy-to-clipboard support.
  • Documentation

    • Added a migration guide with steps, examples, and automigration usage.
  • Tests

    • Added tests covering detection, prompts, dry-run behavior, and migration actions.
  • Chores

    • Added a small clipboard utility dependency.

huang-julien and others added 5 commits April 28, 2026 16:36
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@huang-julien huang-julien requested review from kylegach and shilman May 5, 2026 12:24
@huang-julien huang-julien added feature request cli automigrations ci:normal ci:docs Run the CI jobs for documentation checks only. and removed ci:docs Run the CI jobs for documentation checks only. labels May 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an automigration that replaces @storybook/react-vite with @storybook/tanstack-react, detects manual TanStack Router decorators, rewrites package.json and .storybook/main.*, transforms story/config imports, provides an AI-ready clipboard prompt for manual decorator removal, adds tests, and documents the migration in MIGRATION.md.

Changes

React-Vite → TanStack-React Automigration

Layer / File(s) Summary
Docs / TOC
MIGRATION.md
Adds "TanStack Router projects: migrate from @storybook/react-vite to @storybook/tanstack-react" under 10.3.0→10.4.0 with usage, examples, and automigration notes.
Dependency Addition
code/lib/cli-storybook/package.json
Adds tinyclip@^0.1.12.
Registry Integration
code/lib/cli-storybook/src/automigrate/fixes/index.ts
Imports and registers reactViteToTanstackReact in allFixes.
Constants / Heuristics
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts
Adds REACT_VITE_PACKAGE, TANSTACK_REACT_PACKAGE, TanStack package markers, and fileLooksLikeTanstackRouterDecorator.
Decorator Detection
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts
Adds detectTanstackRouterDecorator(...) that globs preview/config/stories files and inspects contents for TanStack Router imports and provider/constructor markers.
Main Config Transform
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts
Adds transformMainConfig(...) to replace @storybook/react-vite with @storybook/tanstack-react in .storybook/main.* (respects dryRun).
AI Prompt Builder
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts
Adds buildAiMigrationPrompt(...) producing an instructional prompt for removing manual decorators and switching to parameters.tanstack.router.
Core Fix Implementation
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts
Exports reactViteToTanstackReact fix with check, prompt, and run: checks package presence, collects package.jsons to update, removes @storybook/react-vite and adds @storybook/tanstack-react@<storybookVersion> (unless dryRun), updates main config, runs transformImportFiles on discovered files, logs warnings, and offers/copies the AI prompt when a manual decorator is detected (respecting --yes and dryRun).
Tests
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts
Adds Vitest coverage mocking fs, globby, transformImportFiles, tinyclip, and prompt/logger; tests check (presence/absence and decorator detection), prompt content, run behavior (dependency edits, main config rewrite, dry-run, prompt/clipboard interactions), and --yes bypass.

Sequence Diagram

sequenceDiagram
    participant CLI as Automigrate CLI
    participant Checker as Check Logic
    participant FS as File System
    participant Detector as Decorator Detector
    participant Prompt as Prompt Handler
    participant Transformer as Migration Runner
    participant Clipboard as Clipboard

    CLI->>Checker: check() for React-Vite & TanStack packages
    Checker->>FS: scan package.json files
    FS-->>Checker: package presence result

    alt both packages present
        Checker->>Detector: detectTanstackRouterDecorator()
        Detector->>FS: glob candidate files (preview, configDir, stories)
        FS-->>Detector: file contents
        Detector-->>Checker: decorator found? (true/false)
        Checker-->>CLI: return migration metadata
    else missing package
        Checker-->>CLI: return null
    end

    CLI->>Prompt: prompt() (shows old/new packages)
    Prompt-->>CLI: message

    CLI->>Transformer: run() perform migration
    Transformer->>FS: update package.json (remove/add packages)
    Transformer->>FS: transform `.storybook/main.*` (replace framework)
    Transformer->>FS: transform imports via transformImportFiles
    FS-->>Transformer: write results

    alt decorator detected & no --yes
        Transformer->>Prompt: ask to copy AI prompt
        Prompt-->>Transformer: user confirms
        Transformer->>Clipboard: copy AI migration prompt
        Clipboard-->>CLI: clipboard contains prompt
    end
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts (1)

155-156: ⚡ Quick win

Mock behaviors inside test cases should be moved to beforeEach.

Lines 155–156 dynamically re-import and configure globby inside a test case, and line 264 sets prompt.confirm's resolved value inline. Both should be configured in a beforeEach block (or a nested describe block with its own beforeEach) rather than inline inside the test.

As per coding guidelines: "Implement mock behaviors in beforeEach blocks in Vitest tests" and "Avoid inline mock implementations within test cases in Vitest tests."

Also applies to: 264-264

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts`
around lines 155 - 156, Move inline mock setups for globby and prompt.confirm
out of individual tests into a shared beforeEach (or a nested describe with its
own beforeEach): import or require globby at the top of the test module, then in
beforeEach call vi.mocked(globby).mockResolvedValue(...) instead of
mockResolvedValueOnce inside the test, and similarly set
vi.mocked(prompt).confirm.mockResolvedValue(...) (or
prompt.confirm.mockResolvedValue) in beforeEach; update tests that relied on
per-test one-off values to adjust expectations or reconfigure mocks within
nested beforeEach if a single-test behavior is required. Ensure you reference
the existing uses of globby and prompt.confirm in the test file when moving the
mocks.
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts (1)

37-45: ⚡ Quick win

Simplify the import detection to avoid the static-analysis regexp-from-variable warning.

TANSTACK_ROUTER_PACKAGES is a static list, so there's no actual ReDoS risk, but the new RegExp(...) construction still triggers the warning. A plain string check covers every real-world import style equally well:

♻️ Proposed simplification
 const fileLooksLikeTanstackRouterDecorator = (content: string): boolean => {
-  const importsTanstackRouter = TANSTACK_ROUTER_PACKAGES.some((pkg) =>
-    new RegExp(`from\\s+['"]${pkg.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\$&')}['"]`).test(content)
-  );
+  const importsTanstackRouter = TANSTACK_ROUTER_PACKAGES.some(
+    (pkg) => content.includes(`from '${pkg}'`) || content.includes(`from "${pkg}"`)
+  );
   if (!importsTanstackRouter) {
     return false;
   }
   return TANSTACK_ROUTER_DECORATOR_MARKERS.some((marker) => content.includes(marker));
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`
around lines 37 - 45, The function fileLooksLikeTanstackRouterDecorator uses new
RegExp(...) against each pkg from TANSTACK_ROUTER_PACKAGES which triggers the
static-analysis regexp-from-variable warning; replace the RegExp test with a
plain string check (e.g., content.includes(pkg) or content.indexOf(pkg) !== -1)
to detect imports, keep the existing early return and the subsequent
TANSTACK_ROUTER_DECORATOR_MARKERS.some(...) check unchanged so the function
still returns true only when a package import and a decorator marker are
present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts`:
- Around line 15-40: Update the four vi.mock calls to use the spy form
(vi.mock('module', { spy: true })) instead of providing factory functions;
remove the inline factory objects for 'node:fs/promises',
'storybook/internal/node-logger', 'storybook/internal/common', and 'globby' and
instead set default mock behavior in beforeEach using
vi.mocked(readFile).mockResolvedValue(...),
vi.mocked(writeFile).mockResolvedValue(...),
vi.mocked(logger.step).mockImplementation(...)/vi.mocked(logger.error).mockImplementation(...)/vi.mocked(prompt.confirm).mockResolvedValue(...),
vi.mocked(transformImportFiles).mockResolvedValue([]), and
vi.mocked(globby).mockResolvedValue([]) so each export becomes a tracked spy
while preserving per-test configuration.

In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`:
- Around line 404-413: The clipboard write call await writeText(aiPrompt) can
throw in headless/CI environments and must be wrapped in a try-catch so the
overall run doesn't reject after a successful migration; inside the
wantsAiPrompt branch (where buildAiMigrationPrompt is called) wrap
writeText(aiPrompt) in try { await writeText(aiPrompt); logger.logBox(...) }
catch (err) { logger.warn(`Could not copy AI prompt to clipboard:
${String(err)}`); logger.logBox(...) } so the migration file writes remain
successful and a clear warning is logged instead of letting writeText propagate
an exception.
- Around line 363-366: The run function's file-scan uses globby without guarding
for configDir and without the same filters as detectTanstackRouterDecorator, so
add a guard to skip globby when configDir is falsy and apply the same glob
pattern/filters (restrict to relevant extensions and ignore node_modules/dist)
used in detectTanstackRouterDecorator; specifically update the block that
imports globby and builds configFiles/ allFiles (references: configDir, globby,
configFiles, allFiles, storiesPaths, run) to early-return or treat configFiles
as [] when configDir is undefined and pass the extension pattern and ignore
options to globby to match the check path behavior.

---

Nitpick comments:
In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts`:
- Around line 155-156: Move inline mock setups for globby and prompt.confirm out
of individual tests into a shared beforeEach (or a nested describe with its own
beforeEach): import or require globby at the top of the test module, then in
beforeEach call vi.mocked(globby).mockResolvedValue(...) instead of
mockResolvedValueOnce inside the test, and similarly set
vi.mocked(prompt).confirm.mockResolvedValue(...) (or
prompt.confirm.mockResolvedValue) in beforeEach; update tests that relied on
per-test one-off values to adjust expectations or reconfigure mocks within
nested beforeEach if a single-test behavior is required. Ensure you reference
the existing uses of globby and prompt.confirm in the test file when moving the
mocks.

In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`:
- Around line 37-45: The function fileLooksLikeTanstackRouterDecorator uses new
RegExp(...) against each pkg from TANSTACK_ROUTER_PACKAGES which triggers the
static-analysis regexp-from-variable warning; replace the RegExp test with a
plain string check (e.g., content.includes(pkg) or content.indexOf(pkg) !== -1)
to detect imports, keep the existing early return and the subsequent
TANSTACK_ROUTER_DECORATOR_MARKERS.some(...) check unchanged so the function
still returns true only when a package import and a decorator marker are
present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9e182563-d782-46de-87b1-54f3b15d2b27

📥 Commits

Reviewing files that changed from the base of the PR and between 6750e05 and acb41b5.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • MIGRATION.md
  • code/lib/cli-storybook/package.json
  • code/lib/cli-storybook/src/automigrate/fixes/index.ts
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts

Comment thread code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts Outdated
Comment thread code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts Outdated
@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented May 5, 2026

Package Benchmarks

Commit: 5456279, ran on 7 May 2026 at 08:38:01 UTC

The following packages have significant changes to their size or dependencies:

@storybook/builder-webpack5

Before After Difference
Dependency count 186 186 0
Self size 79 KB 79 KB 🚨 +48 B 🚨
Dependency size 32.92 MB 32.94 MB 🚨 +16 KB 🚨
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 190 190 0
Self size 15 KB 15 KB 0 B
Dependency size 29.64 MB 29.65 MB 🚨 +16 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 536 536 0
Self size 651 KB 651 KB 0 B
Dependency size 61.04 MB 61.05 MB 🚨 +16 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 273 273 0
Self size 23 KB 23 KB 0 B
Dependency size 45.59 MB 45.60 MB 🚨 +16 KB 🚨
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 198 198 0
Self size 16 KB 16 KB 0 B
Dependency size 34.18 MB 34.20 MB 🚨 +16 KB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 194 194 0
Self size 890 KB 906 KB 🚨 +16 KB 🚨
Dependency size 84.49 MB 84.48 MB 🎉 -1 KB 🎉
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 166 166 0
Self size 18 KB 18 KB 0 B
Dependency size 31.93 MB 31.94 MB 🚨 +16 KB 🚨
Bundle Size Analyzer Link Link

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts (1)

363-366: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard configDir and apply the same filtered globby pattern used in check.

Line 365 currently does an unguarded broad glob (${configDir}/**/*). This can degrade scan behavior and skip intended rewrite targets when configDir is absent/invalid. Mirror the guarded, extension-filtered scan used in detectTanstackRouterDecorator.

🛡️ Targeted fix
-// eslint-disable-next-line depend/ban-dependencies
-const { globby } = await import('globby');
-const configFiles = await globby([`${configDir}/**/*`]);
+// eslint-disable-next-line depend/ban-dependencies
+const { globby } = await import('globby');
+const configFiles = configDir
+  ? await globby([`${configDir}/**/*.{ts,tsx,js,jsx,mjs,cjs}`], {
+      ignore: ['**/node_modules/**', '**/dist/**'],
+    })
+  : [];
 const allFiles = [...storiesPaths, ...configFiles].filter(Boolean) as string[];
#!/bin/bash
target="code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts"

# Compare globby usage in check vs run blocks
rg -n "detectTanstackRouterDecorator|const configFiles =|globby\\(" "$target" -C 3
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`
around lines 363 - 366, The current unguarded glob using globby for
`${configDir}/**/*` can run when configDir is absent or invalid and misses
extension filtering; update the block that defines configFiles (the const
configFiles = await globby(...) usage) to first guard that configDir is truthy
and only call globby when it is, and use the same extension-filtered glob
pattern and options used by detectTanstackRouterDecorator (i.e., limit to
relevant file extensions and any ignore patterns), then merge with storiesPaths
into allFiles as before; ensure references to configDir, configFiles,
storiesPaths, and allFiles are preserved so the downstream logic remains
unchanged.
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts (1)

15-44: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Switch these Vitest mocks to spy: true and move default implementations into beforeEach.

At Line 15-44, mocks are still factory-based, and at Line 35/39/43/53-54 default behaviors are defined outside beforeEach. This is still violating the repo’s Vitest mock policy.

♻️ Minimal alignment patch
-vi.mock('node:fs/promises', () => ({
-  readFile: vi.fn(),
-  writeFile: vi.fn(),
-}));
+vi.mock('node:fs/promises', { spy: true });

-vi.mock('storybook/internal/node-logger', () => ({
-  logger: {
-    step: vi.fn(),
-    debug: vi.fn(),
-    warn: vi.fn(),
-    log: vi.fn(),
-    error: vi.fn(),
-    logBox: vi.fn(),
-  },
-  prompt: {
-    confirm: vi.fn(),
-  },
-}));
+vi.mock('storybook/internal/node-logger', { spy: true });

-vi.mock('storybook/internal/common', () => ({
-  transformImportFiles: vi.fn().mockResolvedValue([]),
-}));
+vi.mock('storybook/internal/common', { spy: true });

-vi.mock('globby', () => ({
-  globby: vi.fn().mockResolvedValue([]),
-}));
+vi.mock('globby', { spy: true });

-vi.mock('tinyclip', () => ({
-  writeText: vi.fn().mockResolvedValue(undefined),
-}));
+vi.mock('tinyclip', { spy: true });
#!/bin/bash
target="code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts"

# 1) Find factory-style vi.mock calls (should be none after fix)
rg -nP "vi\.mock\([^,]+,\s*\(\)\s*=>" "$target"

# 2) Spot inline default mock implementations outside beforeEach (quick signal)
rg -n "mockResolvedValue\(" "$target"

As per coding guidelines, "Use vi.mock() with the spy: true option for all package and file mocks in Vitest tests", "Implement mock behaviors in beforeEach blocks in Vitest tests", and "Avoid mock implementations outside of beforeEach blocks in Vitest tests."

Also applies to: 53-63

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts`
around lines 15 - 44, Replace the factory-style vi.mock calls with spy-based
mocks (add { spy: true } to each vi.mock for 'node:fs/promises',
'storybook/internal/node-logger', 'storybook/internal/common', 'globby', and
'tinyclip') and remove their inline factory implementations; then move all
default mock behaviors (readFile/writeFile,
logger.step/debug/warn/log/error/logBox and prompt.confirm,
transformImportFiles, globby, and tinyclip.writeText) into a beforeEach block
where you set up the spies (e.g., vi.mocked(...).mockResolvedValue /
mockImplementation as needed) so no mockResolvedValue or default implementations
exist outside beforeEach and all vi.mock calls use the spy:true option.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts`:
- Around line 15-44: Replace the factory-style vi.mock calls with spy-based
mocks (add { spy: true } to each vi.mock for 'node:fs/promises',
'storybook/internal/node-logger', 'storybook/internal/common', 'globby', and
'tinyclip') and remove their inline factory implementations; then move all
default mock behaviors (readFile/writeFile,
logger.step/debug/warn/log/error/logBox and prompt.confirm,
transformImportFiles, globby, and tinyclip.writeText) into a beforeEach block
where you set up the spies (e.g., vi.mocked(...).mockResolvedValue /
mockImplementation as needed) so no mockResolvedValue or default implementations
exist outside beforeEach and all vi.mock calls use the spy:true option.

In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`:
- Around line 363-366: The current unguarded glob using globby for
`${configDir}/**/*` can run when configDir is absent or invalid and misses
extension filtering; update the block that defines configFiles (the const
configFiles = await globby(...) usage) to first guard that configDir is truthy
and only call globby when it is, and use the same extension-filtered glob
pattern and options used by detectTanstackRouterDecorator (i.e., limit to
relevant file extensions and any ignore patterns), then merge with storiesPaths
into allFiles as before; ensure references to configDir, configFiles,
storiesPaths, and allFiles are preserved so the downstream logic remains
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6899a7c-6f0c-43ba-b8ff-3ceb15680393

📥 Commits

Reviewing files that changed from the base of the PR and between b24e31b and f792937.

📒 Files selected for processing (2)
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`:
- Around line 365-370: The current allFiles array (built from storiesPaths and
configFiles) omits previewConfigPath so preview imports may not be rewritten;
modify the code that builds allFiles (referencing configDir, configFiles,
storiesPaths, and allFiles) to also include previewConfigPath (if defined) in
the spread, e.g. [...storiesPaths, ...configFiles, previewConfigPath], then
dedupe/filter falsy values as before so the preview file is always considered
for import-rewrite even when configDir is missing or unexpected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b92242f6-7289-46f0-b3bb-7caaf8695ec3

📥 Commits

Reviewing files that changed from the base of the PR and between f792937 and 456b390.

📒 Files selected for processing (2)
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.test.ts

Comment thread code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts Outdated
…stack-react.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts (1)

37-45: ⚡ Quick win

Export fileLooksLikeTanstackRouterDecorator to enable direct unit testing.

This function encapsulates non-trivial two-step detection logic (package import + marker matching) that deserves targeted unit tests independent of the file I/O in detectTanstackRouterDecorator. As per coding guidelines, "Export functions that need direct tests to ensure they can be unit tested."

♻️ Proposed change
-const fileLooksLikeTanstackRouterDecorator = (content: string): boolean => {
+export const fileLooksLikeTanstackRouterDecorator = (content: string): boolean => {

As per coding guidelines: "Export functions that need direct tests to ensure they can be unit tested."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`
around lines 37 - 45, The function fileLooksLikeTanstackRouterDecorator
currently is unexported and should be exported so it can be unit-tested
directly; update its declaration to export the function (export const
fileLooksLikeTanstackRouterDecorator = ...) and ensure any existing
imports/exports in the module remain consistent (adjust any default export or
index re-exports if needed) so tests can import
fileLooksLikeTanstackRouterDecorator and exercise its two-step logic
(TANSTACK_ROUTER_PACKAGES and TANSTACK_ROUTER_DECORATOR_MARKERS checks).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`:
- Around line 294-309: The loop collects packageJsonFiles but those values
(packageJsonFiles, result.packageJsonFiles, result.hasReactVitePackage,
result.hasTanstackRouter) are never used by check/run, causing unnecessary I/O;
either remove the packageJsonFiles array and its field from the check result and
stop reading package.json files in check, or wire the collected packageJsonFiles
into run (e.g., pass result.packageJsonFiles to
packageManager.removeDependencies) and update run to scope removals to only
those package.json paths; locate the collection in the function containing the
packageJsonFiles variable and the consumers check/run that inspect
result.hasTanstackRouterDecorator and packageManager.removeDependencies to
implement one of these two fixes.

---

Nitpick comments:
In
`@code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts`:
- Around line 37-45: The function fileLooksLikeTanstackRouterDecorator currently
is unexported and should be exported so it can be unit-tested directly; update
its declaration to export the function (export const
fileLooksLikeTanstackRouterDecorator = ...) and ensure any existing
imports/exports in the module remain consistent (adjust any default export or
index re-exports if needed) so tests can import
fileLooksLikeTanstackRouterDecorator and exercise its two-step logic
(TANSTACK_ROUTER_PACKAGES and TANSTACK_ROUTER_DECORATOR_MARKERS checks).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76170a44-2459-49b6-af28-a953a8f1ac69

📥 Commits

Reviewing files that changed from the base of the PR and between 456b390 and ab9f5bc.

📒 Files selected for processing (1)
  • code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts

Comment thread code/lib/cli-storybook/src/automigrate/fixes/react-vite-to-tanstack-react.ts Outdated
huang-julien and others added 3 commits May 5, 2026 17:37
Co-authored-by: Copilot <copilot@github.com>
@kylegach
Copy link
Copy Markdown
Contributor

kylegach commented May 6, 2026

@huang-julien — Please also update the docs to include the equivalent of this section of the nextjs-vite docs.

huang-julien and others added 2 commits May 6, 2026 17:43
Co-authored-by: Copilot <copilot@github.com>
@huang-julien huang-julien enabled auto-merge May 6, 2026 16:23
@JReinhold JReinhold changed the title Cli: Add react-vite to tanstack-react automigration CLI: Add react-vite to tanstack-react automigration May 7, 2026
@huang-julien huang-julien disabled auto-merge May 7, 2026 07:19
Comment thread code/lib/cli-storybook/package.json Outdated
Comment thread MIGRATION.md
@huang-julien huang-julien merged commit 228542d into next May 7, 2026
109 checks passed
@huang-julien huang-julien deleted the feat/tanstack_automigrate branch May 7, 2026 09:07
@github-actions github-actions Bot mentioned this pull request May 7, 2026
15 tasks
@github-actions github-actions Bot mentioned this pull request May 7, 2026
32 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants