diff --git a/.changeset/router-plugin-remove-splitter-internals.md b/.changeset/router-plugin-remove-splitter-internals.md new file mode 100644 index 00000000000..258345f710d --- /dev/null +++ b/.changeset/router-plugin-remove-splitter-internals.md @@ -0,0 +1,5 @@ +--- +'@tanstack/router-plugin': patch +--- + +Remove internal code-splitter APIs: the `codeSplittingOptions.compilerPlugins` option, and the root-entry exports `unpluginRouterCodeSplitterFactory`, `getObjectPropertyKeyName`, `CodeSplitCompilerPlugin`, `ReferenceRouteCompilerPlugin`, `ReferenceRouteCompilerPluginContext` and `VirtualRouteSplitNodeCompilerPluginContext`. 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() - }) -})