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

Provide an es modules build in dist/ for mapbox-gl-style-spec #8247

Merged
merged 1 commit into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/dist/
/docs/pages/dist/
/docs/img/dist/
*.es.js
*.js.map
node_modules
package-lock.json
Expand Down
6 changes: 4 additions & 2 deletions src/style-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
],
"license": "ISC",
"main": "./dist/index.js",
"module": "./dist/index.es.js",
"scripts": {
"copy-flow-typed": "cp -R ../../flow-typed .",
"build": "../../node_modules/.bin/rollup -c",
"build": "../../node_modules/.bin/rollup -c && ../../node_modules/.bin/rollup -c --environment esm",
"prepublish": "yarn copy-flow-typed && yarn build",
"postpublish": "rm -r flow-typed dist/index.js"
},
Expand All @@ -34,5 +35,6 @@
"minimist": "0.0.8",
"rw": "^1.3.3",
"sort-object": "^0.3.2"
}
},
"sideEffects": false
}
14 changes: 11 additions & 3 deletions src/style-spec/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ import unassert from 'rollup-plugin-unassert';
import json from 'rollup-plugin-json';
import {flow} from '../../build/rollup_plugins';

// Build es modules?
const esm = 'esm' in process.env;

const transforms = {
dangerousForOf: true,
modules: esm ? false : undefined
};

const config = [{
input: `${__dirname}/style-spec.js`,
output: {
name: 'mapboxGlStyleSpecification',
file: `${__dirname}/dist/index.js`,
format: 'umd',
file: `${__dirname}/dist/${esm ? 'index.es.js' : 'index.js'}`,
format: esm ? 'esm' : 'umd',
sourcemap: true
},
plugins: [
Expand All @@ -25,7 +33,7 @@ const config = [{
}),
flow(),
json(),
buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}),
buble({transforms, objectAssign: "Object.assign"}),
unassert(),
resolve({
browser: true,
Expand Down