(options: Options)
| 60 | // - build - lib - fileName: [name.mjs] |
| 61 | // - rollup - output - preserveModulesRoot: src |
| 62 | export const tanstackViteConfig = (options: Options) => { |
| 63 | const outDir = options.outDir ?? 'dist' |
| 64 | const cjs = options.cjs ?? true |
| 65 | |
| 66 | return defineConfig({ |
| 67 | plugins: [ |
| 68 | externalizeDeps({ include: options.externalDeps ?? [] }), |
| 69 | tsconfigPaths({ |
| 70 | projects: options.tsconfigPath ? [options.tsconfigPath] : undefined, |
| 71 | }), |
| 72 | dts({ |
| 73 | outDir, |
| 74 | entryRoot: options.srcDir, |
| 75 | include: options.srcDir, |
| 76 | exclude: options.exclude, |
| 77 | tsconfigPath: options.tsconfigPath, |
| 78 | compilerOptions: { |
| 79 | module: 99, // ESNext |
| 80 | declarationMap: false, |
| 81 | }, |
| 82 | beforeWriteFile: (filePath, content) => { |
| 83 | return { |
| 84 | filePath, |
| 85 | content: ensureImportFileExtension({ content, extension: 'js' }), |
| 86 | } |
| 87 | }, |
| 88 | afterDiagnostic: (diagnostics) => { |
| 89 | if (diagnostics.length > 0) { |
| 90 | console.error('Please fix the above type errors') |
| 91 | process.exit(1) |
| 92 | } |
| 93 | }, |
| 94 | }), |
| 95 | ], |
| 96 | build: { |
| 97 | outDir, |
| 98 | minify: false, |
| 99 | sourcemap: true, |
| 100 | lib: { |
| 101 | entry: options.entry, |
| 102 | formats: cjs ? ['es', 'cjs'] : ['es'], |
| 103 | fileName: () => '[name].mjs', |
| 104 | }, |
| 105 | rollupOptions: { |
| 106 | output: { |
| 107 | preserveModules: true, |
| 108 | preserveModulesRoot: 'src', |
| 109 | }, |
| 110 | }, |
| 111 | }, |
| 112 | }) |
| 113 | } |
| 114 | |
| 115 | export default mergeConfig( |
| 116 | config, |
no test coverage detected