fix(router-devtools-core): bundle solid for smaller package #5406
main fromrefs/pull/5406/head·merged by birkskyum(GitHub profile, opens in a new tab) Trying https://github.com/TanStack/router/pull/5374 again
However, this time I followed the manual testing instructions detailed in https://github.com/TanStack/router/pull/5374#issuecomment-3378827140, so I'm fairly confident this version shouldn't break anything
Summary by CodeRabbit#
Chores
- Adjusted development dependencies to streamline tooling; no runtime impact.
Build
- Updated build configuration to produce a more consistent output and simplify packaging.
- Improved stability of the build by refining how bundles are generated.
- No changes to the public API or end-user functionality.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-devtools-core
Walkthrough#
The PR moves solid-js from dependencies to devDependencies in packages/router-devtools-core/package.json and refactors packages/router-devtools-core/vite.config.ts to assign the merged config to a constant, set rollup output options (manualChunks and preserveModules to false), and export the constant as the default.
Changes#
Cohort / File(s) Summary of Changes Dependency adjustments packages/router-devtools-core/package.jsonMoved "solid-js" from dependencies to devDependencies; no changes to peerDependencies. Vite config refactor and rollup options packages/router-devtools-core/vite.config.tsIntroduced const merged = mergeConfig(...); setmerged.build.rollupOptions.output.manualChunks = falseandpreserveModules = false; changed default export from inlinemergeConfig(...)call to exportingmerged.Sequence Diagram(s)#
(no diagram)
Estimated code review effort#
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs#
- TanStack/router#5403 — Also alters packages/router-devtools-core dependencies around "solid-js" and adjusts exports, directly overlapping with this change.
- TanStack/router#5374 — Moves "solid-js" out of runtime deps and tweaks build/bundling for the same package, closely related.
Poem#
A hop, a bop, I tweak my deps with glee, Rollup rolls simpler, chunks set free. Dev-only carrots in my toolkit stash, Exports tidied—no extra flash. Thump-thump! Config merged, ears high— Ship the build, then off I fly. 🥕🐇
Pre-merge checks and finishing touches#
✅ Passed checks (3 passed)
Check name Status Explanation Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled. Title Check ✅ Passed The title “fix(router-devtools-core): bundle solid for smaller package” succinctly describes the main change of bundling Solid into the build to reduce the published package size, which aligns with the dependency and Vite configuration updates in the PR. Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped. ✨ 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.
Comment `@coderabbitai help` to get the list of available commands and usage tips.More templates
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-solid-start-example-bare
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-static
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5406@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5406@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5406@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5406@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5406@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5406@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5406@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5406@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5406@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5406@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5406@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5406@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5406@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5406@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5406@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5406@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5406@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5406@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5406@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5406@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5406@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5406@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5406@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5406@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5406@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5406@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5406@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5406@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5406@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5406@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5406@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5406@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5406@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5406commit:
ebe58cbActionable 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 e0c63d47b4d6891bb186c16ece27bd452a37406b and ebe58cb6b20a8b50b55215c7d4b102a84e8f057c.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
packages/router-devtools-core/package.json(1 hunks)packages/router-devtools-core/vite.config.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace:* protocol for internal dependencies in package.json files
Files:
packages/router-devtools-core/package.json
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/router-devtools-core/vite.config.ts
🧠 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/📚 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
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (2)
packages/router-devtools-core/vite.config.ts (1)
10-21: Refactoring approach is appropriate for bundling configuration.Extracting the merged configuration to a constant before export is a clean approach that allows you to modify the Rollup options. Setting
manualChunks = falseandpreserveModules = falseis correct for bundling solid-js into the package (as per the PR objectives).However, ensure that the property access is safe (see previous comment about type guards).
packages/router-devtools-core/package.json (1)
70-70: Re-run build with dependencies installed and confirm solid-js is bundled. Inpackages/router-devtools-core, runpnpm installthenpnpm run build, verifydistexists, confirm no externalsolid-jsimports (e.g.rg -n "from ['\"]solid-js['\"]" dist/), and check package size reduction.@@ -7,10 +7,13 @@77 plugins: [solid()] as UserConfig['plugins'],88 })9910-export default mergeConfig(10+const merged = mergeConfig(1111 config,1212 tanstackViteConfig({1313 entry: './src/index.tsx',1414 srcDir: './src',1515 }),1616 )17+18+merged.build.rollupOptions.output.manualChunks = false19+merged.build.rollupOptions.output.preserveModules = false⚠️ Potential issue | 🔴 Critical
Unsafe property access: add type guards or ensure structure exists.
Directly accessing
merged.build.rollupOptions.output.manualChunksandmerged.build.rollupOptions.output.preserveModuleswithout null checks or type guards is unsafe. Additionally, Rollup'soutputproperty can be an array or a single object, so this code will fail at runtime ifoutputis an array or if any intermediate property is undefined.Apply this diff to safely set the rollup options:
-merged.build.rollupOptions.output.manualChunks = false -merged.build.rollupOptions.output.preserveModules = false +// Ensure build, rollupOptions, and output are initialized +if (!merged.build) merged.build = {} +if (!merged.build.rollupOptions) merged.build.rollupOptions = {} +if (!merged.build.rollupOptions.output) { + merged.build.rollupOptions.output = {} +} + +// Only set if output is an object (not an array) +if (!Array.isArray(merged.build.rollupOptions.output)) { + merged.build.rollupOptions.output.manualChunks = false + merged.build.rollupOptions.output.preserveModules = false +}Alternatively, if you're confident that
tanstackViteConfigalways initializes these properties correctly, add a comment documenting this assumption and consider adding a TypeScript assertion to make the types explicit.📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Ensure build, rollupOptions, and output are initialized if (!merged.build) merged.build = {} if (!merged.build.rollupOptions) merged.build.rollupOptions = {} if (!merged.build.rollupOptions.output) { merged.build.rollupOptions.output = {} } // Only set if output is an object (not an array) if (!Array.isArray(merged.build.rollupOptions.output)) { merged.build.rollupOptions.output.manualChunks = false merged.build.rollupOptions.output.preserveModules = false }🤖 Prompt for AI Agents
In packages/router-devtools-core/vite.config.ts around lines 18-19, the code directly sets merged.build.rollupOptions.output.manualChunks and .preserveModules which is unsafe because build/rollupOptions/output may be undefined or output can be an array; update the code to first guard that merged.build and merged.build.rollupOptions exist, normalize output to a single object if it's an array (or iterate the array and set the fields on each output entry), and only then set manualChunks and preserveModules; alternatively, if you guarantee the structure, add a concise TypeScript non-null assertion or a comment documenting the invariant and use a type assertion to make the intent explicit.birkskyum(GitHub profile, opens in a new tab) approved these changes
Excellent, let's try it!
birkskyum(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
View your CI Pipeline Execution ↗ for commit ebe58cb6b20a8b50b55215c7d4b102a84e8f057c
nx affected --targets=test:eslint,test:unit,tes...nx run-many --target=build --exclude=examples/*...☁️ Nx Cloud last updated this comment at
2025-10-08 16:10:52UTC