@@ -3,39 +3,45 @@ import path from 'node:path'
33import babel from '@babel/core'
44import { Parser } from 'acorn'
55import acornJsx from 'acorn-jsx'
6- import { generate } from 'astring '
6+ import { toJs } from 'estree-util-to-js '
77import { buildJsx } from 'estree-util-build-jsx'
88
99const doc = String ( fs . readFileSync ( path . join ( 'test' , 'jsx.jsx' ) ) )
1010
1111fs . writeFileSync (
1212 path . join ( 'test' , 'jsx-build-jsx-classic.js' ) ,
13- generate (
13+ toJs (
14+ // @ts -expect-error it’s a program.
1415 buildJsx (
1516 // @ts -expect-error Acorn nodes are assignable to ESTree nodes.
1617 Parser . extend ( acornJsx ( ) ) . parse (
1718 doc . replace ( / ' n a m e ' / , "'jsx (estree-util-build-jsx, classic)'" ) ,
18- // @ts -expect-error Hush, `2021` is fine.
19+ // Note: different npms resolve this differently, so it may break or work, hence the ignore.
20+ // @ts -ignore Hush, `2021` is fine.
1921 { sourceType : 'module' , ecmaVersion : 2021 }
2022 ) ,
2123 { pragma : 'x' , pragmaFrag : 'null' }
2224 )
23- )
25+ // @ts -expect-error Some bug in `to-js`
26+ ) . value
2427)
2528
2629fs . writeFileSync (
2730 path . join ( 'test' , 'jsx-build-jsx-automatic.js' ) ,
28- generate (
31+ toJs (
32+ // @ts -expect-error it’s a program.
2933 buildJsx (
3034 // @ts -expect-error Acorn nodes are assignable to ESTree nodes.
3135 Parser . extend ( acornJsx ( ) ) . parse (
3236 doc . replace ( / ' n a m e ' / , "'jsx (estree-util-build-jsx, automatic)'" ) ,
33- // @ts -expect-error Hush, `2021` is fine.
37+ // Note: different npms resolve this differently, so it may break or work, hence the ignore.
38+ // @ts -ignore Hush, `2021` is fine.
3439 { sourceType : 'module' , ecmaVersion : 2021 }
3540 ) ,
3641 { runtime : 'automatic' , importSource : '.' }
3742 )
38- ) . replace ( / \/ j s x - r u n t i m e (? = [ " ' ] ) / g, './lib/runtime.js' )
43+ // @ts -expect-error Some bug in `to-js`
44+ ) . value . replace ( / \/ j s x - r u n t i m e (? = [ " ' ] ) / g, './lib/runtime.js' )
3945)
4046
4147fs . writeFileSync (
0 commit comments