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 #183

Open
mbostock opened this issue Nov 15, 2023 · 2 comments · May be fixed by #364
Open

Import attributes #183

mbostock opened this issue Nov 15, 2023 · 2 comments · May be fixed by #364
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

We should support import assertions. This may require the acorn-import-assertions plugin.

Static imports with assertions look like this:

import data from "./data.json" assert {type: "json"};

Dynamic imports with assertions look like this:

const data = await import("./data.json", {assert: {type: "json"}});

Both of these currently generate syntax errors with Acorn, but are supported by most browsers.

@mbostock mbostock added the enhancement New feature or request label Nov 15, 2023
@mbostock mbostock added this to the Future milestone Nov 15, 2023
@Fil Fil linked a pull request Dec 11, 2023 that will close this issue
2 tasks
@mootari
Copy link
Member

mootari commented Jan 20, 2024

Maybe worth mentioning that ESLint won't add support for import attributes until they become Stage 4 and fails to parse a file that contains them.

@mbostock mbostock changed the title Import assertions Import attributes Mar 4, 2024
@mbostock
Copy link
Member Author

mbostock commented Mar 4, 2024

These are now called “import attributes” and use with instead of assert. Still not widely supported though.

@mbostock mbostock removed this from the Future milestone Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants