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 7fdd2d5
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 3 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
2 changes: 2 additions & 0 deletions src/style-spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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';
43 changes: 42 additions & 1 deletion src/style-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,56 @@
"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": "./"
}
},
"typesVersions": {
"*": {
"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"]
}
},
"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 7fdd2d5

Please sign in to comment.