File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,6 @@ class EggCore extends KoaApplication {
3131   */ 
3232  constructor ( options  =  { } )  { 
3333    options . baseDir  =  options . baseDir  ||  process . cwd ( ) ; 
34-     // auto require('tsconfig-paths/register') on typescript app 
35-     if  ( process . env . EGG_TYPESCRIPT  ===  'true' )  { 
36-       require ( 'tsconfig-paths' ) . register ( {  cwd : options . baseDir  } ) ; 
37-     } 
3834    options . type  =  options . type  ||  'application' ; 
3935
4036    assert ( typeof  options . baseDir  ===  'string' ,  'options.baseDir required, and must be a string' ) ; 
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ class EggLoader {
4343     */ 
4444    this . pkg  =  utility . readJSONSync ( path . join ( this . options . baseDir ,  'package.json' ) ) ; 
4545
46+     // auto require('tsconfig-paths/register') on typescript app 
47+     // support env.EGG_TYPESCRIPT = true or { "egg": { "typescript": true }  } on package.json 
48+     if  ( process . env . EGG_TYPESCRIPT  ===  'true'  ||  ( this . pkg . egg  &&  this . pkg . egg . typescript ) )  { 
49+       require ( 'tsconfig-paths' ) . register ( {  cwd : this . options . baseDir  } ) ; 
50+     } 
51+ 
4652    /** 
4753     * All framework directories. 
4854     * 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments