-
Notifications
You must be signed in to change notification settings - Fork 84
Add recommended libraries #207
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
Conversation
I don't have an solutions to offer, but having both |
We can’t change the behavior of |
Mutable: () => Mutable, | ||
Plot: () => require("@observablehq/[email protected]/dist/plot.umd.min.js"), | ||
Promises: () => Promises, | ||
_: () => require("[email protected]/lodash.min.js"), |
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.
This one is sort of not-like-the-others in this set. I assume that it is very commonly used and stable in notebooks?
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.
Lodash is the most popular library on npm according to this analysis:
https://gist.github.com/anvaka/8e8fa57c7ee1350e3491
It appears to be referenced in 2.5K public notebooks according to this query:
https://observablehq.com/search?query=lodash
That’s less than Vega (9K) and D3 (10K+), but still quite popular, and I vouch for its quality.
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.
Question regarding evolvability and compatibility: I started out using Ramda because of its elegant “immutable auto-curried iteratee-first data-last methods”. However, including the much more popular lodash
library conveniently and lazily by default urges me to switch to lodash
. Plus, I just learned that there also is lodash/fp
, that enjoys the same feature as Ramda above. Is there a way to include lodash/fp
by default the same way as just lodash
? Or should I fall back to an explicit require?
how much does this increase the size of the bundle? we could add an example to the examples repo showing how to roll your own version-pinning for downloaded notebooks (i.e. the example would just sub in an older or pruned version of stdlib) |
It has a negligible increase in the bundle size because everything is loaded lazily. You only load d3 if you reference it. |
oh wow that's sweet |
To help the user could you add .version systematically? Currently each library has a different method (if at all): https://observablehq.com/@fil/stdlib-recommended-libraries |
Is the current plan to hold out on BC breaking updates for these libraries until Observable supports version pinning out of the box? |
@mootari Yes, we’re only going to accept patch and minor upgrades until Observable supports version pinning. |
This adds a handful of first-party and sanctioned third-party libraries to the Observable standard library for convenient access from notebooks. This set of libraries may grow over time based on demand. The current set is:
d3
- D3.jshtl
- Observable’s Hypertext LiteralInputs
- Observable InputsPlot
- Observable Plot_
- Lodashvl
- Vega-Lite APIIn the last case, some additional code is required based on this notebook.
The trickiest part here is version pinning. I chose to hard-code the versions and paths in the standard library for stability and performance, and in particular to guarantee that duplicate versions of D3 and Hypertext Literal are not loaded: Observable Plot depends on D3, and Observable Inputs depends on Hypertext Literal. A consequence of this choice is that we’ll need to upgrade the Observable standard library explicitly, for everyone, when new versions of these libraries are released. However, when Observable supports version pinning natively in the future, we should be able to relax these requirements and give authors control over which version to use. In the meantime, notebook authors can require the libraries explicitly rather than depending on the standard library if they want to specify the version.