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' ;
910
1011console . log ( `Node: ${ process . version } ` ) ;
1112
12- const head = [ 'fixture' , 'current' , 'v6.0.0-alpha.3' , 'v5.4.3' , 'v4.1.1' ] ;
13+ const __dirname = dirname ( fileURLToPath ( import . meta . url ) ) ;
1314
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' ] ;
1518
1619const table = new Table ( {
1720 head,
@@ -30,7 +33,7 @@ if (!global.gc) {
3033
3134files . forEach ( file => {
3235 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 _ _ \/ / , '' ) ) ;
3437 const options = { filename : file , babelrc : false , configFile : false } ;
3538 const newOptions = { babelOptions : options } ;
3639
@@ -40,17 +43,17 @@ files.forEach(file => {
4043 parse5 ( code , undefined , undefined , options ) ;
4144 parse4 ( code , undefined , undefined , options ) ;
4245 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 ) ;
4848 } ) ;
4949 suite . add ( 'v5.4.3' , ( ) => {
5050 parse5 ( code , undefined , undefined , options ) ;
5151 } ) ;
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 ) ;
5457 } ) ;
5558 const result = [ suite . name ] ;
5659
0 commit comments