Skip to content

parsing issues with latest release #64

@danielroe

Description

@danielroe
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions