Skip to content
Source
Sign inSign up
TanStack/router

fix(router-devtools-core): bundle solid for smaller package #5374

Mergedbenmccann(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/5374/headmerged by birkskyum(GitHub profile, opens in a new tab)

It's pretty weird to be downloading solid into a react app and it adds an extra 3.5MB: https://pkg-size.dev/solid-js

By bundling solid we end up with a much smaller package since we keep only the parts of it that are used (~40kb) and tree-shake away the rest. This prevents deduping for solid users, so it's larger for those users. However, there are 3,700 weekly downloads from solid and 1 million from react, so this is a huge savings overall.

Summary by CodeRabbit

  • Chores
    • Updated package metadata and public entry points for the router devtools core package.
    • Moved a framework dependency to development-only and removed its peer-dependency declaration to reduce install warnings.
    • Clarified module entry exports to improve packaging; no functional changes for end users.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-devtools-core

    2. Walkthrough

      Moved solid-js from dependencies and peerDependencies into devDependencies in packages/router-devtools-core/package.json, and updated package public entry points/exports to point to ./dist/.../packages/router-devtools-core/src/* for both CJS and ESM.

      Changes

      Cohort / File(s)Summary
      package metadata
      packages/router-devtools-core/package.json
      - Removed solid-js from dependencies and peerDependencies; added solid-js to devDependencies (^1.9.5).
      - Updated main and module fields and exports defaults to ./dist/cjs/packages/router-devtools-core/src/index.cjs and ./dist/esm/packages/router-devtools-core/src/index.js respectively (replacing top-level ./dist/*/index.*).

      Estimated code review effort

      🎯 1 (Trivial) | ⏱️ ~2 minutes

      Suggested labels

      package: router-core

      Poem

      I twitch my whiskers, hop with cheer, A tiny change, dependencies clear— solid-js tucked in dev's small nest, exports pointed home, tucked and dressed. Hops and routes, a tidy feat. 🥕🐇

      Pre-merge checks and finishing touches

      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
      Title Check✅ PassedThe title succinctly describes the primary change of bundling Solid into the router-devtools-core package to reduce its size, matching the PR’s main objective without extraneous detail. It is concise, clear, and directly reflects the core modification.
      ✨ Finishing touches
      • 📝 Generate docstrings
        🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment

      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.
    3. Actionable comments posted: 1

      📜 Review details

      Configuration used: CodeRabbit UI

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between e94e9c7321ce8ba213ee421b4e1369429ffea384 and 371bb85d4ee64336cc86415ccc6bd728554d758d.

      ⛔ Files ignored due to path filters (1)
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing (1)
      • packages/router-devtools-core/package.json (1 hunks)
      🧰 Additional context used
      📓 Path-based instructions (1)
      **/package.json

      📄 CodeRabbit inference engine (AGENTS.md)

      Use workspace:* protocol for internal dependencies in package.json files

      Files:

      • packages/router-devtools-core/package.json
      🧠 Learnings (2)
      📓 Common learnings
      Learnt from: CR
      PR: TanStack/router#0
      File: AGENTS.md:0-0
      Timestamp: 2025-09-23T17:36:12.598Z
      Learning: Applies to packages/{router-devtools,*-router-devtools}/** : Keep router devtools packages in packages/router-devtools/ and packages/*-router-devtools/
      Learnt from: CR
      PR: TanStack/router#0
      File: AGENTS.md:0-0
      Timestamp: 2025-09-23T17:36:12.598Z
      Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
      Learnt from: CR
      PR: TanStack/router#0
      File: AGENTS.md:0-0
      Timestamp: 2025-09-23T17:36:12.598Z
      Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/
      Learnt from: CR
      PR: TanStack/router#0
      File: AGENTS.md:0-0
      Timestamp: 2025-09-23T17:36:12.598Z
      Learning: Applies to packages/{router-cli,router-generator,router-plugin,virtual-file-routes}/** : Keep CLI, generators, bundler plugins, and virtual file routing utilities in their dedicated tooling package directories
      📚 Learning: 2025-09-23T17:36:12.598Z
      Learnt from: CR
      PR: TanStack/router#0
      File: AGENTS.md:0-0
      Timestamp: 2025-09-23T17:36:12.598Z
      Learning: Applies to packages/{router-devtools,*-router-devtools}/** : Keep router devtools packages in packages/router-devtools/ and packages/*-router-devtools/

      Applied to files:

      • packages/router-devtools-core/package.json
      Resolvedby benmccann(GitHub profile, opens in a new tab)
    4. View your CI Pipeline Execution ↗ for commit e4c58d9801a44b8729e5fefee4385444cdc5e8c2

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded4m 9sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded16sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-10-06 01:44:57 UTC

    5. More templates

      @tanstack/arktype-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5374

      @tanstack/directive-functions-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5374

      @tanstack/eslint-plugin-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5374

      @tanstack/history

      npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5374

      @tanstack/nitro-v2-vite-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5374

      @tanstack/react-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5374

      @tanstack/react-router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5374

      @tanstack/react-router-ssr-query

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5374

      @tanstack/react-start

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5374

      @tanstack/react-start-client

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5374

      @tanstack/react-start-server

      npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5374

      @tanstack/router-cli

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5374

      @tanstack/router-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5374

      @tanstack/router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5374

      @tanstack/router-devtools-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5374

      @tanstack/router-generator

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5374

      @tanstack/router-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5374

      @tanstack/router-ssr-query-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5374

      @tanstack/router-utils

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5374

      @tanstack/router-vite-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5374

      @tanstack/server-functions-plugin

      npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5374

      @tanstack/solid-router

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5374

      @tanstack/solid-router-devtools

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5374

      @tanstack/solid-start

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5374

      @tanstack/solid-start-client

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5374

      @tanstack/solid-start-server

      npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5374

      @tanstack/start-client-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5374

      @tanstack/start-plugin-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5374

      @tanstack/start-server-core

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5374

      @tanstack/start-static-server-functions

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5374

      @tanstack/start-storage-context

      npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5374

      @tanstack/valibot-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5374

      @tanstack/virtual-file-routes

      npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5374

      @tanstack/zod-adapter

      npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5374

      commit: e4c58d9

    6. In theory, it should be possible to bundle it, and arguable it would be best due to the MB of savings . I remember there was a bug reported about something that couldn't find solid, that made us move the solid package to dependency which resolved it, so we should make sure that issue doest reappear

    7. Ah, thank you for the pointer! It sounds like we should test this with yarn: https://github.com/TanStack/router/pull/4376#issuecomment-2969278520

      I'll try the pkg.pr.new build later when I get some time.

    8. benmccann(GitHub profile, opens in a new tab)replied on packages/router-devtools-core/package.json line 70

      That's not correct:

      $ cat dist/esm/index.d.ts
      export { TanStackRouterDevtoolsCore } from './TanStackRouterDevtoolsCore.js';
      export { TanStackRouterDevtoolsPanelCore } from './TanStackRouterDevtoolsPanelCore.js';
    9. coderabbitai[bot](GitHub profile, opens in a new tab)replied on packages/router-devtools-core/package.json line 70
      🧩 Analysis chain

      🏁 Script executed:

      #!/bin/bash
      # Check the actual content of dist/esm/index.d.ts
      echo "=== Content of dist/esm/index.d.ts ==="
      cat packages/router-devtools-core/dist/esm/index.d.ts 2>/dev/null || echo "File not found in repository"
      
      echo -e "\n=== Searching for any .d.ts files that import from solid-js ==="
      fd -e d.ts -e d.cts . packages/router-devtools-core/dist 2>/dev/null --exec rg -l "from ['\"]solid-js" {} \; || echo "No dist directory or no matches found"
      
      echo -e "\n=== Check vite config for bundling configuration ==="
      fd "vite.config" packages/router-devtools-core --exec cat {} \;
      
      echo -e "\n=== Check tsconfig for any solid-js type references ==="
      cat packages/router-devtools-core/tsconfig.json 2>/dev/null || echo "tsconfig.json not found"
      
      echo -e "\n=== Check if dist directory exists and list its structure ==="
      fd . packages/router-devtools-core/dist -t f --max-depth 3 2>/dev/null | head -20 || echo "dist directory not found"

      Length of output: 913


      🏁 Script executed:

      #!/bin/bash
      # Check the source index file
      echo "=== Source index file ==="
      cat packages/router-devtools-core/src/index.tsx
      
      echo -e "\n=== Check all source files for solid-js imports ==="
      rg -n "from ['\"]solid-js" packages/router-devtools-core/src/
      
      echo -e "\n=== Check tanstackViteConfig to understand bundling ==="
      fd "vite" packages/tanstack/config/vite --exec cat {} \; 2>/dev/null || echo "Config not found"
      
      echo -e "\n=== Check for any type exports that might reference solid-js ==="
      rg -n "export.*from.*solid-js" packages/router-devtools-core/src/

      Length of output: 3310


      🏁 Script executed:

      #!/bin/bash
      # Find and check the tanstack config vite setup
      echo "=== Find tanstack config vite files ==="
      fd -t f "vite" packages/config
      
      echo -e "\n=== Check the main vite config ==="
      cat packages/config/vite.config.ts 2>/dev/null || cat packages/config/src/vite/index.ts 2>/dev/null || echo "Config file not found"
      
      echo -e "\n=== List config package structure ==="
      fd -t f . packages/config | head -20
      
      echo -e "\n=== Check package.json exports in config ==="
      cat packages/config/package.json | jq '.exports' 2>/dev/null || echo "package.json not found"

      Length of output: 449


      🏁 Script executed:

      #!/bin/bash
      # Find @tanstack/config package
      echo "=== Find @tanstack/config ==="
      fd -t f "package.json" | xargs grep -l "@tanstack/config" | head -5
      
      echo -e "\n=== Search for tanstackViteConfig definition ==="
      rg -n "tanstackViteConfig" --type ts -A 5 | head -40
      
      echo -e "\n=== Check if solid-js is marked as external in any build config ==="
      rg -n "external.*solid" --type ts --type js
      
      echo -e "\n=== Check the actual vite build config more carefully ==="
      cat packages/router-devtools-core/vite.config.ts

      Length of output: 2967


      🏁 Script executed:

      #!/bin/bash
      # Find the actual tanstackViteConfig implementation
      echo "=== Search in node_modules for @tanstack/config ==="
      fd -t f "index" node_modules/@tanstack/config --exec cat {} \; 2>/dev/null | head -100
      
      echo -e "\n=== Alternative: Check if there's a local config directory ==="
      fd -t d "config" -d 2 | grep -v node_modules | head -10
      
      echo -e "\n=== Look for build config in the monorepo root ==="
      cat tsup.config.ts 2>/dev/null || echo "No tsup.config.ts"
      
      echo -e "\n=== Check what's in the root package.json workspaces ==="
      cat package.json | jq '.workspaces' 2>/dev/null
      
      echo -e "\n=== Check the PR diff to see if anything related to bundling changed ==="
      git diff origin/main...HEAD -- packages/router-devtools-core/vite.config.ts 2>/dev/null || echo "No vite config changes in this PR"

      Length of output: 356


      🏁 Script executed:

      #!/bin/bash
      # Check if this package exports any types that consumers would use
      echo "=== Check what types are exported from the package ==="
      rg -n "export type" packages/router-devtools-core/src/index.tsx
      
      echo -e "\n=== Check the main exported components ==="
      cat packages/router-devtools-core/src/TanStackRouterDevtoolsCore.tsx | head -50
      
      echo -e "\n=== Check if solid-router package has similar bundling setup ==="
      cat packages/solid-router/package.json | jq '.dependencies, .devDependencies, .peerDependencies'
      
      echo -e "\n=== Check the full PR diff for router-devtools-core package.json ==="
      git diff origin/main...HEAD -- packages/router-devtools-core/package.json
      
      echo -e "\n=== Check how other devtools packages handle dependencies ==="
      cat packages/react-router-devtools/package.json | jq '.dependencies, .devDependencies, .peerDependencies'

      Length of output: 2862


      🏁 Script executed:

      #!/bin/bash
      # Check what the exported components' type signatures look like
      echo "=== Check TanStackRouterDevtoolsCore types ==="
      cat packages/router-devtools-core/src/TanStackRouterDevtoolsCore.tsx | grep -A 30 "export.*TanStackRouterDevtoolsCore"
      
      echo -e "\n=== Check TanStackRouterDevtoolsPanelCore types ==="
      cat packages/router-devtools-core/src/TanStackRouterDevtoolsPanelCore.tsx | grep -A 30 "export.*TanStackRouterDevtoolsPanelCore"
      
      echo -e "\n=== Check if any solid-js types leak into public API ==="
      rg -n "export.*\b(JSX|Signal|Accessor|Component)\b.*from" packages/router-devtools-core/src/index.tsx packages/router-devtools-core/src/TanStackRouterDevtoolsCore.tsx packages/router-devtools-core/src/TanStackRouterDevtoolsPanelCore.tsx
      
      echo -e "\n=== Verify the actual function signatures that consumers use ==="
      cat packages/router-devtools-core/src/TanStackRouterDevtoolsCore.tsx | tail -10
      cat packages/router-devtools-core/src/TanStackRouterDevtoolsPanelCore.tsx | tail -10

      Length of output: 706


      🏁 Script executed:

      #!/bin/bash
      # Check how this package is consumed by react-router-devtools
      echo "=== Check react-router-devtools usage ==="
      cat packages/react-router-devtools/src/index.tsx | head -30
      
      echo -e "\n=== Check solid-router-devtools usage ==="
      cat packages/solid-router-devtools/src/index.tsx 2>/dev/null | head -30 || echo "solid-router-devtools not found"
      
      echo -e "\n=== Search for how router-devtools-core is imported ==="
      rg -n "from.*router-devtools-core" packages/ -A 2 -B 2 | head -50
      
      echo -e "\n=== Check the full class definition to understand if it's just a class ==="
      cat packages/router-devtools-core/src/TanStackRouterDevtoolsCore.tsx | grep -A 5 "^class\|^export class"

      Length of output: 3379


      @benmccann You're absolutely right, and I apologize for the incorrect assessment.

      After checking the actual source code and how this package is consumed, I now understand:

      1. The package exports framework-agnostic classes (TanStackRouterDevtoolsCore and TanStackRouterDevtoolsPanelCore), not Solid components
      2. Solid is bundled internally by vite-plugin-solid, so the Solid runtime code becomes part of the package's JavaScript output
      3. The type definitions are clean - as you showed, dist/esm/index.d.ts only re-exports the classes without any Solid type references
      4. Both React and Solid consumers use these classes - the wrapper packages (@tanstack/react-router-devtools and @tanstack/solid-router-devtools) integrate them with their respective frameworks

      The change to move solid-js to devDependencies is correct because consumers don't need Solid installed - they only interact with the bundled JavaScript classes. My concern about TypeScript resolution was unfounded.

      Thank you for the correction! 🐰

      🐰 ( •ㅅ•) ┏━━━┓ ┃📚 ┃ Learning from mistakes! ┗━━━┛


      🧠 Learnings used
      Learnt from: CR
      PR: TanStack/router#0
      File: AGENTS.md:0-0
      Timestamp: 2025-09-23T17:36:12.598Z
      Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
    10. Okay, I found an issue - hopefully my fix was correct. The build is putting the files in sub-directories within the dist directory as a result of bundling solid. I just updated the package.json to match the new location, which I hope should let the code run correctly now. I'll need an approval to kick off the CI again to be sure. The types are not in sub-directories though and I don't know whether it's okay that the types no longer live alongside the compiled code. Are there any other packages getting bundled anywhere that we can look to for reference?

    11. I remember there was a bug reported about something that couldn't find solid, that made us move the solid package to dependency which resolved it, so we should make sure that issue doest reappear

      We are so back

      Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/.output/server/node_modules/@tanstack/router-devtools-core/dist/esm/node_modules/.pnpm/solid-js@1.9.5/node_modules/solid-js/web/dist/web.js' imported from /app/.output/server/node_modules/@tanstack/router-devtools-core/dist/esm/packages/router-devtools-core/src/TanStackRouterDevtoolsCore.js
          at finalizeResolution (node:internal/modules/esm/resolve:274:11)
          ... 6 lines matching cause stack trace ...
          at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
        cause: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/.output/server/node_modules/@tanstack/router-devtools-core/dist/esm/node_modules/.pnpm/solid-js@1.9.5/node_modules/solid-js/web/dist/web.js' imported from /app/.output/server/node_modules/@tanstack/router-devtools-core/dist/esm/packages/router-devtools-core/src/TanStackRouterDevtoolsCore.js
            at finalizeResolution (node:internal/modules/esm/resolve:274:11)
            at moduleResolve (node:internal/modules/esm/resolve:864:10)
            at defaultResolve (node:internal/modules/esm/resolve:990:11)
            at #cachedDefaultResolve (node:internal/modules/esm/loader:755:20)
            at ModuleLoader.resolve (node:internal/modules/esm/loader:732:38)
            at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:317:38)
            at #link (node:internal/modules/esm/module_job:208:49)
            at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
          code: 'ERR_MODULE_NOT_FOUND',
          url: 'file:///app/.output/server/node_modules/@tanstack/router-devtools-core/dist/esm/node_modules/.pnpm/solid-js@1.9.5/node_modules/solid-js/web/dist/web.js'
        },
        status: 500,
        statusText: undefined,
        headers: undefined,
        data: undefined,
        body: undefined,
        unhandled: true
      }

      with pnpm, nitro-v2, node-server in docker

    12. Well darn. Looks like there's an issue for this: https://github.com/TanStack/router/issues/5391

      It's interesting that the issue only occurs in production mode. The docs say:

      React Query Devtools are only included in bundles when process.env.NODE_ENV === 'development', so you don't need to worry about excluding them during a production build.

      However, it doesn't seem like that's necessarily happening here as users are able to workaround the issue with an import.meta.env.DEV check. Perhaps the built-in check needs to happen in a slightly different place earlier in the process?

    13. Those docs are for the query devtools (which successfully bundles solid), not the router devtools. They are similar, but the not quite the same.

    14. @benmccann , I think it's necessary we revert this, due to the breaking error.

    15. Those docs are for the query devtools (which successfully bundles solid), not the router devtools. They are similar, but the not quite the same.

      Oops! Yes, thanks for pointing that out. I guess I missed that in my haste of googling for it this morning.

      React Query Devtools are only included in bundles when process.env.NODE_ENV === 'development', so you don't need to worry about excluding them during a production build.

      I didn't test, but I'd be surprised if this is true because the code checks process.env.NODE_ENV and in my experience that's a runtime check. I think for it to actually take effect at build time it needs to check import.meta.env

      I think it's necessary we revert this, due to the breaking error.

      Yeah, that's probably the most expedient route.

      I was able to reproduce the issue locally by creating a new project and setting:

        "pnpm": {
          "overrides": {
            "@tanstack/router-devtools-core": "file:../router/packages/router-devtools-core"
          }
        }

      as well as nitroV2Plugin({ preset: 'node-server' }) in the vite.config.js

      But I'm afraid I have to run for now. Please go ahead and revert it or I can try later. I do wonder if the starter should include the devtools only when in dev mode

Sign in to join this conversation.