Skip to content

Commit 2d9633c

Browse files
committed
refactor(router-core): share the formatter through an internal entry
Keeps the root entry point unchanged, per the scope note on TanStack#7779, by adding a `./internal` subpath that `start-client-core` imports instead. Also drops a pollution assertion that could not fail: the formatter builds a string and never keys an object by the path, so the rendered output is what actually covers the `__proto__` case.
1 parent d3af6f5 commit 2d9633c

6 files changed

Lines changed: 19 additions & 10 deletions

File tree

‎packages/router-core/package.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@
4848
"default": "./dist/cjs/index.cjs"
4949
}
5050
},
51+
"./internal": {
52+
"import": {
53+
"types": "./dist/esm/internal.d.ts",
54+
"default": "./dist/esm/internal.js"
55+
},
56+
"require": {
57+
"types": "./dist/cjs/internal.d.cts",
58+
"default": "./dist/cjs/internal.cjs"
59+
}
60+
},
5161
"./ssr/server": {
5262
"import": {
5363
"types": "./dist/esm/ssr/server.d.ts",

‎packages/router-core/src/index.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,6 @@ export type {
390390
ResolveValidatorOutput,
391391
} from './validators'
392392

393-
// Exported so `start-client-core` can share one formatter. Not part of the
394-
// documented public API.
395-
export { formatStandardSchemaIssues } from './standardSchemaIssues'
396-
397393
export type {
398394
UseRouteContextBaseOptions,
399395
UseRouteContextOptions,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Shared internals. Not part of the documented public API and not covered by
3+
* semver: this entry exists so sibling packages such as `start-client-core`
4+
* can reuse helpers without widening the root `@tanstack/router-core` surface.
5+
*/
6+
export { formatStandardSchemaIssues } from './standardSchemaIssues'

‎packages/router-core/tests/standardSchemaIssues.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ describe('formatStandardSchemaIssues', () => {
6969
{ message: 'x', path: ['__proto__', 'constructor'] },
7070
]),
7171
).toBe('__proto__.constructor: x')
72-
expect(({} as Record<string, unknown>).polluted).toBeUndefined()
7372
})
7473

7574
it('renders a symbol key', () => {

‎packages/router-core/vite.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default mergeConfig(
4242
tanstackViteConfig({
4343
entry: [
4444
'./src/index.ts',
45+
'./src/internal.ts',
4546
'./src/ssr/client.ts',
4647
'./src/ssr/server.ts',
4748
'./src/scroll-restoration-script/client.ts',

‎packages/start-client-core/src/createServerFn.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { mergeHeaders } from '@tanstack/router-core/ssr/client'
22

3-
import {
4-
formatStandardSchemaIssues,
5-
isRedirect,
6-
parseRedirect,
7-
} from '@tanstack/router-core'
3+
import { isRedirect, parseRedirect } from '@tanstack/router-core'
4+
import { formatStandardSchemaIssues } from '@tanstack/router-core/internal'
85
import { TSS_SERVER_FUNCTION_FACTORY } from './constants'
96
import { getStartOptions } from './getStartOptions'
107
import { getStartContextServerOnly } from './getStartContextServerOnly'

0 commit comments

Comments
 (0)