@@ -2,7 +2,7 @@ import { confirm, intro, isCancel, log, outro } from "@clack/prompts";
22import { Command } from "commander" ;
33import { detectPackageManager , installDependencies } from "nypm" ;
44import { basename , dirname , resolve } from "path" ;
5- import { PackageJson , readPackageJSON , resolvePackageJSON } from "pkg-types" ;
5+ import { PackageJson , readPackageJSON , type ResolveOptions , resolvePackageJSON } from "pkg-types" ;
66import { z } from "zod" ;
77import { CommonCommandOptions , OutroCommandError , wrapCommandAction } from "../cli/common.js" ;
88import { chalkError , prettyError , prettyWarning } from "../utilities/cliOutput.js" ;
@@ -339,8 +339,20 @@ async function tryResolveTriggerPackageVersion(
339339
340340 logger . debug ( `Resolved ${ name } package version path` , { name, resolvedPath } ) ;
341341
342- // IMPORTANT: keep the two dirname calls, as the first one resolves the nested package.json inside dist/commonjs or dist/esm
343- const { packageJson } = await getPackageJson ( dirname ( dirname ( resolvedPath ) ) ) ;
342+ const { packageJson } = await getPackageJson ( dirname ( resolvedPath ) , {
343+ test : ( filePath ) => {
344+ // We need to skip any type-marker files
345+ if ( filePath . includes ( "dist/commonjs" ) ) {
346+ return false ;
347+ }
348+
349+ if ( filePath . includes ( "dist/esm" ) ) {
350+ return false ;
351+ }
352+
353+ return true ;
354+ } ,
355+ } ) ;
344356
345357 if ( packageJson . version ) {
346358 logger . debug ( `Resolved ${ name } package version` , { name, version : packageJson . version } ) ;
@@ -398,8 +410,8 @@ async function updateConfirmation(depsToUpdate: Dependency[], targetVersion: str
398410 } ) ;
399411}
400412
401- export async function getPackageJson ( absoluteProjectPath : string ) {
402- const packageJsonPath = await resolvePackageJSON ( absoluteProjectPath ) ;
413+ export async function getPackageJson ( absoluteProjectPath : string , options ?: ResolveOptions ) {
414+ const packageJsonPath = await resolvePackageJSON ( absoluteProjectPath , options ) ;
403415 const readonlyPackageJson = await readPackageJSON ( packageJsonPath ) ;
404416
405417 const packageJson = structuredClone ( readonlyPackageJson ) ;
0 commit comments