* fix: shared virtual module for code-split routes
When a route file has module-level bindings (variables, functions, classes) referenced by **both** split and non-split route properties, the bindings are duplicated — initialized independently in the reference file and in each virtual split file. This breaks singletons, causes double side effects, and wastes bundle size.
```tsx
const collection = { name: 'todos', preload: async () => {} }
export const Route = createFileRoute('/todos')({
loader: async () => {
await collection.preload()
}, // stays in reference
component: () => <div>{collection.name}</div>, // split to virtual
})
```
In this example, `collection` is initialized in **both** the reference file (because `loader` references it) and the `?tsr-split=component` virtual file (because the component references it). Two separate instances exist at runtime.
To solve this issue, this PR introduces a third virtual module `route.tsx?tsr-shared=1` that contains shared bindings. Both the reference and virtual files import from it.
When `sharedBindings` is empty (the common case — component-only helpers, loader-only code), no shared module exists and the system works exactly as today.
The reference transform runs first and will emit a static import of `?tsr-shared=1` **only when needed**. Since split chunks are only discovered via the reference file's emitted `import('...?tsr-split=...')`, the bundler will always process/evaluate the reference module first. Result: the shared module is evaluated once and then reused by any later-loaded split chunk.
Currently, when using `automaticCodeSplitting`, as part of compiling the "reference" route, we add a component (named `TSRDummyComponent`) to aid with the HMR trickery.
In removing this component from the production bundle, it impacts the visitor by reducing the initial js bundle that wires the route-tree.
* chore(router-plugin): add `babel-dead-code-elimination`
* feat(router-plugin): initial implementation
* chore(router-plugin): better test scripts
* test(router-plugin): check it with the new functions
* fix(start-vite-plugin): add vite
* feat(router-plugin): bump unplugin
* fix(router-plugin): making sure it works
* chore(router-plugin): cleanup
* chore(router-plugin): delete "eliminateUnreferencedIdentifiers.ts"
* fix(router-plugin): esm problems
* chore(router-plugin): restore minification for production
* chore(start-vite-plugin): undo the vite
* Bump vite
* pnpm dedupe
* test(router-plugin): bit of renaming here
---------
Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com>
* fix(router-plugin): package.json fields causing issues during imports
* fix: make the inlineConfig optional
* chore: trigger ci
* chore: try ci again
* chore: add a better readme
* test: just something to trigger CI honestly
* feat: scaffold the new `@tanstack/router-plugin` package
* chore: include in the overrides
* feat: more scaffolding
* test: just a random test that'll be removed later
* build: hopefully fixes build
* style: import order
* chore: peer deps for router-plugin
* feat: setup the generator
* refactor: combined needs to be done for the individual plugin
* chore: copy all the babel stuff over from router-vite-plugin
* feat: copy the babel plugin setup from router-plugin
* feat: enfore pre
* refactor: turn the error into its own custom one
* style: eslint
* style: more eslint
* chore: update the readme