From 66d423123b58a2ce14fe7166d3c1cc61446b05c8 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 9 Feb 2025 21:21:02 +0000 Subject: [PATCH] chore: add more type-safe solution + fallback --- src/commands/build.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/build.ts b/src/commands/build.ts index 09070a2..eb514e9 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -1,6 +1,6 @@ import { existsSync, promises as fsp } from 'node:fs' import { pathToFileURL } from 'node:url' -import { basename, dirname, join, normalize, resolve } from 'pathe' +import { basename, dirname, extname, join, normalize, resolve } from 'pathe' import { filename } from 'pathe/utils' import { readPackageJSON } from 'pkg-types' import { parse } from 'tsconfck' @@ -135,10 +135,11 @@ export default defineCommand({ const normalizedId = normalize(resolved.id) for (const entry of runtimeEntries) { - if (!normalizedId.includes(entry.input)) + if (!entry.outDir || !normalizedId.includes(entry.input)) continue - const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId).href.replace(entry.input, entry.outDir!)), filename(normalizedId)!)) + const name = filename(normalizedId) || basename(normalizedId, extname(normalizedId)) + const distFile = await resolvePath(join(dirname(pathToFileURL(normalizedId).href.replace(entry.input, entry.outDir)), name)) if (distFile) { return { external: true,