Skip to content

fix(create): repair router-only package manifests - #482

Open
jingjing2222 wants to merge 1 commit into
TanStack:mainfrom
jingjing2222:fix/router-only-pnp-manifest
Open

fix(create): repair router-only package manifests#482
jingjing2222 wants to merge 1 commit into
TanStack:mainfrom
jingjing2222:fix/router-only-pnp-manifest

Conversation

@jingjing2222

@jingjing2222 jingjing2222 commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • Add @tanstack/router-core to router-only React and Solid app dependencies so generated devtools resolve under strict package managers like Yarn PnP.
  • Keep @tanstack/router-plugin in devDependencies only for file-router templates, avoiding duplicate dependency/devDependency entries.
  • Preserve the existing router plugin version when router-only compatibility code moves it between package sections.

Reproduction

Reproduction repo: https://github.com/jingjing2222/tanstack-router-pnp-peer-repro

The repo contains two workspaces:

  • apps/repro: generated with yarn dlx @tanstack/cli create --router-only ...
  • apps/fixed: same app with only package manifest fixes applied

yarn dev:repro fails during Vite dependency optimization because @tanstack/router-devtools-core imports @tanstack/router-core, but the generated app does not provide it directly.

Failure screenshot: https://github.com/jingjing2222/tanstack-router-pnp-peer-repro/blob/main/docs/assets/repro-fails.png

yarn dev:fixed starts successfully after adding @tanstack/router-core and removing the duplicate @tanstack/router-plugin dependency entry.

Success screenshot: https://github.com/jingjing2222/tanstack-router-pnp-peer-repro/blob/main/docs/assets/fixed-starts.png

Summary by CodeRabbit

  • Bug Fixes
    • Improved router-only project setup for strict package managers to ensure routing packages land in the correct dependency sections (with the router plugin in development dependencies and router core where required).
    • Fixed React and Solid template package files to produce cleaner JSON output.
  • Tests
    • Added unit tests covering router-only dependency behavior for React and Solid templates.
  • Chores
    • Updated @tanstack/create and @tanstack/cli to patch-level releases.
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe37b5ee-e234-46b8-a6e0-7ba600706725

📥 Commits

Reviewing files that changed from the base of the PR and between 7a95b6a and 0a82014.

📒 Files selected for processing (5)
  • .changeset/tidy-spoons-dream.md
  • packages/create/src/frameworks/react/project/packages.json
  • packages/create/src/frameworks/solid/project/packages.json
  • packages/create/src/package-json.ts
  • packages/create/tests/package-json.test.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/create/src/frameworks/react/project/packages.json
  • packages/create/src/frameworks/solid/project/packages.json
  • .changeset/tidy-spoons-dream.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/create/src/package-json.ts
  • packages/create/tests/package-json.test.ts

📝 Walkthrough

Walkthrough

This PR updates router-only package.json generation for React and Solid so @tanstack/router-plugin is moved to devDependencies, @tanstack/router-core is ensured in dependencies, template JSON punctuation is corrected, and tests plus a changeset are added.

Changes

Router-only manifest fix

Layer / File(s) Summary
Core createPackageJSON logic for router-only mode
packages/create/src/package-json.ts
Adds a shared helper for router-only package.json conversion and calls it from the React and Solid routerOnly paths after framework-specific deletions.
Template packages.json punctuation fixes
packages/create/src/frameworks/react/project/packages.json, packages/create/src/frameworks/solid/project/packages.json
Adds trailing commas to the @tanstack/router-cli entries in the file-router package templates.
Tests and changeset for router-only fix
packages/create/tests/package-json.test.ts, .changeset/tidy-spoons-dream.md
Adds React and Solid router-only unit tests covering dependency placement and records the versioning/documentation update in a changeset.

Estimated code review effort: 2 (Simple) | ~12 minutes

🚥 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 summarizes the main change: fixing router-only package manifests in create.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/create/tests/package-json.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/create/tests/package-json.test.ts


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/create/src/package-json.ts (1)

136-169: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate router-plugin/router-core handling between react and solid branches.

The routerPluginVersion computation, moving @tanstack/router-plugin to devDependencies, and adding @tanstack/router-core to dependencies is copy-pasted verbatim across the react and solid branches. Extracting a shared helper would reduce duplication and the risk of the two branches drifting apart on future edits.

♻️ Suggested refactor
+  function applyRouterOnlyCompat() {
+    const routerPluginVersion =
+      packageJSON.devDependencies?.['`@tanstack/router-plugin`'] ??
+      packageJSON.dependencies?.['`@tanstack/router-plugin`'] ??
+      'latest'
+    delete packageJSON.dependencies?.['`@tanstack/router-plugin`']
+    packageJSON.devDependencies = {
+      ...(packageJSON.devDependencies ?? {}),
+      '`@tanstack/router-plugin`': routerPluginVersion,
+    }
+    packageJSON.dependencies = {
+      ...(packageJSON.dependencies ?? {}),
+      '`@tanstack/router-core`':
+        packageJSON.dependencies?.['`@tanstack/router-core`'] ?? 'latest',
+    }
+  }
+
   if (options.routerOnly) {
     if (options.framework.id === 'react') {
       delete packageJSON.dependencies?.['`@tanstack/react-start`']
       delete packageJSON.dependencies?.['`@tanstack/react-router-ssr-query`']
-      const routerPluginVersion = ...
-      ...
+      applyRouterOnlyCompat()
     }

     if (options.framework.id === 'solid') {
       delete packageJSON.dependencies?.['`@tanstack/solid-start`']
       delete packageJSON.dependencies?.['`@tanstack/solid-router-ssr-query`']
-      const routerPluginVersion = ...
-      ...
       delete packageJSON.scripts?.start
+      applyRouterOnlyCompat()
     }
   }
🤖 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 `@packages/create/src/package-json.ts` around lines 136 - 169, The react and
solid branches in packageJSON handling duplicate the same router plugin/core
migration logic, so extract that shared work into a helper and call it from both
branches. Move the routerPluginVersion lookup, deletion of
`@tanstack/router-plugin` from dependencies, promotion into devDependencies, and
ensuring `@tanstack/router-core` stays in dependencies into a reusable function
referenced by the package-json.ts flow, keeping the framework-specific deletions
separate.
🤖 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.

Nitpick comments:
In `@packages/create/src/package-json.ts`:
- Around line 136-169: The react and solid branches in packageJSON handling
duplicate the same router plugin/core migration logic, so extract that shared
work into a helper and call it from both branches. Move the routerPluginVersion
lookup, deletion of `@tanstack/router-plugin` from dependencies, promotion into
devDependencies, and ensuring `@tanstack/router-core` stays in dependencies into a
reusable function referenced by the package-json.ts flow, keeping the
framework-specific deletions separate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 263d423e-4d0c-4892-8d38-7bdb65521bd6

📥 Commits

Reviewing files that changed from the base of the PR and between 12c31df and 7a95b6a.

📒 Files selected for processing (5)
  • .changeset/tidy-spoons-dream.md
  • packages/create/src/frameworks/react/project/packages.json
  • packages/create/src/frameworks/solid/project/packages.json
  • packages/create/src/package-json.ts
  • packages/create/tests/package-json.test.ts
@jingjing2222
jingjing2222 force-pushed the fix/router-only-pnp-manifest branch from 7a95b6a to 0a82014 Compare July 4, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant