Skip to content

Commit

Permalink
Adding a new build Bench to be used in benchmarks (internal-241)
Browse files Browse the repository at this point in the history
* Adding a new build `Bench` to be used in benchmarks

* Adding minify to the Bench build
  • Loading branch information
sgolbabaei authored and karimnaaji committed Dec 8, 2020
1 parent ddf3e9d commit 167a043
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build/rollup_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import replace from 'rollup-plugin-replace';
// Common set of plugins/transformations shared across different rollup
// builds (main mapboxgl bundle, style-spec package, benchmarks bundle)

export const plugins = (minified, production, test) => [
export const plugins = (minified, production, test, bench) => [
flow(),
minifyStyleSpec(),
json(),
production ? strip({
sourceMap: true,
functions: ['PerformanceUtils.*', 'Debug.*']
}) : false,
production || bench ? unassert() : false,
test ? replace({
'process.env.CI': JSON.stringify(process.env.CI),
'process.env.UPDATE': JSON.stringify(process.env.UPDATE)
Expand All @@ -34,7 +35,6 @@ export const plugins = (minified, production, test) => [
passes: 3
}
}) : false,
production ? unassert() : false,
resolve({
browser: true,
preferBuiltins: false
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"scripts": {
"build-dev": "rollup -c --environment BUILD:dev",
"watch-dev": "rollup -c --environment BUILD:dev --watch",
"build-bench": "rollup -c --environment BUILD:bench,MINIFY:true",
"build-prod": "rollup -c --environment BUILD:production",
"build-prod-min": "rollup -c --environment BUILD:production,MINIFY:true",
"build-csp": "rollup -c rollup.config.csp.js",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config = (input, file, format) => ({
banner
},
treeshake: true,
plugins: plugins(true, true)
plugins: plugins(true, true, false)
});

export default [
Expand Down
21 changes: 17 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,22 @@ import banner from './build/banner';
const {BUILD, MINIFY} = process.env;
const minified = MINIFY === 'true';
const production = BUILD === 'production';
const outputFile =
!production ? 'dist/mapbox-gl-dev.js' :
minified ? 'dist/mapbox-gl.js' : 'dist/mapbox-gl-unminified.js';
const bench = BUILD === 'bench';

function buildType(build, minified) {
switch (build) {
case 'production':
if (minified) return 'dist/mapbox-gl.js';
return 'dist/mapbox-gl-unminified.js';
case 'bench':
return 'dist/mapbox-gl-bench.js';
case 'dev':
return 'dist/mapbox-gl-dev.js';
default:
return 'dist/mapbox-gl-dev.js';
}
}
const outputFile = buildType(BUILD, MINIFY);

export default [{
// First, use code splitting to bundle GL JS into three "chunks":
Expand All @@ -28,7 +41,7 @@ export default [{
chunkFileNames: 'shared.js'
},
treeshake: production,
plugins: plugins(minified, production)
plugins: plugins(minified, production, false, bench)
}, {
// Next, bundle together the three "chunks" produced in the previous pass
// into a single, final bundle. See rollup/bundle_prelude.js and
Expand Down

0 comments on commit 167a043

Please sign in to comment.