Skip to content

Commit 7fdd2d5

Browse files
committed
Provide modules with reference without docs and examples
1 parent 6f74fc5 commit 7fdd2d5

File tree

7 files changed

+55
-3
lines changed

7 files changed

+55
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test/integration/**/test-results.xml
2222
test/integration/dist/**/*.js
2323
test/integration/dist/**/*.json
2424
.eslintcache
25-
src/style-spec/dist/index.cjs
25+
src/style-spec/dist/
2626
_batfish_site
2727
_batfish_tmp
2828
_site

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"build-test-suite": "rollup -c test/integration/rollup.config.test.js",
118118
"build-flow-types": "mkdir -p dist && cp build/mapbox-gl.js.flow dist/mapbox-gl.js.flow && cp build/mapbox-gl.js.flow dist/mapbox-gl-dev.js.flow",
119119
"build-css": "postcss -o dist/mapbox-gl.css src/css/mapbox-gl.css",
120-
"build-style-spec": "cd src/style-spec && npm run build && cd ../.. && mkdir -p dist/style-spec && cp src/style-spec/dist/* dist/style-spec",
120+
"build-style-spec": "cd src/style-spec && npm run build && cd ../.. && mkdir -p dist/style-spec && cp src/style-spec/dist/index.* dist/style-spec",
121121
"watch-css": "postcss --watch -o dist/mapbox-gl.css src/css/mapbox-gl.css",
122122
"build-token": "node build/generate-access-token-script.js",
123123
"build-benchmarks": "BENCHMARK_VERSION=${BENCHMARK_VERSION:-\"$(git rev-parse --abbrev-ref HEAD) $(git rev-parse --short=7 HEAD)\"} rollup -c bench/versions/rollup_config_benchmarks.js",

src/style-spec/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ package so that they can be installed without the bulk of GL JS.
99

1010
npm install @mapbox/mapbox-gl-style-spec
1111

12+
In addition to ESM and CJS bundles, the package also provides separate modules. The difference between the bundles and the modules is that the modules use a minified version of the `latest` style refererence, which does not contain any `doc` and `example` fields. See the `exports` section of `package.json` for available modules.
13+
1214
## CLI Tools
1315

1416
If you install this package globally, you will have access to several CLI tools.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {readFileSync, writeFileSync} from 'fs';
2+
const fullSpecJson = readFileSync('./reference/v8.json', 'utf8');
3+
const minifiedSpec = JSON.parse(fullSpecJson, (key, value) => ['doc', 'example'].includes(key) ? undefined : value);
4+
writeFileSync('./dist/reference/v8.json', JSON.stringify(minifiedSpec), 'utf8');
5+

src/style-spec/expression/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,5 @@ function getDefaultValue(spec: StylePropertySpecification): Value {
397397
return spec.default;
398398
}
399399
}
400+
401+
export {isExpressionFilter} from '../feature_filter/index.js';

src/style-spec/function/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,5 @@ function interpolationFactor(input, base, lowerValue, upperValue) {
260260
return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
261261
}
262262
}
263+
264+
export {default as convertFunction} from './convert.js';

src/style-spec/package.json

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,56 @@
1717
"require": "./dist/index.cjs",
1818
"import": "./dist/index.es.js"
1919
},
20+
"./v8": "./src/reference/v8.json",
21+
"./v8.min": "./dist/reference/v8.json",
22+
"./latest": "./dist/reference/latest.js",
23+
"./format": "./dist/format.js",
24+
"./migrate": "./dist/migrate.js",
25+
"./composite": "./dist/composite.js",
26+
"./derefLayers": "./dist/deref.js",
27+
"./diff": "./dist/diff.js",
28+
"./ValidationError": "./dist/error/validation_error.js",
29+
"./ParsingError": "./dist/error/parsing_error.js",
30+
"./expression": "./dist/expression/index.js",
31+
"./featureFilter": "./dist/feature_filter/index.js",
32+
"./convertFilter": "./dist/feature_filter/convert.js",
33+
"./Color": "./dist/util/color.js",
34+
"./function": "./dist/function/index.js",
35+
"./validate": "./dist/validate_style.js",
36+
"./validateMapboxApiSupported": "./dist/validate_mapbox_api_supported.js",
37+
"./visit": "./dist/visit.js",
2038
"./": {
2139
"import": "./"
2240
}
2341
},
42+
"typesVersions": {
43+
"*": {
44+
"latest": ["dist/reference/latest.js"],
45+
"format": ["dist/format.js"],
46+
"migrate": ["dist/migrate.js"],
47+
"composite": ["dist/composite.js"],
48+
"derefLayers": ["dist/deref.js"],
49+
"diff": ["dist/diff.js"],
50+
"ValidationError": ["dist/error/validation_error.js"],
51+
"ParsingError": ["dist/error/parsing_error.js"],
52+
"expression": ["dist/expression/index.js"],
53+
"featureFilter": ["dist/feature_filter/index.js"],
54+
"convertFilter": ["dist/feature_filter/convert.js"],
55+
"Color": ["dist/util/color.js"],
56+
"function": ["dist/function/index.js"],
57+
"validate": ["dist/validate_style.js"],
58+
"validateMapboxApiSupported": ["dist/validate_mapbox_api_supported.js"],
59+
"visit": ["dist/visit.js"]
60+
}
61+
},
62+
"browser": {
63+
"assert": false
64+
},
2465
"scripts": {
2566
"pretest": "npm run build",
2667
"test": "node ./test.js",
2768
"copy-flow-typed": "cp -R ../../flow-typed .",
28-
"build": "../../node_modules/.bin/rollup -c && ../../node_modules/.bin/rollup -c --environment esm",
69+
"build": "../../node_modules/.bin/rollup -c && ../../node_modules/.bin/rollup -c --environment esm && flow-remove-types ./ --ignore \"(node_modules|bin|build|dist)\" --out-dir dist/ && node copy-minified-spec.js",
2970
"prepublishOnly": "npm run copy-flow-typed && npm run build",
3071
"postpublish": "rm -r flow-typed dist/index.cjs"
3172
},

0 commit comments

Comments
 (0)