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.meta.resolve for files #1008

Closed
mbostock opened this issue Mar 7, 2024 · 1 comment · Fixed by #1696
Closed

import.meta.resolve for files #1008

mbostock opened this issue Mar 7, 2024 · 1 comment · Fixed by #1696
Assignees
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented Mar 7, 2024

You can use import.meta.resolve for JavaScript modules, but it’s not currently supported for files (as it assumes that the referenced file is in _import rather than _file). It would be nice as an alternative to FileAttachment(name).url() because it is synchronous, e.g.,

fetch(import.meta.resolve("./data/nyc-taxi.parquet"))

Related #954. Perhaps _import and _file could be combined? But the challenge there is we transpile JavaScript, and hence we want to keep _import and _file separate. 🤔

@Fil
Copy link
Contributor

Fil commented Sep 30, 2024

We can also use FileAttachment(name).href for synchronous resolution, but it's good to have both, especially since import.meta.resolve is a built-in function.

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