@tanstack/vite-config 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vite-config",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Shared Vite build config used by TanStack projects.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -39,12 +39,11 @@
39
39
  "vite-tsconfig-paths": "^5.1.4"
40
40
  },
41
41
  "devDependencies": {
42
- "eslint": "^9.21.0",
43
- "vite": "^6.2.0"
42
+ "vite": "^6.3.6"
44
43
  },
45
44
  "scripts": {
46
45
  "test:types": "tsc",
47
- "test:eslint": "eslint ./src",
46
+ "test:eslint": "eslint --concurrency=auto ./src",
48
47
  "test:build": "publint --strict"
49
48
  }
50
49
  }
package/src/index.d.ts CHANGED
@@ -15,6 +15,8 @@ export type Options = {
15
15
  tsconfigPath?: string
16
16
  /** Additional dependencies to externalize if not detected by `vite-plugin-externalize-deps` */
17
17
  externalDeps?: Array<string | RegExp>
18
+ /** Hook called prior to writing each declaration file; allows to transform the content */
19
+ beforeWriteDeclarationFile?: (filePath: string, content: string) => string
18
20
  }
19
21
 
20
22
  /** https://tanstack.com/config/latest/docs/vite */
package/src/index.js CHANGED
@@ -50,10 +50,14 @@ export const tanstackViteConfig = (options) => {
50
50
  module: 99, // ESNext
51
51
  declarationMap: false,
52
52
  },
53
- beforeWriteFile: (filePath, content) => ({
54
- filePath,
55
- content: ensureImportFileExtension({ content, extension: 'js' }),
56
- }),
53
+ beforeWriteFile: (filePath, content) => {
54
+ content =
55
+ options.beforeWriteDeclarationFile?.(filePath, content) || content
56
+ return {
57
+ filePath,
58
+ content: ensureImportFileExtension({ content, extension: 'js' }),
59
+ }
60
+ },
57
61
  afterDiagnostic: (diagnostics) => {
58
62
  if (diagnostics.length > 0) {
59
63
  console.error('Please fix the above type errors')
@@ -72,10 +76,18 @@ export const tanstackViteConfig = (options) => {
72
76
  module: 1, // CommonJS
73
77
  declarationMap: false,
74
78
  },
75
- beforeWriteFile: (filePath, content) => ({
76
- filePath: filePath.replace('.d.ts', '.d.cts'),
77
- content: ensureImportFileExtension({ content, extension: 'cjs' }),
78
- }),
79
+ beforeWriteFile: (filePath, content) => {
80
+ content =
81
+ options.beforeWriteDeclarationFile?.(filePath, content) ||
82
+ content
83
+ return {
84
+ filePath: filePath.replace('.d.ts', '.d.cts'),
85
+ content: ensureImportFileExtension({
86
+ content,
87
+ extension: 'cjs',
88
+ }),
89
+ }
90
+ },
79
91
  afterDiagnostic: (diagnostics) => {
80
92
  if (diagnostics.length > 0) {
81
93
  console.error('Please fix the above type errors')