Skip to content

Use cjs/es-module-lexer instead of acorn #169

@tjallingt

Description

@tjallingt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions