-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anand Thakker
committed
Feb 22, 2018
1 parent
ed695ab
commit 4a30c29
Showing
9 changed files
with
1,913 additions
and
1,871 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/src_untyped | ||
/rollup/build/ | ||
/docs/components/api.json | ||
/dist/mapbox-gl-dev.js | ||
/dist/mapbox-gl.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
function replacer(k, v) { | ||
return (k === 'doc' || k === 'example' || k === 'sdk-support') ? undefined : v; | ||
} | ||
|
||
export default function minifyStyleSpec() { | ||
return { | ||
name: 'minify-style-spec', | ||
transform: (source, id) => { | ||
if (!/style\-spec[\\/]reference[\\/]v[0-9]+\.json$/.test(id)) { | ||
return; | ||
} | ||
|
||
return { | ||
code: JSON.stringify(JSON.parse(source), replacer, 0), | ||
map: {mappings: ''} | ||
}; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import flow from 'rollup-plugin-flow'; | ||
import buble from 'rollup-plugin-buble'; | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import unassert from 'rollup-plugin-unassert'; | ||
import json from 'rollup-plugin-json'; | ||
import browserifyPlugin from 'rollup-plugin-browserify-transform'; | ||
import brfs from 'brfs'; | ||
import uglify from 'rollup-plugin-uglify' | ||
import minifyStyleSpec from './build/rollup_plugin_minify_style_spec'; | ||
|
||
const production = process.env.BUILD === 'production'; | ||
const outputFile = production ? 'dist/mapbox-gl.js' : 'dist/mapbox-gl-dev.js'; | ||
|
||
const plugins = [ | ||
flow(), | ||
minifyStyleSpec(), | ||
json(), | ||
buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}), | ||
unassert(), | ||
resolve({ | ||
browser: true, | ||
preferBuiltins: false | ||
}), | ||
browserifyPlugin(brfs, { | ||
include: 'src/shaders/index.js' | ||
}), | ||
commonjs({ | ||
namedExports: { | ||
'@mapbox/gl-matrix': ['vec3', 'vec4', 'mat2', 'mat3', 'mat4'] | ||
} | ||
}) | ||
] | ||
|
||
if (production) { | ||
plugins.push(uglify()); | ||
} | ||
|
||
const config = [{ | ||
input: ['src/index.js', 'src/source/worker.js'], | ||
output: { | ||
name: 'mapboxgl', | ||
dir: 'rollup/build', | ||
format: 'amd', | ||
sourcemap: 'inline' | ||
}, | ||
experimentalCodeSplitting: true, | ||
plugins | ||
}, { | ||
input: 'rollup/main.js', | ||
output: { | ||
name: 'mapboxgl', | ||
file: outputFile, | ||
format: 'umd', | ||
sourcemap: production ? true : 'inline' | ||
}, | ||
plugins: production ? [] : [uglify()], | ||
intro: ` | ||
let shared, worker, mapboxgl; | ||
function define(_, module) { | ||
if (!shared) { | ||
shared = module; | ||
} else if (!worker) { | ||
worker = module; | ||
} else { | ||
const workerBundleString = 'const sharedModule = {}; (' + shared + ')(sharedModule); (' + worker + ')(sharedModule);' | ||
const sharedModule = {}; | ||
shared(sharedModule); | ||
mapboxgl = module(sharedModule); | ||
mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' })); | ||
} | ||
} | ||
` | ||
}]; | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import './build/chunk1'; | ||
import './build/worker'; | ||
import './build/index'; | ||
|
||
export default mapboxgl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.