1
- const fs = require ( 'fs' ) ;
2
- const path = require ( 'path' ) ;
3
- const Table = require ( 'cli-table' ) ;
4
- const Benchmark = require ( 'benchmark' ) ;
5
- const { parse } = require ( '../packages/react-docgen' ) ;
6
- const { parse : parse4 } = require ( 'react-docgen4' ) ;
7
- const { parse : parse5 } = require ( 'react-docgen5' ) ;
8
- const { parse : parse6old } = require ( 'react-docgen6pre' ) ;
1
+ import fs from 'fs' ;
2
+ import path , { dirname } from 'path' ;
3
+ import { fileURLToPath } from 'url' ;
4
+ import Table from 'cli-table' ;
5
+ import Benchmark from 'benchmark' ;
6
+ import { parse } from '../packages/react-docgen/dist/main.js' ;
7
+ import { parse as parse4 } from 'react-docgen4' ;
8
+ import { parse as parse5 } from 'react-docgen5' ;
9
+ import { parse as parse6old } from 'react-docgen6pre' ;
9
10
10
11
console . log ( `Node: ${ process . version } ` ) ;
11
12
12
- const head = [ 'fixture' , 'current' , 'v6.0.0-alpha.3' , 'v5.4.3' , 'v4.1.1' ] ;
13
+ const __dirname = dirname ( fileURLToPath ( import . meta . url ) ) ;
13
14
14
- const files = [ './fixtures/CircularProgress.js' ] ;
15
+ const head = [ 'fixture' , 'v4.1.1' , 'v5.4.3' , 'v6.0.0-alpha.3' , 'current' ] ;
16
+
17
+ const files = [ './__fixtures__/CircularProgress.js' ] ;
15
18
16
19
const table = new Table ( {
17
20
head,
@@ -30,7 +33,7 @@ if (!global.gc) {
30
33
31
34
files . forEach ( file => {
32
35
const code = fs . readFileSync ( path . join ( __dirname , file ) , 'utf-8' ) ;
33
- const suite = new Benchmark . Suite ( file . replace ( / \. \/ f i x t u r e s \/ / , '' ) ) ;
36
+ const suite = new Benchmark . Suite ( file . replace ( / \. \/ _ _ f i x t u r e s _ _ \/ / , '' ) ) ;
34
37
const options = { filename : file , babelrc : false , configFile : false } ;
35
38
const newOptions = { babelOptions : options } ;
36
39
@@ -40,17 +43,17 @@ files.forEach(file => {
40
43
parse5 ( code , undefined , undefined , options ) ;
41
44
parse4 ( code , undefined , undefined , options ) ;
42
45
global . gc ( ) ;
43
- suite . add ( 'current' , ( ) => {
44
- parse ( code , newOptions ) ;
45
- } ) ;
46
- suite . add ( 'v6.0.0-alpha.3' , ( ) => {
47
- parse6old ( code , undefined , undefined , options ) ;
46
+ suite . add ( 'v4.1.1' , ( ) => {
47
+ parse4 ( code , undefined , undefined , options ) ;
48
48
} ) ;
49
49
suite . add ( 'v5.4.3' , ( ) => {
50
50
parse5 ( code , undefined , undefined , options ) ;
51
51
} ) ;
52
- suite . add ( 'v4.1.1' , ( ) => {
53
- parse4 ( code , undefined , undefined , options ) ;
52
+ suite . add ( 'v6.0.0-alpha.3' , ( ) => {
53
+ parse6old ( code , undefined , undefined , options ) ;
54
+ } ) ;
55
+ suite . add ( 'current' , ( ) => {
56
+ parse ( code , newOptions ) ;
54
57
} ) ;
55
58
const result = [ suite . name ] ;
56
59
0 commit comments