guybedford / es-module-lexer

Low-overhead lexer dedicated to ES module parsing for fast analysis
MIT License
912 stars 47 forks source link

Parse imported variables #163

Open privatenumber opened 8 months ago

privatenumber commented 8 months ago

I believe this is a duplicate of https://github.com/guybedford/es-module-lexer/issues/100. It was resolved by providing information on exported variables, but the actual request was for imports.

In my use-case, I'd like to be able to extract the variables (a & c) from a statement like this:

import/*
long comment
*/{
        a,
        b as c
}from/*
long comment
*/'file'

Additionally, I'd like to know the ranges for where the import names start and end: { a, b as c}

guybedford commented 8 months ago

I'm open to adding this feature, if we can try to keep the footprint overhead down.