diff --git a/package.json b/package.json index 27b6606a..b7b81211 100644 --- a/package.json +++ b/package.json @@ -46,13 +46,13 @@ "citty": "^0.2.2", "consola": "^3.4.2", "defu": "^6.1.7", + "get-tsconfig": "^4.14.0", "jiti": "^2.7.0", "magic-regexp": "^0.11.0", "mkdist": "^2.4.1", "mlly": "^1.8.2", "pathe": "^2.0.3", "pkg-types": "^2.3.1", - "tsconfck": "^3.1.6", "unbuild": "^3.6.1", "vue-sfc-transformer": "^0.2.5" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d46a32d..b70fe4aa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: defu: specifier: ^6.1.7 version: 6.1.7 + get-tsconfig: + specifier: ^4.14.0 + version: 4.14.0 jiti: specifier: ^2.7.0 version: 2.7.0 @@ -44,9 +47,6 @@ importers: pkg-types: specifier: ^2.3.1 version: 2.3.1 - tsconfck: - specifier: ^3.1.6 - version: 3.1.6(typescript@5.9.3) unbuild: specifier: ^3.6.1 version: 3.6.1(typescript@5.9.3)(vue-sfc-transformer@0.2.5(@volar/typescript@2.4.28)(@vue/compiler-core@3.5.40)(@vue/language-core@3.3.8)(esbuild@0.28.0)(rolldown@1.2.0)(typescript@5.9.3)(vue@3.5.40(typescript@5.9.3)))(vue-tsc@3.3.8(typescript@5.9.3))(vue@3.5.40(typescript@5.9.3)) @@ -5115,17 +5115,6 @@ packages: peerDependencies: typescript: ~5.9.3 - tsconfck@3.1.6: - resolution: {integrity: sha512-ks6Vjr/jEw0P1gmOVwutM3B7fWxoWBL2KRDb1JfqGVawBmO5UsvmWOQFGHBPl5yxYz4eERr19E6L7NMv+Fej4w==} - engines: {node: ^18 || >=20} - deprecated: unmaintained - hasBin: true - peerDependencies: - typescript: ~5.9.3 - peerDependenciesMeta: - typescript: - optional: true - tsdown@0.22.14: resolution: {integrity: sha512-ule7Y+fsAN2iZbLDoo7C4KYljFJNJJ+fLshyn+9gozeTspVersWHxwdGB+Dm2hzA38s6muFnUTl0jK3vJm9ifQ==} engines: {node: ^22.18.0 || >=24.11.0} @@ -11244,10 +11233,6 @@ snapshots: dependencies: typescript: 5.9.3 - tsconfck@3.1.6(typescript@5.9.3): - optionalDependencies: - typescript: 5.9.3 - tsdown@0.22.14(@arethetypeswrong/core@0.18.5)(@volar/typescript@2.4.28)(oxc-resolver@11.24.2)(publint@0.3.22)(typescript@5.9.3)(vue-tsc@3.3.8(typescript@5.9.3)): dependencies: ansis: 4.3.1 diff --git a/src/commands/build.ts b/src/commands/build.ts index acdda04d..1eb65cc7 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -3,8 +3,7 @@ import { pathToFileURL } from 'node:url' import { basename, dirname, extname, join, normalize, resolve } from 'pathe' import { filename } from 'pathe/utils' import { readPackageJSON } from 'pkg-types' -import { parse } from 'tsconfck' -import type { TSConfig } from 'pkg-types' +import { createPathsMatcher, getTsconfig } from 'get-tsconfig' import { defu } from 'defu' import { createJiti } from 'jiti' import { anyOf, createRegExp } from 'magic-regexp' @@ -100,7 +99,7 @@ export default defineCommand({ hooks: { async 'mkdist:entry:options'(_ctx, entry, options) { options.typescript = defu(options.typescript, { - compilerOptions: await loadTSCompilerOptions(entry.input), + compilerOptions: loadTSCompilerOptions(entry.input), }) }, async 'rollup:options'(ctx, options) { @@ -110,7 +109,7 @@ export default defineCommand({ paths: { '#app/nuxt': ['./node_modules/nuxt/dist/app/nuxt'], }, - }, ctx.options.rollup.dts.compilerOptions, await loadTSCompilerOptions(entry!.path)) + }, ctx.options.rollup.dts.compilerOptions, loadTSCompilerOptions(entry!.path)) ctx.options.rollup.dts.compilerOptions = convertCompilerOptionsFromJson(mergedCompilerOptions, entry!.path).options options.plugins ||= [] if (!Array.isArray(options.plugins)) @@ -309,20 +308,17 @@ async function rewriteRuntimeTypeAliases(runtimeDir: string) { })) } -async function loadTSCompilerOptions(path: string): Promise> { - const config = await parse(path) - const resolvedCompilerOptions = config?.tsconfig.compilerOptions || {} +function loadTSCompilerOptions(path: string) { + const tsconfig = getTsconfig(path) + const compilerOptions = tsconfig?.config.compilerOptions ?? {} - // TODO: this should probably be ported to tsconfck? - for (const { tsconfig, tsconfigFile } of config.extended || []) { - for (const alias in tsconfig.compilerOptions?.paths || {}) { - resolvedCompilerOptions.paths[alias] = resolvedCompilerOptions.paths[alias].map((p: string) => { - if (!/^\.{1,2}(?:\/|$)/.test(p)) return p + const matchPath = tsconfig && createPathsMatcher(tsconfig) - return resolve(dirname(tsconfigFile), p) - }) + if (matchPath && compilerOptions.paths) { + for (const alias in compilerOptions.paths) { + compilerOptions.paths[alias] = matchPath(alias) } } - return resolvedCompilerOptions + return compilerOptions }