fix(create): repair router-only package manifests#482
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR updates router-only package.json generation for React and Solid so ChangesRouter-only manifest fix
Estimated code review effort: 2 (Simple) | ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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
packages/create/tests/package-json.test.tsParsing error: "parserOptions.project" has been provided for 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/create/src/package-json.ts (1)
136-169: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate router-plugin/router-core handling between react and solid branches.
The
routerPluginVersioncomputation, moving@tanstack/router-plugintodevDependencies, and adding@tanstack/router-coretodependenciesis 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
📒 Files selected for processing (5)
.changeset/tidy-spoons-dream.mdpackages/create/src/frameworks/react/project/packages.jsonpackages/create/src/frameworks/solid/project/packages.jsonpackages/create/src/package-json.tspackages/create/tests/package-json.test.ts
7a95b6a to
0a82014
Compare
Summary
@tanstack/router-coreto router-only React and Solid app dependencies so generated devtools resolve under strict package managers like Yarn PnP.@tanstack/router-pluginindevDependenciesonly for file-router templates, avoiding duplicate dependency/devDependency entries.Reproduction
Reproduction repo: https://github.com/jingjing2222/tanstack-router-pnp-peer-repro
The repo contains two workspaces:
apps/repro: generated withyarn dlx @tanstack/cli create --router-only ...apps/fixed: same app with only package manifest fixes appliedyarn dev:reprofails during Vite dependency optimization because@tanstack/router-devtools-coreimports@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:fixedstarts successfully after adding@tanstack/router-coreand removing the duplicate@tanstack/router-plugindependency entry.Success screenshot: https://github.com/jingjing2222/tanstack-router-pnp-peer-repro/blob/main/docs/assets/fixed-starts.png
Summary by CodeRabbit
@tanstack/createand@tanstack/clito patch-level releases.