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

Enable compress attributes browserify transform by default #1584

Merged
merged 6 commits into from
Sep 10, 2018

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Apr 11, 2017

as discussed in rreusser/plotly-mock-viewer#5 (comment), we should really be compressing our attribute declarations in all browserify builds by default - to make sure that customs bundles don't include (useless) attribute description strings.

Note that, using the ignoreTransform browserify options with can still produce dist/plotly-with-meta.js as before.

TODO:

  • In this PR, I'm referring to the compress_attributes.js transform using a relative (UNIX) path. We should make sure that this works also on Windows machines before merging. If that doesn't work we can always publish compress_attributes.js on npm and refer to it as a dependency in node_modules/ like we currently do for glslify.
  • move the plotschema_test.js suite to bundle_tests/ and make it use plotly-with-meta.js

cc @rreusser

Sorry, something went wrong.

- so that it is enabled by default on browserify builds
- mv it to `./tasks/` for better discoveribility
- ignore it when bundling plotly-with-meta.js bundle
- 🔪 other refs to compress_attributes.js
@rreusser
Copy link
Contributor

Apologies I missed in the first place, but I wholeheartedly support this. The only exception would be if it makes it difficult to compile with metadata. So my question is: how do you compile with metadata when this is present?

@rreusser
Copy link
Contributor

Oh, just saw linked comment:

--ignore-transform=MODULE

browserifyOpts.transform = outputMinified ? [compressAttributes] : [];

if(opts.noCompress) {
browserifyOpts.ignoreTransform = './tasks/compress_attributes.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 This seems better by default, and tasks/ seems like a better location than tasks/util

@@ -6,7 +6,6 @@ var prettySize = require('prettysize');

var constants = require('./constants');
var common = require('./common');
var compressAttributes = require('./compress_attributes');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that this just disappears. Opt-opt also scopes the transform better so it doesn't need to be applied globally 👍

tasks/bundle.js Outdated
@@ -41,7 +41,8 @@ _bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist,
// Browserify the plotly.js with meta
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, {
standalone: 'Plotly',
debug: DEV
debug: DEV,
noCompress: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@rreusser
Copy link
Contributor

rreusser commented Sep 21, 2017

Apologies I didn't leave more meaningful feedback the first time around. This definitely seems like a good idea. It's really the exception rather than the norm that you'd even want the extra metadata. It looks like it needs a quick refresh to resolve a conflict or two, but assuming that's just trivial merging, it gets the 💃 from me.

Edit: and pending windows check.

@etpinard
Copy link
Contributor Author

Can anyone with a window laptop try running npm run build off this branch? I'm a little worried about this line which uses a UNIX-style path.

Maybe @dfcreative could help.

@etpinard
Copy link
Contributor Author

Ping @antoinerg (who has access to a Windows "dev" 💻 )

Could you pull down this branch and run npm run build to check that the added UNIX-style path to a browserify transform in our package.json works ok on Windows?

To check that things work:

  • npm run build, then
  • grep "description:" dist/plotly.js (or some windows equivalent) should output:
    return Lib.extendFlat({}, attributes, { description: description });
 *     extra.description: extra description. N.B we use
 *     opts.description: where & how this font is used

i.e. only three occurrences of description:

  • and grep "description:" dist/plotly-with-meta.js | wc -l should be 973 (i.e. 973 lines with description: in it)

Thanks!

@antoinerg
Copy link
Contributor

antoinerg commented Sep 10, 2018

@etpinard: I confirm that things work on my Windows 10 machine 🎉

@etpinard
Copy link
Contributor Author

Fantastic!

Attribute meta will be stripped out of bundles (made with bundlers that support browserify transforms) by default starting in v1.41.0!

@etpinard etpinard merged commit 1b6c9a3 into master Sep 10, 2018
@etpinard etpinard deleted the compress-attr-transform-by-default branch September 10, 2018 18:59
etpinard added a commit to rreusser/plotly-mock-viewer that referenced this pull request Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants