@@ -3,39 +3,45 @@ import path from 'node:path'
3
3
import babel from '@babel/core'
4
4
import { Parser } from 'acorn'
5
5
import acornJsx from 'acorn-jsx'
6
- import { generate } from 'astring '
6
+ import { toJs } from 'estree-util-to-js '
7
7
import { buildJsx } from 'estree-util-build-jsx'
8
8
9
9
const doc = String ( fs . readFileSync ( path . join ( 'test' , 'jsx.jsx' ) ) )
10
10
11
11
fs . writeFileSync (
12
12
path . join ( 'test' , 'jsx-build-jsx-classic.js' ) ,
13
- generate (
13
+ toJs (
14
+ // @ts -expect-error it’s a program.
14
15
buildJsx (
15
16
// @ts -expect-error Acorn nodes are assignable to ESTree nodes.
16
17
Parser . extend ( acornJsx ( ) ) . parse (
17
18
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.
19
21
{ sourceType : 'module' , ecmaVersion : 2021 }
20
22
) ,
21
23
{ pragma : 'x' , pragmaFrag : 'null' }
22
24
)
23
- )
25
+ // @ts -expect-error Some bug in `to-js`
26
+ ) . value
24
27
)
25
28
26
29
fs . writeFileSync (
27
30
path . join ( 'test' , 'jsx-build-jsx-automatic.js' ) ,
28
- generate (
31
+ toJs (
32
+ // @ts -expect-error it’s a program.
29
33
buildJsx (
30
34
// @ts -expect-error Acorn nodes are assignable to ESTree nodes.
31
35
Parser . extend ( acornJsx ( ) ) . parse (
32
36
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.
34
39
{ sourceType : 'module' , ecmaVersion : 2021 }
35
40
) ,
36
41
{ runtime : 'automatic' , importSource : '.' }
37
42
)
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' )
39
45
)
40
46
41
47
fs . writeFileSync (
0 commit comments