Skip to content

Commit

Permalink
Provide modules with reference without docs and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Mar 23, 2022
1 parent 6f74fc5 commit f47b20d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test/integration/**/test-results.xml
test/integration/dist/**/*.js
test/integration/dist/**/*.json
.eslintcache
src/style-spec/dist/index.cjs
src/style-spec/dist/
_batfish_site
_batfish_tmp
_site
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"build-test-suite": "rollup -c test/integration/rollup.config.test.js",
"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",
"build-css": "postcss -o dist/mapbox-gl.css src/css/mapbox-gl.css",
"build-style-spec": "cd src/style-spec && npm run build && cd ../.. && mkdir -p dist/style-spec && cp src/style-spec/dist/* dist/style-spec",
"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",
"watch-css": "postcss --watch -o dist/mapbox-gl.css src/css/mapbox-gl.css",
"build-token": "node build/generate-access-token-script.js",
"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",
Expand Down
4 changes: 4 additions & 0 deletions src/style-spec/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Mapbox GL style specification & utilities

This package is a temporary, source code identical fork of [@mapbox/mapbox-gl-style-spec](https://npmjs.com/package/@mapbox/mapbox-gl-style-spec), maintained by OpenLayers contributors. It provides separate exports for all of its modules, and a style spec without docs and examples to reduce build sizes. When [#11628](https://github.com/mapbox/mapbox-gl-js/pull/11628) is merged, this package will be obsolete.

This directory contains code and reference files that define the Mapbox GL style specification and provides some utilities for working with Mapbox styles.

## npm package
Expand All @@ -9,6 +11,8 @@ package so that they can be installed without the bulk of GL JS.

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

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.

## CLI Tools

If you install this package globally, you will have access to several CLI tools.
Expand Down
5 changes: 5 additions & 0 deletions src/style-spec/copy-minified-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {readFileSync, writeFileSync} from 'fs';
const fullSpecJson = readFileSync('./reference/v8.json', 'utf8');
const minifiedSpec = JSON.parse(fullSpecJson, (key, value) => ['doc', 'example'].includes(key) ? undefined : value);
writeFileSync('./dist/reference/v8.json', JSON.stringify(minifiedSpec), 'utf8');

2 changes: 2 additions & 0 deletions src/style-spec/expression/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,5 @@ function getDefaultValue(spec: StylePropertySpecification): Value {
return spec.default;
}
}

export {isExpressionFilter} from '../feature_filter/index.js';
2 changes: 2 additions & 0 deletions src/style-spec/function/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,5 @@ function interpolationFactor(input, base, lowerValue, upperValue) {
return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
}
}

export {default as convertFunction} from './convert.js';
25 changes: 23 additions & 2 deletions src/style-spec/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@mapbox/mapbox-gl-style-spec",
"name": "@openlayers/mapbox-gl-style-spec",
"description": "a specification for mapbox gl styles",
"version": "13.24.0-alpha.6",
"author": "Mapbox",
Expand All @@ -17,15 +17,36 @@
"require": "./dist/index.cjs",
"import": "./dist/index.es.js"
},
"./v8": "./src/reference/v8.json",
"./v8.min": "./dist/reference/v8.json",
"./latest": "./dist/reference/latest.js",
"./format": "./dist/format.js",
"./migrate": "./dist/migrate.js",
"./composite": "./dist/composite.js",
"./derefLayers": "./dist/deref.js",
"./diff": "./dist/diff.js",
"./ValidationError": "./dist/error/validation_error.js",
"./ParsingError": "./dist/error/parsing_error.js",
"./expression": "./dist/expression/index.js",
"./featureFilter": "./dist/feature_filter/index.js",
"./convertFilter": "./dist/feature_filter/convert.js",
"./Color": "./dist/util/color.js",
"./function": "./dist/function/index.js",
"./validate": "./dist/validate_style.js",
"./validateMapboxApiSupported": "./dist/validate_mapbox_api_supported.js",
"./visit": "./dist/visit.js",
"./": {
"import": "./"
}
},
"browser": {
"assert": false
},
"scripts": {
"pretest": "npm run build",
"test": "node ./test.js",
"copy-flow-typed": "cp -R ../../flow-typed .",
"build": "../../node_modules/.bin/rollup -c && ../../node_modules/.bin/rollup -c --environment esm",
"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",
"prepublishOnly": "npm run copy-flow-typed && npm run build",
"postpublish": "rm -r flow-typed dist/index.cjs"
},
Expand Down

0 comments on commit f47b20d

Please sign in to comment.