@@ -5,6 +5,8 @@ const node_fs_1 = require("node:fs");
55const node_path_1 = require ( "node:path" ) ;
66const node_url_1 = require ( "node:url" ) ;
77const NM = `${ node_path_1 . sep } node_modules${ node_path_1 . sep } ` ;
8+ const STORE = `.store${ node_path_1 . sep } ` ;
9+ const PKG = `${ node_path_1 . sep } package${ node_path_1 . sep } ` ;
810const DIST = `${ node_path_1 . sep } dist${ node_path_1 . sep } ` ;
911/**
1012 * Find the package.json file, either from a TypeScript file somewhere not
@@ -59,8 +61,16 @@ const findPackageJson = (from, pathFromSrc = '../package.json') => {
5961 // inside of node_modules. find the dist directly under package name.
6062 const nm = __dirname . substring ( 0 , nms + NM . length ) ;
6163 const pkgDir = __dirname . substring ( nms + NM . length ) ;
64+ // affordance for yarn berry, which puts package contents in
65+ // '.../node_modules/.store/${id}-${hash}/package/...'
66+ if ( pkgDir . startsWith ( STORE ) ) {
67+ const pkg = pkgDir . indexOf ( PKG , STORE . length ) ;
68+ if ( pkg ) {
69+ return ( 0 , node_path_1 . resolve ) ( nm , pkgDir . substring ( 0 , pkg + PKG . length ) , 'package.json' ) ;
70+ }
71+ }
6272 const pkgName = pkgDir . startsWith ( '@' ) ?
63- pkgDir . split ( node_path_1 . sep ) . slice ( 0 , 2 ) . join ( node_path_1 . sep )
73+ pkgDir . split ( node_path_1 . sep , 2 ) . join ( node_path_1 . sep )
6474 : String ( pkgDir . split ( node_path_1 . sep ) [ 0 ] ) ;
6575 return ( 0 , node_path_1 . resolve ) ( nm , pkgName , 'package.json' ) ;
6676 }
0 commit comments