File tree 2 files changed +6
-4
lines changed
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 {
31
31
*/
32
32
constructor ( options = { } ) {
33
33
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
- }
38
34
options . type = options . type || 'application' ;
39
35
40
36
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 {
43
43
*/
44
44
this . pkg = utility . readJSONSync ( path . join ( this . options . baseDir , 'package.json' ) ) ;
45
45
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
+
46
52
/**
47
53
* All framework directories.
48
54
*
You can’t perform that action at this time.
0 commit comments