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 () {
4040
4141 const CHAR_FORWARD_SLASH = '/' . charCodeAt ( 0 )
4242
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+
4365 stat . cache = new Map ( )
4466 function stat ( filename ) {
4567 filename = path . resolve ( path . toNamespacedPath ( filename ) )
Original file line number Diff line number Diff line change 4848 "find-npm-prefix" : " ^1.0.2" ,
4949 "get-stream" : " ^3.0.0" ,
5050 "graceful-fs" : " ^4.1.11" ,
51+ "jsx-transform" : " ^2.4.0" ,
5152 "lock-verify" : " ^2.0.2" ,
5253 "npm-lifecycle" : " ^2.0.3" ,
5354 "npm-logical-tree" : " ^1.2.1" ,
6162 "stringify-package" : " ^1.0.0" ,
6263 "tacks" : " ^1.2.7" ,
6364 "tar" : " ^4.4.4" ,
65+ "typescript" : " ^3.1.1" ,
6466 "yargs" : " ^12.0.1"
6567 },
6668 "config" : {
You can’t perform that action at this time.
0 commit comments