@tanstack/vite-config 0.5.2 → 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 CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Options } from "./types.js";
2
2
  import { UserConfig } from "vite";
3
-
4
3
  //#region src/index.d.ts
5
4
  declare const tanstackViteConfig: (options: Options) => UserConfig;
6
5
  //#endregion
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ const tanstackViteConfig = (options) => {
21
21
  }),
22
22
  options.tsconfigPath ? tsconfigPaths({ projects: [options.tsconfigPath] }) : void 0,
23
23
  dts({
24
- outDir: `${outDir}/esm`,
24
+ outDirs: `${outDir}/esm`,
25
25
  entryRoot: options.srcDir,
26
26
  include: options.srcDir,
27
27
  exclude: options.exclude,
@@ -48,7 +48,7 @@ const tanstackViteConfig = (options) => {
48
48
  }
49
49
  }),
50
50
  cjs ? dts({
51
- outDir: `${outDir}/cjs`,
51
+ outDirs: `${outDir}/cjs`,
52
52
  entryRoot: options.srcDir,
53
53
  include: options.srcDir,
54
54
  exclude: options.exclude,
@@ -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 outDir: `${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 outDir: `${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 rolldownOptions: {\n output: {\n preserveModules: true,\n },\n },\n },\n })\n}\n"],"mappings":";;;;;;AAWA,SAAS,0BAA0B,EACjC,SACA,aAIC;AAED,WAAU,QAAQ,QAChB,uEACA,MAAM,YACP;AAGD,WAAU,QAAQ,QAChB,gDACA,MAAM,YACP;AACD,QAAO;;AAGT,MAAa,sBAAsB,YAAiC;CAClE,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,MAAM,QAAQ,OAAO;AAE3B,QAAO,aAAa;EAClB,SAAS,EACP,eAAe,CAAC,QAAQ,cACzB;EACD,SAAS;GACP,gBAAgB;IACd,SAAS,QAAQ,gBAAgB,EAAE;IACnC,QAAQ,QAAQ,eAAe,EAAE;IAClC,CAAC;GAGF,QAAQ,eACJ,cAAc,EACZ,UAAU,CAAC,QAAQ,aAAa,EACjC,CAAC,GACF;GACJ,IAAI;IACF,QAAQ,GAAG,OAAO;IAClB,WAAW,QAAQ;IACnB,SAAS,QAAQ;IACjB,SAAS,QAAQ;IACjB,cAAc,QAAQ;IACtB,iBAAiB;KACf,QAAQ;KACR,gBAAgB;KACjB;IACD,kBAAkB,UAAU,YAAY;AACtC,eACE,QAAQ,6BAA6B,UAAU,QAAQ,IAAI;AAC7D,YAAO;MACL;MACA,SAAS,0BAA0B;OAAE;OAAS,WAAW;OAAM,CAAC;MACjE;;IAEH,kBAAkB,gBAAgB;AAChC,SAAI,YAAY,SAAS,GAAG;AAC1B,cAAQ,MAAM,mCAAmC;AACjD,cAAQ,KAAK,EAAE;;;IAGpB,CAAC;GACF,MACI,IAAI;IACF,QAAQ,GAAG,OAAO;IAClB,WAAW,QAAQ;IACnB,SAAS,QAAQ;IACjB,SAAS,QAAQ;IACjB,cAAc,QAAQ;IACtB,iBAAiB;KACf,QAAQ;KACR,gBAAgB;KACjB;IACD,kBAAkB,UAAU,YAAY;AACtC,eACE,QAAQ,6BAA6B,UAAU,QAAQ,IACvD;AACF,YAAO;MACL,UAAU,SAAS,QAAQ,SAAS,SAAS;MAC7C,SAAS,0BAA0B;OACjC;OACA,WAAW;OACZ,CAAC;MACH;;IAEH,kBAAkB,gBAAgB;AAChC,SAAI,YAAY,SAAS,GAAG;AAC1B,cAAQ,MAAM,mCAAmC;AACjD,cAAQ,KAAK,EAAE;;;IAGpB,CAAC,GACF;GACL;EACD,OAAO;GACL;GACA,QAAQ;GACR,WAAW;GACX,KAAK;IACH,OAAO,QAAQ;IACf,SAAS,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAK;IACrC,WAAW,WAAW;AACpB,SAAI,WAAW,MAAO,QAAO;AAC7B,YAAO;;IAEV;GACD,iBAAiB,EACf,QAAQ,EACN,iBAAiB,MAClB,EACF;GACF;EACF,CAAC"}
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` */entry: string | Array<string>; /** Source directory used for type generation, e.g. `./src` */
4
- srcDir: string; /** Excluded from type generation, e.g. `[./src/tests]` */
5
- exclude?: Array<string>; /** Directory where build output will be placed, e.g. `./dist` */
6
- outDir?: string; /** Generate CJS output, defaults to `true` */
7
- cjs?: boolean; /** Optional path to a custom tsconfig file, defaults to `./tsconfig.json` */
8
- tsconfigPath?: string; /** Additional dependencies to externalize if not detected by `vite-plugin-externalize-deps` */
9
- externalDeps?: Array<string | RegExp>; /** Dependencies to bundle. Will be passed to the except argument of `vite-plugin-externalize-deps` */
10
- bundledDeps?: Array<string | RegExp>; /** Hook called prior to writing each declaration file; allows to transform the content */
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.5.2",
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": "4.2.3",
33
+ "vite-plugin-dts": "5.0.3",
34
34
  "vite-plugin-externalize-deps": "^0.10.0",
35
35
  "vite-tsconfig-paths": "^6.1.1"
36
36
  },
37
37
  "devDependencies": {
38
- "vite": "^8.0.0",
38
+ "vite": "^8.1.4",
39
39
  "@tanstack/eslint-config": "0.4.0"
40
40
  },
41
41
  "peerDependencies": {
package/src/index.ts CHANGED
@@ -51,7 +51,7 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
51
51
  })
52
52
  : undefined,
53
53
  dts({
54
- outDir: `${outDir}/esm`,
54
+ outDirs: `${outDir}/esm`,
55
55
  entryRoot: options.srcDir,
56
56
  include: options.srcDir,
57
57
  exclude: options.exclude,
@@ -77,7 +77,7 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
77
77
  }),
78
78
  cjs
79
79
  ? dts({
80
- outDir: `${outDir}/cjs`,
80
+ outDirs: `${outDir}/cjs`,
81
81
  entryRoot: options.srcDir,
82
82
  include: options.srcDir,
83
83
  exclude: options.exclude,
@@ -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
  }