guybedford / es-module-lexer

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

fix: ignore dynamic import for `hasModulesyntax` #164

Closed sapphi-red closed 8 months ago

sapphi-red commented 8 months 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 8 months ago

Thanks for catching this and posting the follow-up.