Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

Should named JSON module import be a parsing stage error? #27

@JLHwung

Description

@JLHwung

Currently Babel parser throws syntax error for the following cases:

import { foo } from "./foo" asserts { type: "json" };

which conforms to this test262 test.

But the spec only states that JSON module should provide only a single default export, so a SyntaxError should be thrown no later than the module resolution stage. However unlike random modules, a parser can recognize JSON module imports thanks to the import assertion syntax. So should a JavaScript parser throw such errors?

Either way an end user will not observe any differences, but it helps us define the scope.

Context: babel/babel#14816

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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