babel-plugin-espower icon indicating copy to clipboard operation
babel-plugin-espower copied to clipboard

Is estraverse necessary?

Open STRML opened this issue 4 years ago • 2 comments

This is the first babel plugin I've seen that simply uses a Program entrypoint then uses estraverse all over (https://github.com/power-assert-js/babel-plugin-espower/blob/4932320d9eecffca0dc38dc7fc2684ffffca1c6c/lib/babel-assertion-visitor.js) rather than use the visitors provided by Babel itself.

This additional/redundant parsing makes estraverse's functions the heaviest in a profile run of one test file, screenshotted below:

Screen Shot 2019-11-08 at 11 33 46 AM

This leads to us finding estraverse code at the bottom of a significant proportion of the flame graph:

Screen Shot 2019-11-08 at 11 36 09 AM

How necessary is this module? Can the plugin be modified to follow babel conventions more closely?

Time with babel-plugin-espower enabled:

env BABEL_DISABLE_CACHE=1 time ./node_modules/.bin/mocha test/spec/fooSpec.js
...
       11.28 real        13.31 user         1.03 sys

With it disabled:

env BABEL_DISABLE_CACHE=1 time ./node_modules/.bin/mocha test/spec/fooSpec.js
...
      7.29 real         8.85 user         0.96 sys

STRML avatar Nov 08 '19 16:11 STRML