import { findExports } from 'mlly'
findExports('const a = `<div${JSON.stringify({ class: 42 })}>`;\nexport default true;')
// unterminated template
Update: this seems to be an issue with tokenizer directly, as this also fails:
import { tokenizer } from 'acorn'
[...tokenizer('`<div${JSON.stringify({ class: 42 })}>`', { ecmaVersion: 'latest', sourceType: 'module', allowHashBang: true, allowAwaitOutsideFunction: true, allowImportExportEverywhere: true })]
Upstream issue has been known for several years: acornjs/acorn#1001. See comment:
So the code just fails to tokenize correctly when not running the actual parser? That's unfortunately how JS tokenization works—it's sufficiently difficult that you need a parser to direct it in some corner cases. Making our tokenizer 100% independent is not a goal of this library.
Update: this seems to be an issue with tokenizer directly, as this also fails:
Upstream issue has been known for several years: acornjs/acorn#1001. See comment: