Skip to content

babel-parser throws syntax error for import string names with flow plugin #12209

@sosukesuzuki

Description

@sosukesuzuki

Bug Report

  • I would like to work on a fix!

Current behavior

babel-parser throws syntax error Unexpected token (1:9) with moduleStringNames plugin and flow plugin. (REPL)
This happens on import only, export works fine. (REPL)

Input Code

import { "foo" as foo } from "module-a";

Expected behavior

No syntax error is thrown.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Call parse directly.

const code = `import { "foo" as foo } from "module-a";`;
require("@babel/parser").parse(code, {
  sourceType: "module",
  plugins: ["moduleStringNames", "flow"],
});

Environment

Possible Solution

Additional context

Found from working on prettier/prettier#9408

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: flowoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions