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

Add an unminified production build to the NPM package #7403

Merged
merged 3 commits into from
Oct 17, 2018

Conversation

mourner
Copy link
Member

@mourner mourner commented Oct 11, 2018

Provides an alternative build in the published NPM package which is like the production build but unminified (e.g. for use with custom minifiers).

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs not sure if we should document anywhere
  • post benchmark scores
  • manually test the debug page

@mourner mourner requested review from kkaefer and ansis October 11, 2018 14:28
package.json Outdated
@@ -110,6 +110,7 @@
"scripts": {
"build-dev": "rollup -c --environment BUILD:dev",
"watch-dev": "rollup -c --environment BUILD:dev --watch",
"build-alt": "rollup -c --environment BUILD:production-unminified",
Copy link
Member

Choose a reason for hiding this comment

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

why build-alt?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just a short name for the package script (which shouldn't be called directly anyway), "alternative" build. Didn't want to name it build-production-unminified.

rollup.config.js Outdated
const outputFile = production ? 'dist/mapbox-gl.js' : 'dist/mapbox-gl-dev.js';
const {BUILD} = process.env;
const minified = BUILD === 'production';
const production = BUILD === 'production' || BUILD === 'production-unminified';
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the conflation of debug/release and minification? We could have two separate variables: BUILD controls dev vs. release, while UGLIFY (defaulting to true) controls minification

@mourner mourner requested a review from kkaefer October 11, 2018 15:27
@mourner
Copy link
Member Author

mourner commented Oct 11, 2018

@kkaefer addressed your comments.

@mourner mourner force-pushed the build-prod-unminified branch from 8936d97 to 30a842c Compare October 11, 2018 15:30
rollup.config.js Outdated
const production = BUILD === 'production';
const outputFile =
production && minified ? 'dist/mapbox-gl.js' :
production ? 'dist/mapbox-gl-unminified.js' : 'dist/mapbox-gl-dev.js';
Copy link
Member

Choose a reason for hiding this comment

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

This still doesn't account for the matrix of BUILD/MINIFY yet :) How about

const suffix = (production ? '' : '-dev') + (minified ? '' : '-unminified');
const outputFile = 'dist/mapbox-gl' + suffix + '.js';

Copy link
Member Author

Choose a reason for hiding this comment

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

@kkaefer I wouldn't want to change names of existing builds. This suggestion would rename mapbox-gl-dev.js to mapbox-gl-dev-unminified.js.

Copy link
Member

Choose a reason for hiding this comment

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

Let's reverse the MINIFY flag and default to true, then specify MINIFY:false for the non-minified production build

Copy link
Member Author

Choose a reason for hiding this comment

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

@kkaefer and rename the current mapbox-gl.js build to mapbox-gl-min.js?

Copy link
Member

Choose a reason for hiding this comment

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

No, the suffix only gets added for unminified builds

Copy link
Member Author

Choose a reason for hiding this comment

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

@kkaefer so it would still be mapbox-gl-dev-unminified.js? I'm confused.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the confusion; I didn't realize that the dev version is unminified. What I was trying to get at is that we have 4 possible combinations of BUILD and MINIFY, but we're only producing 3 different file names; the one for BUILD:development,MINIFY:true produces the same output file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since it doesn't make sense to have a minified dev build anyway, I don't think we need to worry about it. I added another commit that hopefully makes build naming logic clearer. Feel free to add any changes you feel are needed here and I'll review, and otherwise we can merge.

@mourner mourner merged commit 03f8775 into master Oct 17, 2018
@mourner mourner deleted the build-prod-unminified branch October 17, 2018 11:18
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.

2 participants