Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing issues with latest release #64

Closed
danielroe opened this issue Aug 3, 2022 · 0 comments
Closed

parsing issues with latest release #64

danielroe opened this issue Aug 3, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@danielroe
Copy link
Member

danielroe commented Aug 3, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant