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

Extend the implicit import detection mechanism to inspect the accept field of Inputs.file #1574

Open
yurivish opened this issue Aug 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@yurivish
Copy link

yurivish commented Aug 11, 2024

Framework uses static analysis to detect implicit imports. For example, loading a Parquet file using FileAttachment(...).parquet() will be detected as a dependency on the parquet-wasm package which will then be bundled for distribution and lazily-loaded when the parquet() method is called.

This static analysis is not complete and there are some cases where it succeeds in dev mode but fails in production, since the lazy import can be resolved in dev mode but absent in production since it was not detected by static analysis at build time.

One such case is when Inputs.file is used:

const file = view(Inputs.file({ accept: '.arrow,.parquet' }))
function load(file) {
    return file.parquet()
}
load(file);

This enhancement request is for static analysis to infer dependencies using the the accept option of Inputs.file. File type specifiers are documented here.

I think bundling these potential implicit dependencies by default would be an improvement to the user experience, but it could make sense to make it possible to opt out so that there's a way to keep unused dependencies out of the build (e.g. if a Parquet file picker is present but the user loads it using a different library).

(Thanks to @thinkingfish for the idea, and @mbostock for encouragement to file this issue!)

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

No branches or pull requests

1 participant