From 91fa43c0171ba4e6ad81268887eb56eff40ab654 Mon Sep 17 00:00:00 2001 From: Sheraff Date: Tue, 3 Nov 2026 15:40:12 +0100 Subject: [PATCH 1/2] refactor(router-plugin)!: remove `compilerPlugins` and splitter internals from the root entry Remove the experimental `codeSplittingOptions.compilerPlugins` hook and stop exporting the Babel splitter's internals from the package root: `unpluginRouterCodeSplitterFactory`, `getObjectPropertyKeyName`, `CodeSplitCompilerPlugin`, `ReferenceRouteCompilerPlugin`, `ReferenceRouteCompilerPluginContext` and `VirtualRouteSplitNodeCompilerPluginContext`. Split out of #8817. Co-Authored-By: Claude Opus 5.5 --- ...router-plugin-remove-splitter-internals.md | 6 +++ packages/router-plugin/src/core/config.ts | 7 ---- .../src/core/router-code-splitter-plugin.ts | 15 +++---- packages/router-plugin/src/index.ts | 8 ---- packages/router-plugin/tests/utils.test.ts | 40 +------------------ 5 files changed, 13 insertions(+), 63 deletions(-) create mode 100644 .changeset/router-plugin-remove-splitter-internals.md diff --git a/.changeset/router-plugin-remove-splitter-internals.md b/.changeset/router-plugin-remove-splitter-internals.md new file mode 100644 index 00000000000..a9bfd00b729 --- /dev/null +++ b/.changeset/router-plugin-remove-splitter-internals.md @@ -0,0 +1,6 @@ +--- +'@tanstack/router-plugin': minor +--- + +- **Removed:** `codeSplittingOptions.compilerPlugins` (the experimental Babel hook). +- **Removed from the root entry** (undocumented internals of the Babel splitter): `unpluginRouterCodeSplitterFactory`, `getObjectPropertyKeyName` and the types `CodeSplitCompilerPlugin`, `ReferenceRouteCompilerPlugin`, `ReferenceRouteCompilerPluginContext` and `VirtualRouteSplitNodeCompilerPluginContext`. Code splitting comes with the bundler entries (`@tanstack/router-plugin/vite`, `/rspack`, `/webpack`). diff --git a/packages/router-plugin/src/core/config.ts b/packages/router-plugin/src/core/config.ts index 8366f78e805..f3726b00823 100644 --- a/packages/router-plugin/src/core/config.ts +++ b/packages/router-plugin/src/core/config.ts @@ -9,7 +9,6 @@ import type { RouteIds, } from '@tanstack/router-core' import type { CodeSplitGroupings } from './constants' -import type { CodeSplitCompilerPlugin } from './code-splitter/plugins' export const splitGroupingsSchema = z .array( @@ -71,12 +70,6 @@ export type CodeSplittingOptions = { * @default true */ addHmr?: boolean - - /** - * Internal compiler plugins used by framework integrations. - * @internal - */ - compilerPlugins?: Array } export type HmrStyle = 'vite' | 'webpack' diff --git a/packages/router-plugin/src/core/router-code-splitter-plugin.ts b/packages/router-plugin/src/core/router-code-splitter-plugin.ts index 596bd6e0120..bb078040ebb 100644 --- a/packages/router-plugin/src/core/router-code-splitter-plugin.ts +++ b/packages/router-plugin/src/core/router-code-splitter-plugin.ts @@ -99,15 +99,12 @@ export function createRouterCodeSplitterPlugin( addHmr = (userConfig.codeSplittingOptions?.addHmr ?? true) && !isProduction hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite' - compilerPlugins = [ - ...(addHmr - ? (getFrameworkHmrCompilerPlugins({ - targetFramework: userConfig.target, - hmrStyle, - }) ?? []) - : []), - ...(userConfig.codeSplittingOptions?.compilerPlugins ?? []), - ] + compilerPlugins = addHmr + ? (getFrameworkHmrCompilerPlugins({ + targetFramework: userConfig.target, + hmrStyle, + }) ?? []) + : [] virtualRouteCompilerPlugins = compilerPlugins.filter( (plugin) => plugin.onVirtualRouteSplitNode, ) diff --git a/packages/router-plugin/src/index.ts b/packages/router-plugin/src/index.ts index 6a6ad158bb5..e775906783b 100644 --- a/packages/router-plugin/src/index.ts +++ b/packages/router-plugin/src/index.ts @@ -1,5 +1,4 @@ export { configSchema, getConfig } from './core/config' -export { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin' export { unpluginRouterGeneratorFactory } from './core/router-generator-plugin' export { createRouterPluginContext } from './core/router-plugin-context' export type { @@ -11,13 +10,6 @@ export type { HmrOptions, } from './core/config' export type { RouterPluginContext } from './core/router-plugin-context' -export { getObjectPropertyKeyName } from './core/utils' -export type { - CodeSplitCompilerPlugin, - ReferenceRouteCompilerPlugin, - ReferenceRouteCompilerPluginContext, - VirtualRouteSplitNodeCompilerPluginContext, -} from './core/code-splitter/plugins' export { tsrSplit, splitRouteIdentNodes, diff --git a/packages/router-plugin/tests/utils.test.ts b/packages/router-plugin/tests/utils.test.ts index 6812b59bc38..530880858ee 100644 --- a/packages/router-plugin/tests/utils.test.ts +++ b/packages/router-plugin/tests/utils.test.ts @@ -1,13 +1,12 @@ import * as babel from '@babel/core' -import * as t from '@babel/types' import { parseAst } from '@tanstack/router-utils' import { describe, expect, it } from 'vitest' import { - getObjectPropertyKeyName, getUniqueProgramIdentifier, normalizePath, routeFactoryCallCodeFilter, } from '../src/core/utils' +import type * as t from '@babel/types' import type { NodePath } from '@babel/core' function matchesRouteFactoryCallCodeFilter(code: string) { @@ -140,40 +139,3 @@ describe('routeFactoryCallCodeFilter', () => { ).toBe(true) }) }) - -describe('getObjectPropertyKeyName', () => { - it('returns identifier keys', () => { - const prop = t.objectProperty(t.identifier('component'), t.identifier('x')) - - expect(getObjectPropertyKeyName(prop)).toBe('component') - }) - - it('returns string literal keys', () => { - const prop = t.objectProperty( - t.stringLiteral('errorComponent'), - t.identifier('x'), - ) - - expect(getObjectPropertyKeyName(prop)).toBe('errorComponent') - }) - - it('returns undefined for computed identifier keys', () => { - const prop = t.objectProperty( - t.identifier('component'), - t.identifier('x'), - true, - ) - - expect(getObjectPropertyKeyName(prop)).toBeUndefined() - }) - - it('returns undefined for computed member expression keys', () => { - const prop = t.objectProperty( - t.memberExpression(t.identifier('foo'), t.identifier('bar')), - t.identifier('x'), - true, - ) - - expect(getObjectPropertyKeyName(prop)).toBeUndefined() - }) -}) From ab3605544a1572b91686a604bf15053a36e086f9 Mon Sep 17 00:00:00 2001 From: Sheraff Date: Tue, 3 Nov 2026 17:13:14 +0100 Subject: [PATCH 2/2] chore: make the changeset a patch The removed option and exports were internal, not public API. Co-Authored-By: Claude Opus 5.5 --- .changeset/router-plugin-remove-splitter-internals.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.changeset/router-plugin-remove-splitter-internals.md b/.changeset/router-plugin-remove-splitter-internals.md index a9bfd00b729..258345f710d 100644 --- a/.changeset/router-plugin-remove-splitter-internals.md +++ b/.changeset/router-plugin-remove-splitter-internals.md @@ -1,6 +1,5 @@ --- -'@tanstack/router-plugin': minor +'@tanstack/router-plugin': patch --- -- **Removed:** `codeSplittingOptions.compilerPlugins` (the experimental Babel hook). -- **Removed from the root entry** (undocumented internals of the Babel splitter): `unpluginRouterCodeSplitterFactory`, `getObjectPropertyKeyName` and the types `CodeSplitCompilerPlugin`, `ReferenceRouteCompilerPlugin`, `ReferenceRouteCompilerPluginContext` and `VirtualRouteSplitNodeCompilerPluginContext`. Code splitting comes with the bundler entries (`@tanstack/router-plugin/vite`, `/rspack`, `/webpack`). +Remove internal code-splitter APIs: the `codeSplittingOptions.compilerPlugins` option, and the root-entry exports `unpluginRouterCodeSplitterFactory`, `getObjectPropertyKeyName`, `CodeSplitCompilerPlugin`, `ReferenceRouteCompilerPlugin`, `ReferenceRouteCompilerPluginContext` and `VirtualRouteSplitNodeCompilerPluginContext`.