@tanstack/vite-config 0.5.1 → 0.6.0
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/dist/index.d.ts +0 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +17 -8
- package/package.json +4 -4
- package/src/index.ts +12 -4
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21,13 +21,13 @@ const tanstackViteConfig = (options) => {
|
|
|
21
21
|
}),
|
|
22
22
|
options.tsconfigPath ? tsconfigPaths({ projects: [options.tsconfigPath] }) : void 0,
|
|
23
23
|
dts({
|
|
24
|
-
|
|
24
|
+
outDirs: `${outDir}/esm`,
|
|
25
25
|
entryRoot: options.srcDir,
|
|
26
26
|
include: options.srcDir,
|
|
27
27
|
exclude: options.exclude,
|
|
28
28
|
tsconfigPath: options.tsconfigPath,
|
|
29
29
|
compilerOptions: {
|
|
30
|
-
module:
|
|
30
|
+
module: 99,
|
|
31
31
|
declarationMap: false
|
|
32
32
|
},
|
|
33
33
|
beforeWriteFile: (filePath, content) => {
|
|
@@ -48,13 +48,13 @@ const tanstackViteConfig = (options) => {
|
|
|
48
48
|
}
|
|
49
49
|
}),
|
|
50
50
|
cjs ? dts({
|
|
51
|
-
|
|
51
|
+
outDirs: `${outDir}/cjs`,
|
|
52
52
|
entryRoot: options.srcDir,
|
|
53
53
|
include: options.srcDir,
|
|
54
54
|
exclude: options.exclude,
|
|
55
55
|
tsconfigPath: options.tsconfigPath,
|
|
56
56
|
compilerOptions: {
|
|
57
|
-
module:
|
|
57
|
+
module: 100,
|
|
58
58
|
declarationMap: false
|
|
59
59
|
},
|
|
60
60
|
beforeWriteFile: (filePath, content) => {
|
|
@@ -87,7 +87,8 @@ const tanstackViteConfig = (options) => {
|
|
|
87
87
|
return "esm/[name].js";
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
-
rolldownOptions: { output: { preserveModules: true } }
|
|
90
|
+
rolldownOptions: { output: { preserveModules: true } },
|
|
91
|
+
rollupOptions: { output: { preserveModules: true } }
|
|
91
92
|
}
|
|
92
93
|
});
|
|
93
94
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// @ts-check\n\nimport { defineConfig } from 'vite'\nimport { externalizeDeps } from 'vite-plugin-externalize-deps'\nimport tsconfigPaths from 'vite-tsconfig-paths'\nimport dts from 'vite-plugin-dts'\nimport type { UserConfig } from 'vite'\nimport type { Options } from './types.js'\n\nexport type { Options }\n\nfunction ensureImportFileExtension({\n content,\n extension,\n}: {\n content: string\n extension: string\n}) {\n // replace e.g. `import { foo } from './foo'` with `import { foo } from './foo.js'`\n content = content.replace(\n /(im|ex)port\\s[\\w{}/*\\s,]+from\\s['\"](?:\\.\\.?\\/)+?[^.'\"]+(?=['\"];?)/gm,\n `$&.${extension}`,\n )\n\n // replace e.g. `import('./foo')` with `import('./foo.js')`\n content = content.replace(\n /import\\(['\"](?:\\.\\.?\\/)+?[^.'\"]+(?=['\"];?)/gm,\n `$&.${extension}`,\n )\n return content\n}\n\nexport const tanstackViteConfig = (options: Options): UserConfig => {\n const outDir = options.outDir ?? 'dist'\n const cjs = options.cjs ?? true\n\n return defineConfig({\n resolve: {\n tsconfigPaths: !options.tsconfigPath,\n },\n plugins: [\n externalizeDeps({\n include: options.externalDeps ?? [],\n except: options.bundledDeps ?? [],\n }),\n // Use vite-tsconfig-paths plugin only when a custom tsconfigPath is specified,\n // otherwise Vite 8's native resolve.tsconfigPaths handles it\n options.tsconfigPath\n ? tsconfigPaths({\n projects: [options.tsconfigPath],\n })\n : undefined,\n dts({\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// @ts-check\n\nimport { defineConfig } from 'vite'\nimport { externalizeDeps } from 'vite-plugin-externalize-deps'\nimport tsconfigPaths from 'vite-tsconfig-paths'\nimport dts from 'vite-plugin-dts'\nimport type { UserConfig } from 'vite'\nimport type { Options } from './types.js'\n\nexport type { Options }\n\nfunction ensureImportFileExtension({\n content,\n extension,\n}: {\n content: string\n extension: string\n}) {\n // replace e.g. `import { foo } from './foo'` with `import { foo } from './foo.js'`\n content = content.replace(\n /(im|ex)port\\s[\\w{}/*\\s,]+from\\s['\"](?:\\.\\.?\\/)+?[^.'\"]+(?=['\"];?)/gm,\n `$&.${extension}`,\n )\n\n // replace e.g. `import('./foo')` with `import('./foo.js')`\n content = content.replace(\n /import\\(['\"](?:\\.\\.?\\/)+?[^.'\"]+(?=['\"];?)/gm,\n `$&.${extension}`,\n )\n return content\n}\n\nexport const tanstackViteConfig = (options: Options): UserConfig => {\n const outDir = options.outDir ?? 'dist'\n const cjs = options.cjs ?? true\n\n return defineConfig({\n resolve: {\n tsconfigPaths: !options.tsconfigPath,\n },\n plugins: [\n externalizeDeps({\n include: options.externalDeps ?? [],\n except: options.bundledDeps ?? [],\n }),\n // Use vite-tsconfig-paths plugin only when a custom tsconfigPath is specified,\n // otherwise Vite 8's native resolve.tsconfigPaths handles it\n options.tsconfigPath\n ? tsconfigPaths({\n projects: [options.tsconfigPath],\n })\n : undefined,\n dts({\n outDirs: `${outDir}/esm`,\n entryRoot: options.srcDir,\n include: options.srcDir,\n exclude: options.exclude,\n tsconfigPath: options.tsconfigPath,\n compilerOptions: {\n module: 99, // ESNext\n declarationMap: false,\n },\n beforeWriteFile: (filePath, content) => {\n content =\n options.beforeWriteDeclarationFile?.(filePath, content) || content\n return {\n filePath,\n content: ensureImportFileExtension({ content, extension: 'js' }),\n }\n },\n afterDiagnostic: (diagnostics) => {\n if (diagnostics.length > 0) {\n console.error('Please fix the above type errors')\n process.exit(1)\n }\n },\n }),\n cjs\n ? dts({\n outDirs: `${outDir}/cjs`,\n entryRoot: options.srcDir,\n include: options.srcDir,\n exclude: options.exclude,\n tsconfigPath: options.tsconfigPath,\n compilerOptions: {\n module: 100, // CommonJS - Node16\n declarationMap: false,\n },\n beforeWriteFile: (filePath, content) => {\n content =\n options.beforeWriteDeclarationFile?.(filePath, content) ||\n content\n return {\n filePath: filePath.replace('.d.ts', '.d.cts'),\n content: ensureImportFileExtension({\n content,\n extension: 'cjs',\n }),\n }\n },\n afterDiagnostic: (diagnostics) => {\n if (diagnostics.length > 0) {\n console.error('Please fix the above type errors')\n process.exit(1)\n }\n },\n })\n : undefined,\n ],\n build: {\n outDir,\n minify: false,\n sourcemap: true,\n lib: {\n entry: options.entry,\n formats: cjs ? ['es', 'cjs'] : ['es'],\n fileName: (format) => {\n if (format === 'cjs') return 'cjs/[name].cjs'\n return 'esm/[name].js'\n },\n },\n // Set both so module preservation holds whether the consumer builds\n // with Vite 7 (Rollup → `rollupOptions`) or Vite 8 (Rolldown →\n // `rolldownOptions`).\n rolldownOptions: {\n output: {\n preserveModules: true,\n },\n },\n rollupOptions: {\n output: {\n preserveModules: true,\n },\n },\n },\n })\n}\n"],"mappings":";;;;;;AAWA,SAAS,0BAA0B,EACjC,SACA,aAIC;CAED,UAAU,QAAQ,QAChB,uEACA,MAAM,WACR;CAGA,UAAU,QAAQ,QAChB,gDACA,MAAM,WACR;CACA,OAAO;AACT;AAEA,MAAa,sBAAsB,YAAiC;CAClE,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,MAAM,QAAQ,OAAO;CAE3B,OAAO,aAAa;EAClB,SAAS,EACP,eAAe,CAAC,QAAQ,aAC1B;EACA,SAAS;GACP,gBAAgB;IACd,SAAS,QAAQ,gBAAgB,CAAC;IAClC,QAAQ,QAAQ,eAAe,CAAC;GAClC,CAAC;GAGD,QAAQ,eACJ,cAAc,EACZ,UAAU,CAAC,QAAQ,YAAY,EACjC,CAAC,IACD;GACJ,IAAI;IACF,SAAS,GAAG,OAAO;IACnB,WAAW,QAAQ;IACnB,SAAS,QAAQ;IACjB,SAAS,QAAQ;IACjB,cAAc,QAAQ;IACtB,iBAAiB;KACf,QAAQ;KACR,gBAAgB;IAClB;IACA,kBAAkB,UAAU,YAAY;KACtC,UACE,QAAQ,6BAA6B,UAAU,OAAO,KAAK;KAC7D,OAAO;MACL;MACA,SAAS,0BAA0B;OAAE;OAAS,WAAW;MAAK,CAAC;KACjE;IACF;IACA,kBAAkB,gBAAgB;KAChC,IAAI,YAAY,SAAS,GAAG;MAC1B,QAAQ,MAAM,kCAAkC;MAChD,QAAQ,KAAK,CAAC;KAChB;IACF;GACF,CAAC;GACD,MACI,IAAI;IACF,SAAS,GAAG,OAAO;IACnB,WAAW,QAAQ;IACnB,SAAS,QAAQ;IACjB,SAAS,QAAQ;IACjB,cAAc,QAAQ;IACtB,iBAAiB;KACf,QAAQ;KACR,gBAAgB;IAClB;IACA,kBAAkB,UAAU,YAAY;KACtC,UACE,QAAQ,6BAA6B,UAAU,OAAO,KACtD;KACF,OAAO;MACL,UAAU,SAAS,QAAQ,SAAS,QAAQ;MAC5C,SAAS,0BAA0B;OACjC;OACA,WAAW;MACb,CAAC;KACH;IACF;IACA,kBAAkB,gBAAgB;KAChC,IAAI,YAAY,SAAS,GAAG;MAC1B,QAAQ,MAAM,kCAAkC;MAChD,QAAQ,KAAK,CAAC;KAChB;IACF;GACF,CAAC,IACD;EACN;EACA,OAAO;GACL;GACA,QAAQ;GACR,WAAW;GACX,KAAK;IACH,OAAO,QAAQ;IACf,SAAS,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI;IACpC,WAAW,WAAW;KACpB,IAAI,WAAW,OAAO,OAAO;KAC7B,OAAO;IACT;GACF;GAIA,iBAAiB,EACf,QAAQ,EACN,iBAAiB,KACnB,EACF;GACA,eAAe,EACb,QAAQ,EACN,iBAAiB,KACnB,EACF;EACF;CACF,CAAC;AACH"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
type Options = {
|
|
3
|
-
/** Entry file, e.g. `./src/index.ts` */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
/** Entry file, e.g. `./src/index.ts` */
|
|
4
|
+
entry: string | Array<string>;
|
|
5
|
+
/** Source directory used for type generation, e.g. `./src` */
|
|
6
|
+
srcDir: string;
|
|
7
|
+
/** Excluded from type generation, e.g. `[./src/tests]` */
|
|
8
|
+
exclude?: Array<string>;
|
|
9
|
+
/** Directory where build output will be placed, e.g. `./dist` */
|
|
10
|
+
outDir?: string;
|
|
11
|
+
/** Generate CJS output, defaults to `true` */
|
|
12
|
+
cjs?: boolean;
|
|
13
|
+
/** Optional path to a custom tsconfig file, defaults to `./tsconfig.json` */
|
|
14
|
+
tsconfigPath?: string;
|
|
15
|
+
/** Additional dependencies to externalize if not detected by `vite-plugin-externalize-deps` */
|
|
16
|
+
externalDeps?: Array<string | RegExp>;
|
|
17
|
+
/** Dependencies to bundle. Will be passed to the except argument of `vite-plugin-externalize-deps` */
|
|
18
|
+
bundledDeps?: Array<string | RegExp>;
|
|
19
|
+
/** Hook called prior to writing each declaration file; allows to transform the content */
|
|
11
20
|
beforeWriteDeclarationFile?: (filePath: string, content: string) => string;
|
|
12
21
|
};
|
|
13
22
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vite-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Shared Vite build config used by TanStack projects.",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"node": ">=18"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"vite-plugin-dts": "
|
|
33
|
+
"vite-plugin-dts": "5.0.3",
|
|
34
34
|
"vite-plugin-externalize-deps": "^0.10.0",
|
|
35
|
-
"vite-tsconfig-paths": "^6.1.
|
|
35
|
+
"vite-tsconfig-paths": "^6.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"vite": "^8.
|
|
38
|
+
"vite": "^8.1.4",
|
|
39
39
|
"@tanstack/eslint-config": "0.4.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -51,13 +51,13 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
|
|
|
51
51
|
})
|
|
52
52
|
: undefined,
|
|
53
53
|
dts({
|
|
54
|
-
|
|
54
|
+
outDirs: `${outDir}/esm`,
|
|
55
55
|
entryRoot: options.srcDir,
|
|
56
56
|
include: options.srcDir,
|
|
57
57
|
exclude: options.exclude,
|
|
58
58
|
tsconfigPath: options.tsconfigPath,
|
|
59
59
|
compilerOptions: {
|
|
60
|
-
module:
|
|
60
|
+
module: 99, // ESNext
|
|
61
61
|
declarationMap: false,
|
|
62
62
|
},
|
|
63
63
|
beforeWriteFile: (filePath, content) => {
|
|
@@ -77,13 +77,13 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
|
|
|
77
77
|
}),
|
|
78
78
|
cjs
|
|
79
79
|
? dts({
|
|
80
|
-
|
|
80
|
+
outDirs: `${outDir}/cjs`,
|
|
81
81
|
entryRoot: options.srcDir,
|
|
82
82
|
include: options.srcDir,
|
|
83
83
|
exclude: options.exclude,
|
|
84
84
|
tsconfigPath: options.tsconfigPath,
|
|
85
85
|
compilerOptions: {
|
|
86
|
-
module:
|
|
86
|
+
module: 100, // CommonJS - Node16
|
|
87
87
|
declarationMap: false,
|
|
88
88
|
},
|
|
89
89
|
beforeWriteFile: (filePath, content) => {
|
|
@@ -119,11 +119,19 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
|
|
|
119
119
|
return 'esm/[name].js'
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
|
+
// Set both so module preservation holds whether the consumer builds
|
|
123
|
+
// with Vite 7 (Rollup → `rollupOptions`) or Vite 8 (Rolldown →
|
|
124
|
+
// `rolldownOptions`).
|
|
122
125
|
rolldownOptions: {
|
|
123
126
|
output: {
|
|
124
127
|
preserveModules: true,
|
|
125
128
|
},
|
|
126
129
|
},
|
|
130
|
+
rollupOptions: {
|
|
131
|
+
output: {
|
|
132
|
+
preserveModules: true,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
127
135
|
},
|
|
128
136
|
})
|
|
129
137
|
}
|