Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Adding minified files to dist packages #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cjwainwright
Copy link
Owner

The "dist" bundle packages (e.g. https://www.npmjs.com/package/plotly.js-dist) currently only include un-minified JavaScript. This PR is to include the minified version of the same "dist" file alongside this in the package.

It is common to import packages via npm but not have a minification step in your own build process. It is therefore helpful to have the minified version of the files included in the package.

@cjwainwright
Copy link
Owner Author

@alexcjohnson @etpinard @antoinerg @archmoj Wondered if you’d take a look at this PR to include minified files in the dist packages. See also this comment here scijs/cwise#25 (comment)

@etpinard
Copy link

Thanks very much for making a PR @cjwainwright. Your patch looks good.

Now, here are the 👍 / 👎

👍

  • This PR would allow users to
    • npm i plotly.js-*dist
    • use node_modules/plotly.js-*dist/plotly-*.min.js
    • ... with no extra work

👎

  • This PR would increase the size of our plotly.js "dist" package by 30 to 50 percent (numbers taken from the plotly.js dist README) with arguably "duplicate" code.

Potential alternatives:

  • npm i plotly.js and use dist/plotly.min.js
    • but this downloads the flagged cwise package, some folks will find that bad even if they don't bundle their own code.
  • npm i plotly.js-*dist and minify node_modules/plotly.js-*dist/plotly-*.js
    • but not everyone will want to install a minifier
  • download the minified bundles from our CDN e.g. https://cdn.plot.ly/plotly-basic-latest.js
    • but some people want to use npm to install all their deps
  • publish "dist min" package to the npm registry, that is all our "dist" packages would have a "dist min" equivalent so that users could then e.g. npm i plotly.js-basic-dist-min

@archmoj
Copy link

archmoj commented Jul 25, 2019

Thanks @cjwainwright for the PR.
I was wondering if we could select only a few of those partial bundles, for example plotly.js-dist & plotly.js-gl3d-dist?

@cjwainwright
Copy link
Owner Author

Thank you for the feedback.

@etpinard Creating separate "dist min" packages sounds like the best approach, satisfying both the package size problem and allowing npm install of the min files. I can look at updating this to do that, unless you foresee any other issues with that?

@archmoj Can you explain why you would only include min files for some of the bundles? Would creating separate min packages be a good alternative from your perspective.

@etpinard
Copy link

etpinard commented Jul 26, 2019

The debate is still on between

  • adding min.js files to the current "dist" packages, and
  • publishing new "dist min" packages

We'll make a decision before the 1.50.0 release, which is scheduled for late August.

@cjwainwright
Copy link
Owner Author

@etpinard @archmoj Was there any decision made about distributing minified files in dist packages yet? Thanks!

@etpinard
Copy link

etpinard commented Sep 5, 2019

@cjwainwright

We decided on this option:

  • publish "dist min" package to the npm registry, that is all our "dist" packages would have a "dist min" equivalent so that users could then e.g. npm i plotly.js-basic-dist-min

Would you be interesting in trying to make a PR?

@etpinard
Copy link

etpinard commented Sep 5, 2019

(and note 1.50.0 has been pushed back)

@cjwainwright
Copy link
Owner Author

@etpinard OK, great thanks. I had already made a PR on my fork for this (#2), if you're ok with that code I can look to make it as a PR back to the plotly repository.

@etpinard
Copy link

etpinard commented Sep 6, 2019

Thanks @cjwainwright - your patch looks good.


We should add some info about the new partial "dist min" bundles to

https://github.com/plotly/plotly.js/blob/master/dist/README.md

generated by

https://github.com/plotly/plotly.js/blob/master/tasks/stats.js

Maybe below line

https://github.com/plotly/plotly.js/blob/240334eb51f9abfa0237aadcae90f1d47b10a92a/tasks/stats.js#L145

we could have:

Starting in `v1.50.0`, partial dist "min" packages are also published to npm.

and maybe below line

https://github.com/plotly/plotly.js/blob/240334eb51f9abfa0237aadcae90f1d47b10a92a/tasks/stats.js#L210

we could have

### dist min npm package (starting in `v1.50.0`)
        '',
        'Install [`' + pkgName + '-dist`](https://www.npmjs.com/package/' + pkgName + '-dist) with',
        '```',
        'npm install ' + pkgName + '-dist',
        '```',

What do you think?

@cjwainwright
Copy link
Owner Author

@etpinard Sounds good, I can add those. I was thinking of making the wording a little more descriptive for the first part, maybe:

Starting in v1.50.0, the minified version of each partial bundle is also published to npm in a separate "dist min" package.

Does that sound ok?

@etpinard
Copy link

etpinard commented Sep 6, 2019

Starting in v1.50.0, the minified version of each partial bundle is also published to npm in a separate "dist min" package.

Yep, that's better than my attempt. Thanks!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants