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

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

Closed
silverwind opened this issue May 24, 2024 · 2 comments
Closed

Comments

@silverwind
Copy link

silverwind commented May 24, 2024

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" };
@evanw
Copy link
Owner

evanw commented May 24, 2024

Thanks for the heads up! I'll add support for node v18.20+.

Current behaviour enables them only for node 21 and above:

That's not exactly right. They're already enabled in v20.10+, just not v20+: (example)

@evanw evanw closed this as completed in 5069410 May 24, 2024
@silverwind
Copy link
Author

Thanks. I wasn't aware that target also accepts minor versions. Good to know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants