Skip to content

Commit

Permalink
chore: add more type-safe solution + fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Feb 9, 2025
1 parent 14d7788 commit 66d4231
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 66d4231

Please sign in to comment.