guybedford / es-module-lexer

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

fix: ignore dynamic import for `hasModulesyntax` #164

Closed sapphi-red closed 1 year ago

sapphi-red commented 1 year ago

I initially included dynamic imports to be detected as hasModuleSyntax = true in #160. But now I recalled that non-ESM files (e.g. CJS files, <script> tag) can contain dynamic imports.

This PR will make dynamic import to be ignored for hasModulesyntax. Including a dynamic import won't make hasModulesyntax to be true anymore.

Users that wants the previous behavior can achieve with imports.some(i => i.d >= 0) || hasModuleSyntax.

guybedford commented 1 year ago

Thanks for catching this and posting the follow-up.