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/internal-declarations-import-specifiers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/vite-config': patch
---

Keep import specifiers as written in the declarations that `internalDeclarations` emits. They were still rewritten from tsconfig `paths` into relative paths, unlike the `dist/esm` and `dist/cjs` declarations.
2 changes: 1 addition & 1 deletion integrations/internal-declarations/snap/cjs/extra.cjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions integrations/internal-declarations/snap/cjs/extra.d.cts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { Match } from './index.cjs';
export type { MatchId } from './self.cjs';
export declare function matchId(match: Match): string;
2 changes: 2 additions & 0 deletions integrations/internal-declarations/snap/cjs/self.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Match } from '@tanstack/integration-internal-declarations';
export type MatchId = Match['id'];
1 change: 1 addition & 0 deletions integrations/internal-declarations/snap/esm/extra.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { Match } from './index.js';
export type { MatchId } from './self.js';
export declare function matchId(match: Match): string;
2 changes: 1 addition & 1 deletion integrations/internal-declarations/snap/esm/extra.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions integrations/internal-declarations/snap/esm/self.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Match } from '@tanstack/integration-internal-declarations';
export type MatchId = Match['id'];
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Match } from './index.js';
export type { MatchId } from './self.js';
export declare function matchId(match: Match): string;
/** @internal */
export declare const extraInternal = "extra";
2 changes: 2 additions & 0 deletions integrations/internal-declarations/snap/internal/self.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Match } from '@tanstack/integration-internal-declarations';
export type MatchId = Match['id'];
2 changes: 2 additions & 0 deletions integrations/internal-declarations/src/extra.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Match } from './index'

export type { MatchId } from './self'

export function matchId(match: Match): string {
return match.id
}
Expand Down
6 changes: 6 additions & 0 deletions integrations/internal-declarations/src/self.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// The package's own name is mapped to `./src/index.ts` through the tsconfig
// `paths` (without a `baseUrl`). Every declaration set must keep the package
// specifier, because `src` is not published.
import type { Match } from '@tanstack/integration-internal-declarations'

export type MatchId = Match['id']
11 changes: 11 additions & 0 deletions integrations/internal-declarations/tests/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('check internal declarations build output', () => {
'extra.d.ts',
'index.d.ts',
'nested/paths.d.ts',
'self.d.ts',
])
expect(internal['index.d.ts']).toContain('_pending: Map<string, Match>;')
expect(internal['index.d.ts']).toContain('_strictParams')
Expand All @@ -83,6 +84,16 @@ describe('check internal declarations build output', () => {
}
})

it('should keep tsconfig path specifiers in every declaration set', () => {
for (const dir of ['esm', 'cjs', 'internal']) {
const declarations = readDeclarations(`${distDir}/${dir}`)
const file = dir === 'cjs' ? 'self.d.cts' : 'self.d.ts'
expect(declarations[file], dir).toContain(
"from '@tanstack/integration-internal-declarations'",
)
}
})

it('should not change the other output when the option is off', async () => {
const outDir = await buildVariant({ internalDeclarations: false })

Expand Down
7 changes: 6 additions & 1 deletion integrations/internal-declarations/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
"noUnusedParameters": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true
"skipLibCheck": true,

/* Paths without a baseUrl */
"paths": {
"@tanstack/integration-internal-declarations": ["./src/index.ts"]
}
},
"include": ["src", "tests", "vite.config.ts"]
}
1 change: 1 addition & 0 deletions packages/vite-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
include: options.srcDir,
exclude: options.exclude,
tsconfigPath: options.tsconfigPath,
pathsToAliases: false,
compilerOptions: {
module: 99, // ESNext
declarationMap: false,
Expand Down
Loading