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

Keep import specifiers in emitted declarations as written. Since 0.6.0, tsconfig `paths` were rewritten into relative paths even without a `baseUrl`, which pointed published declarations at source files that are not published.
2 changes: 2 additions & 0 deletions integrations/vanilla/snap/cjs/paths.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { optionalChaining } from '@tanstack/integration-vanilla';
export type OptionalChaining = typeof optionalChaining;
2 changes: 2 additions & 0 deletions integrations/vanilla/snap/esm/paths.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { optionalChaining } from '@tanstack/integration-vanilla';
export type OptionalChaining = typeof optionalChaining;
6 changes: 6 additions & 0 deletions integrations/vanilla/src/paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// `@tanstack/integration-vanilla` is mapped to `./src/index.ts` through the
// tsconfig `paths` (without a `baseUrl`). The emitted declaration must keep
// the package specifier, because `src` is not published.
import type { optionalChaining } from '@tanstack/integration-vanilla'

export type OptionalChaining = typeof optionalChaining
2 changes: 1 addition & 1 deletion integrations/vanilla/tests/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const rootDir = resolve(__dirname, '..')
const esmExtensions = ['.js', '.js.map', '.d.ts']
const cjsExtensions = ['.cjs', '.cjs.map', '.d.cts']

const files = ['index', 'utils']
const files = ['index', 'utils', 'paths']

describe('check Vanilla build output', () => {
it('should output the same file structure', () => {
Expand Down
7 changes: 6 additions & 1 deletion integrations/vanilla/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
"noUnusedParameters": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true
"skipLibCheck": true,

/* Paths without a baseUrl */
"paths": {
"@tanstack/integration-vanilla": ["./src/index.ts"]
}
},
"include": ["src", "tests"]
}
5 changes: 5 additions & 0 deletions packages/vite-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
include: options.srcDir,
exclude: options.exclude,
tsconfigPath: options.tsconfigPath,
// Keep the import specifiers as written. Rewriting tsconfig `paths`
// into relative paths points published declarations at unpublished
// source files.
pathsToAliases: false,
compilerOptions: {
module: 99, // ESNext
declarationMap: false,
Expand All @@ -82,6 +86,7 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
include: options.srcDir,
exclude: options.exclude,
tsconfigPath: options.tsconfigPath,
pathsToAliases: false,
compilerOptions: {
module: 100, // CommonJS - Node16
declarationMap: false,
Expand Down
Loading