File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { promises as fs } from 'node:fs'
22import  {  resolve  }  from  'node:path' 
33import  {  fileURLToPath  }  from  'node:url' 
44import  {  isExists  }  from  './utils.ts' 
5+ import  {  readPackageJSON  }  from  'pkg-types' 
56
67const  __dirname  =  fileURLToPath ( new  URL ( '.' ,  import . meta. url ) ) 
78
@@ -39,9 +40,15 @@ async function main() {
3940    console . log ( `${ resolve ( sourcePath ,  target ) } ${ resolve ( destPath ,  target ) }  ) 
4041  } 
4142
43+   const  pkgJSON  =  await  readPackageJSON ( projectPath ) 
44+   const  devDependencies  =  pkgJSON . devDependencies  ||  { } 
45+ 
4246  // add `npm:` prefix 
4347  const  webCode  =  await  fs . readFile ( resolve ( destPath ,  'web.ts' ) ,  'utf-8' ) 
44-   const  replacedWebCode  =  webCode . replace ( "from 'cookie-es'" ,  "from 'npm:cookie-es'" ) 
48+   const  replacedWebCode  =  webCode . replace ( 
49+     "from 'cookie-es'" , 
50+     `from 'npm:cookie-es@${ devDependencies [ 'cookie-es' ] }  , 
51+   ) 
4552  await  fs . writeFile ( resolve ( destPath ,  'web.ts' ) ,  replacedWebCode ,  'utf8' ) 
4653
4754  console . log ( '... 🦕 done!' ) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments