Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/router-plugin-remove-splitter-internals.md
Original file line number Diff line number Diff line change
@@ -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`.
7 changes: 0 additions & 7 deletions packages/router-plugin/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -71,12 +70,6 @@ export type CodeSplittingOptions = {
* @default true
*/
addHmr?: boolean

/**
* Internal compiler plugins used by framework integrations.
* @internal
*/
compilerPlugins?: Array<CodeSplitCompilerPlugin>
}

export type HmrStyle = 'vite' | 'webpack'
Expand Down
15 changes: 6 additions & 9 deletions packages/router-plugin/src/core/router-code-splitter-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
8 changes: 0 additions & 8 deletions packages/router-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand Down
40 changes: 1 addition & 39 deletions packages/router-plugin/tests/utils.test.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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()
})
})
Loading