Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/style-spec/feature_filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {createExpression} from '../expression/index.js';
import {isFeatureConstant} from '../expression/is_constant.js';
import {deepUnbundle} from '../util/unbundle_jsonlint.js';
import latest from '../reference/latest.js';
import {min as latest} from '../reference/latest.js';
import type {GlobalProperties, Feature} from '../expression/index.js';
import type {CanonicalTileID} from '../../source/tile_id.js';
import type Point from '@mapbox/point-geometry';
Expand Down
7 changes: 4 additions & 3 deletions src/style-spec/reference/latest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow

import spec from './v8.json';
import * as spec from './v8.json';

export type StyleReference = typeof spec;
export type StyleReference = typeof spec.default;

export default spec;
export default spec.default;
export const min = spec.default;
30 changes: 28 additions & 2 deletions src/style-spec/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import replace from '@rollup/plugin-replace';
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 {flow} from '../../build/rollup_plugins.js';

// Build es modules?
Expand All @@ -12,6 +11,8 @@ const esm = 'esm' in process.env;
import {fileURLToPath} from 'url';
const __dirname = fileURLToPath(new URL('.', import.meta.url));

const reviver = (key, value) => ['doc', 'example', 'sdk-support'].includes(key) ? undefined : value;

const config = [{
input: `${__dirname}/style-spec.js`,
output: {
Expand Down Expand Up @@ -46,8 +47,33 @@ const config = [{
'_token_stack:': ''
}
}),
replace({
include: /\/reference\/latest\.js$/,
delimiters: ['', ''],
values: {
'export const min = spec.default': 'export const min = spec.min'
}
}),
flow(),
json(),
{
name: 'json-min',
transform(code, id) {
if (id.endsWith('.json')) {
const json = JSON.parse(code);
const min = JSON.stringify(json, reviver);
const full = JSON.stringify(json);
code = `export default ${full}`;
if (min !== full) {
code += `\nexport const min = ${min}`;
}
return {
code,
map: null
};
}
return null;
}
},
unassert(),
resolve({
browser: true,
Expand Down
3 changes: 2 additions & 1 deletion src/style-spec/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type StylePropertySpecification = {
};

import v8 from './reference/v8.json';
import latest from './reference/latest.js';
import latest, {min as specMin} from './reference/latest.js';
import format from './format.js';
import migrate from './migrate.js';
import composite from './composite.js';
Expand Down Expand Up @@ -109,6 +109,7 @@ const visit = {eachSource, eachLayer, eachProperty};
export {
v8,
latest,
specMin,
format,
migrate,
composite,
Expand Down