-
Notifications
You must be signed in to change notification settings - Fork 89
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
Technique example: data loader, R to ZIP #1423
Conversation
The error in build comes from using this two-step strategy to load the file:
Framework is not smart enough here to know that it will need d3-dsv, and does not include it by default. (This is arguably a bug in Framework, in the sense that it builds an incomplete stdlib—maybe we should preventively build all the methods that stdlib might need?) The most natural way to solve this for the example page is to rewrite that paragraph as: -You can then access individual files (estimates.csv, or predictions.csv) from the ZIP archive:
+Or access individual files (`estimates.csv`, or `predictions.csv`):
```js echo
-const modelEstimates = modelZip.file("estimates.csv").csv({typed: true});
+const modelEstimates = FileAttachment("data/penguin-mlr/estimates.csv").csv({typed: true});
``` which I think conveys the intended use of zip files better. Another way to fix is to make an explicit import of d3-dsv, even an empty one:
but it does feel weird. |
You can shorten that to import "npm:d3-dsv"; but you should use the automatic unpacking of the .csv and not load the .zip in the client anyway. You should only load a .zip in the client if you want to do something “dynamic” with the contents (in which case you can’t benefit from static analysis). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a bit harsh to give a model without a chart, but that's up to you :)
I added two nits
Co-authored-by: Philippe Rivière <fil@rezo.net>
Co-authored-by: Philippe Rivière <fil@rezo.net>
Deployed: https://observablehq.observablehq.cloud/framework-example-loader-r-to-zip/