Skip to content

Import attributes should be enabled for node18 and >= node20 targets #3778

@silverwind

Description

@silverwind

Import attributes were initially shipped in Node 21, but have recently been backported into 18 and 20 branches, specifically available in v21.0.0, v20.10.0, v18.20.0.

Ref: https://nodejs.org/api/esm.html#import-assertions

Current behaviour enables them only for node 21 and above:

$ echo "import foo from 'foo.json' with {type: 'json'}" | esbuild --target="node20"
import foo from "foo.json";
$ echo "import foo from 'foo.json' with {type: 'json'}" | esbuild --target="node21"
import foo from "foo.json" with { type: "json" };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions