This repository was archived by the owner on Jul 28, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +160
-7
lines changed Expand file tree Collapse file tree 3 files changed +160
-7
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,28 @@ function overrideNode () {
40
40
41
41
const CHAR_FORWARD_SLASH = '/' . charCodeAt ( 0 )
42
42
43
+ let jsx
44
+ Module . _extensions [ '.jsx' ] = ( module , filename ) => {
45
+ const content = fs . readFileSync ( filename , 'utf8' )
46
+ if ( ! jsx ) { jsx = require ( 'jsx-transform' ) }
47
+ const transformed = jsx . fromString ( content , { factory : 'h' } )
48
+ module . _compile ( transformed , filename )
49
+ }
50
+
51
+ let ts
52
+ Module . _extensions [ '.ts' ] = ( module , filename ) => {
53
+ const content = fs . readFileSync ( filename , 'utf8' )
54
+ if ( ! ts ) { ts = require ( 'typescript' ) }
55
+ const { outputText} = ts . transpileModule ( content , {
56
+ compilerOptions : {
57
+ module : ts . ModuleKind . CommonJS
58
+ } ,
59
+ fileName : filename
60
+ } )
61
+ module . _compile ( outputText , filename )
62
+ }
63
+ Module . _extensions [ '.tsx' ] = Module . _extensions [ '.ts' ]
64
+
43
65
stat . cache = new Map ( )
44
66
function stat ( filename ) {
45
67
filename = path . resolve ( path . toNamespacedPath ( filename ) )
Original file line number Diff line number Diff line change 48
48
"find-npm-prefix" : " ^1.0.2" ,
49
49
"get-stream" : " ^3.0.0" ,
50
50
"graceful-fs" : " ^4.1.11" ,
51
+ "jsx-transform" : " ^2.4.0" ,
51
52
"lock-verify" : " ^2.0.2" ,
52
53
"npm-lifecycle" : " ^2.0.3" ,
53
54
"npm-logical-tree" : " ^1.2.1" ,
61
62
"stringify-package" : " ^1.0.0" ,
62
63
"tacks" : " ^1.2.7" ,
63
64
"tar" : " ^4.4.4" ,
65
+ "typescript" : " ^3.1.1" ,
64
66
"yargs" : " ^12.0.1"
65
67
},
66
68
"config" : {
You can’t perform that action at this time.
0 commit comments