Given that @guybedford is involved in nft I don't expect this to be a novel idea but I'd like to discuss it anyway.
I think it would be possible to use these two modules to detect all requires instead of depending on acorn and walking the AST. The main advantage would be that it's likely faster and would make nft smaller/simpler.
https://github.com/guybedford/cjs-module-lexer
https://github.com/guybedford/es-module-lexer
Unfortunately cjs-module-lexer doesn't output required files but this PR adds support for it: nodejs/cjs-module-lexer#10
The main blocker for that PR appears to be that detecting requires is somewhat of an unbounded problem, however clear boundaries in what can/cannot be detected might help both cjs-module-lexer and nft.
Given that @guybedford is involved in
nftI don't expect this to be a novel idea but I'd like to discuss it anyway.I think it would be possible to use these two modules to detect all requires instead of depending on acorn and walking the AST. The main advantage would be that it's likely faster and would make
nftsmaller/simpler.https://github.com/guybedford/cjs-module-lexer
https://github.com/guybedford/es-module-lexer
Unfortunately cjs-module-lexer doesn't output required files but this PR adds support for it: nodejs/cjs-module-lexer#10
The main blocker for that PR appears to be that detecting
requires is somewhat of an unbounded problem, however clear boundaries in what can/cannot be detected might help both cjs-module-lexer and nft.