@tanstack/vite-config 0.5.0 → 0.5.2

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.js CHANGED
@@ -54,7 +54,7 @@ const tanstackViteConfig = (options) => {
54
54
  exclude: options.exclude,
55
55
  tsconfigPath: options.tsconfigPath,
56
56
  compilerOptions: {
57
- module: 1,
57
+ module: 100,
58
58
  declarationMap: false
59
59
  },
60
60
  beforeWriteFile: (filePath, content) => {
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: 1, // CommonJS\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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AW;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 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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5.2",
4
4
  "description": "Shared Vite build config used by TanStack projects.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "vite-plugin-dts": "4.2.3",
34
34
  "vite-plugin-externalize-deps": "^0.10.0",
35
- "vite-tsconfig-paths": "^6.1.0"
35
+ "vite-tsconfig-paths": "^6.1.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "vite": "^8.0.0",
package/src/index.ts CHANGED
@@ -83,7 +83,7 @@ export const tanstackViteConfig = (options: Options): UserConfig => {
83
83
  exclude: options.exclude,
84
84
  tsconfigPath: options.tsconfigPath,
85
85
  compilerOptions: {
86
- module: 1, // CommonJS
86
+ module: 100, // CommonJS - Node16
87
87
  declarationMap: false,
88
88
  },
89
89
  beforeWriteFile: (filePath, content) => {