@@ -110,38 +110,42 @@ export const init = async ({ platform, jest, flow, target, jestConfig, outdir, e
110110 if ( options . platform === 'hermes' ) {
111111 const babel = await import ( './babel-worker.cjs' )
112112 loadPipeline . push ( async ( source , filepath ) => {
113- if ( source . includes ( 'using ' ) ) {
114- try {
115- const res = await esbuild . transform ( source , {
116- sourcemap : 'inline' ,
117- sourcefile : filepath ,
118- supported : {
119- using : false ,
120- } ,
121- } )
122- if ( res . warnings . length > 0 ) {
123- console . log ( ...( await formatMessages ( res . warnings , 'warning' ) ) )
124- }
125-
126- source = res . code
127- } catch ( e ) {
128- console . log ( ...( await formatMessages ( e . errors , 'error' ) ) )
129- throw new Error ( 'Transform failed' , { cause : e } )
113+ const loader = extname ( filepath ) . replace ( / ^ \. [ c m ] ? / , '' )
114+ assert ( [ 'js' , 'ts' , 'jsx' , 'tsx' ] . includes ( loader ) )
115+ try {
116+ const res = await esbuild . transform ( source , {
117+ sourcemap : 'inline' ,
118+ sourcefile : filepath ,
119+ loader,
120+ supported : {
121+ 'class-private-accessor' : false ,
122+ 'class-private-brand-check' : false ,
123+ 'class-private-field' : false ,
124+ 'class-private-method' : false ,
125+ 'class-private-static-accessor' : false ,
126+ 'class-private-static-field' : false ,
127+ 'class-private-static-method' : false ,
128+ 'class-static-blocks' : false ,
129+ 'class-static-field' : false ,
130+ 'import-attributes' : false ,
131+ using : false ,
132+ } ,
133+ } )
134+ if ( res . warnings . length > 0 ) {
135+ console . log ( ...( await formatMessages ( res . warnings , 'warning' ) ) )
130136 }
137+
138+ source = res . code
139+ } catch ( e ) {
140+ console . log ( ...( await formatMessages ( e . errors , 'error' ) ) )
141+ throw new Error ( 'Transform failed' , { cause : e } )
131142 }
132143
133144 const result = await babel . transformAsync ( source , {
134145 compact : false ,
135146 babelrc : false ,
136147 configFile : false ,
137- plugins : [
138- '@babel/plugin-syntax-typescript' ,
139- '@babel/plugin-syntax-import-attributes' ,
140- '@babel/plugin-transform-block-scoping' ,
141- '@babel/plugin-transform-class-properties' ,
142- '@babel/plugin-transform-classes' ,
143- '@babel/plugin-transform-private-methods' ,
144- ] ,
148+ plugins : [ '@babel/plugin-transform-block-scoping' , '@babel/plugin-transform-classes' ] ,
145149 } )
146150 return result . code
147151 } )
0 commit comments