@AbhiPrasad suggested we use es-module-lexer father than acorn:
It's specifically designed for the task of parsing imports and exports
8x smaller than acorn (4KiB vs 32KiB gzipped)
20x faster than acorn
A very small single JS file (4KiB gzipped) that includes inlined Web Assembly for very fast source analysis of ECMAScript module syntax only.
For an example of the performance, Angular 1 (720KiB) is fully parsed in 5ms, in comparison to the fastest JS parser, Acorn which takes over 100ms.
Comprehensively handles the JS language grammar while remaining small and fast. - ~10ms per MB of JS cold and ~5ms per MB of JS warm, see benchmarks for more info.
I gave it a test and the entire getEsmExports can be replaced with this:
@AbhiPrasad suggested we use
es-module-lexer
father thanacorn
:acorn
(4KiB vs 32KiB gzipped)acorn
I gave it a test and the entire
getEsmExports
can be replaced with this:A couple of tests fail due to a couple of missing parser features: https://github.com/guybedford/es-module-lexer/issues/175 https://github.com/guybedford/es-module-lexer/issues/176