-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
NPM pkg for dist bundles #2670
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
NPM pkg for dist bundles #2670
Conversation
- these sub-pkg are made in build/ - they all include a (minimal) README and package.json - at the moment, they include only one un-minified bundle file
TODO:
|
IMO no need to add minified versions. The main advantage I see for these packages is for people to import plotly.js in a more friendly way into their build systems like webpack and friends. In my experience, it's unhelpful to load minified files into such systems as it messes with their downstream minification. |
More generally I'm a huge fan of this PR :) |
Slick! As to the questions about Incidentally, I was just chatting with @etpinard about our 4-year-old mathjax version - we're using 2.3, they're up to 2.7.4. Presumably a drop-in replacement since it's still 2.x, though we may change how we package it due to the npm package. We could make a separate issue for this, but perhaps the upgrade should be this PR, regardless of whether it's going to be included in the dist packages or not... if it is included people may start to wonder why it's so old, if not they'll be including the current version anyway (or at least one they can get from npm, which started at 2.5.1) so we'd better make sure it works! |
We could alternatively add a |
I would vote in favor of minified bundles if it's not too much overhead. It'd be much easier for me to leverage partial bundles in the R package that way. |
(no objections to minified bundles if it's helpful for the R world!) |
Just curious @cpsievert, why would an npm package be easier for you than downloading the |
@etpinard do we publish minified partials to the cdn (e.g., https://cdn.plot.ly/plotly-basic.min.js doesn't exist)? I don't currently leverage partial builds in R, and I could do it via github releases, but it'd be nice to have a lighter-weight approach. I also recently created this R package to make it easy to leverage unpkg from R https://github.com/cpsievert/runpkg |
yes -> https://cdn.plot.ly/plotly-basic-latest.min.js or https://cdn.plot.ly/plotly-basic-1.38.1.min.js |
All you want to know about partial bundles is here -> https://github.com/plotly/plotly.js/tree/master/dist#plotlyjs-basic |
Ahhh, ok, I'll use the CDN then, sorry for the noise! |
- factor up findModuleList from stats.js, to list which trace modules are included - fixup cb when build/* exist - add DRYRUN env var, to skip `npm publish`
... and refactor "Quick start options" section. List CDN first, plotly.js-dist 2nd and github release 3rd
Reviewers, if you'll like to see what
|
BUILDING.md
Outdated
@@ -1,5 +1,7 @@ | |||
# Building plotly.js | |||
|
|||
The easiest way to bundle plotly.js into your application is to use the one of the distributed plotly.js packages on npm. These distributed packages should just work with **any** build framework. That said, if you're looking to save a few bytes, read the section below corresponding to your building framework. |
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.
use the one of the distributed...
Do you want to include a link that points to a list of these modules on npm? I guess we can add that later once it actually exists ;)
README.md
Outdated
|
||
#### Install with `npm` | ||
|
||
```bash | ||
npm install plotly.js | ||
npm install plotly.js-dist |
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.
Can we please move this up above the CDN option?
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.
Personally, using the CDN is still the "quickest" way to start using plotly.js (hence its first spot in the "Quick start options" section), but ok.
README.md
Outdated
|
||
If you would like to manually pick which plotly.js modules to include, you can create a *custom* bundle by using `plotly.js/lib/core`, and loading only the trace types that you need (e.g. `pie` or `choropleth`). The recommended way to do this is by creating a *bundling file*: | ||
If you would like to manually pick which plotly.js modules to include, you'll first need to run `npm install plotly.js` and then create a *custom* bundle by using `plotly.js/lib/core`, and loading only the trace types that you need (e.g. `pie` or `choropleth`). The recommended way to do this is by creating a *bundling file*. For example, in CommonJS: |
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.
I might prefix this with something like "If none of the distributed NPM packages meet your needs, and you would like to..." to encourage people to go with the flow :)
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.
I think we should encourage people that want to save bytes to save bytes, but ok.
Like their READMEs e.g.: |
Re the README how are you telling NPM that it should use that readme instead of the main one? AFAIK it just grabs the readme from the |
Oh really? I thought it grabbed the package.json from where we run |
Thanks for bringing this up @nicolaskruchten ! We have to list the files manually in this case, like |
Are there any plans to get this merged in and released? |
Yes, it's ready to go but because it will result in substantial changes to the documentation we want to merge it immediately before releasing v1.39.0. That should happen within the next week. |
resolves #2400
A new
sync_pacakges.js
script assembles "sub plotly.js packages" in the git-ignoredbuild/
folder that include a minimal package.json and README.md as well as one single "bundle" file. Along with the main dist/plotly.js bundle, each partial bundle has it own "sub plotly.js package".After running,
node tasks/sync_pacakges.js
, we get:A sample package.json looks like:
and a sample README.md looks like:
Some questions left to answer:
dist/topojson/
to all sub packages?dist/extras/mathjax/
? Should we include it too?@nicolaskruchten what do you think?