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

Use named exports in style-spec.js #6602

Merged
merged 1 commit into from
May 3, 2018
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"watch-dev": "rollup -c --environment BUILD:dev --watch",
"build-min": "rollup -c --environment BUILD:production",
"build-css": "postcss -o dist/mapbox-gl.css src/css/mapbox-gl.css",
"build-style-spec": "cd src/style-spec && npm run build && cd ../.. && cp -R 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/* 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/rollup_config_benchmarks.js",
Expand Down
41 changes: 21 additions & 20 deletions src/style-spec/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export type StylePropertySpecification = {
};

import v8 from './reference/v8.json';
export {v8};

import latest from './reference/latest';
import format from './format';
import migrate from './migrate';
Expand All @@ -68,35 +66,38 @@ import convertFunction from './function/convert';

import validate from './validate_style';

const exported = {
const expression = {
StyleExpression,
isExpression,
createExpression,
createPropertyExpression,
normalizePropertyExpression,
ZoomConstantExpression,
ZoomDependentExpression,
StylePropertyFunction
};

const styleFunction = {
convertFunction,
createFunction,
isFunction
};

export {
v8,
latest,
format,
migrate,
composite,
diff,
ValidationError,
ParsingError,
expression: {
StyleExpression,
isExpression,
createExpression,
createPropertyExpression,
normalizePropertyExpression,
ZoomConstantExpression,
ZoomDependentExpression,
StylePropertyFunction
},
expression,
featureFilter,
Color,
function: {
convertFunction,
createFunction,
isFunction
},
styleFunction as function,
validate
};

export default exported;

validate.parsed = validate;
validate.latest = validate;
7 changes: 7 additions & 0 deletions test/build/style-spec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,12 @@ test('@mapbox/mapbox-gl-style-spec npm package', (t) => {
});
});

t.test('exports components directly, not behind `default` - https://github.com/mapbox/mapbox-gl-js/issues/6601', (t) => {
const spec = require('../../dist/style-spec/index.js');
t.ok(spec.validate);
t.notOk(spec.default && spec.default.validate);
t.end();
});

t.end();
});
4 changes: 3 additions & 1 deletion test/unit/style-spec/migrate.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { test as t } from 'mapbox-gl-js-test';
import fs from 'fs';
import glob from 'glob';
import spec from '../../../src/style-spec/style-spec';
import path from 'path';
import validate from '../../../src/style-spec/validate_style';
import v8 from '../../../src/style-spec/reference/v8';
import migrate from '../../../src/style-spec/migrate';

/* eslint-disable import/namespace */
import * as spec from '../../../src/style-spec/style-spec';

const UPDATE = !!process.env.UPDATE;

t('does not migrate from version 5', (t) => {
Expand Down
4 changes: 3 additions & 1 deletion test/unit/style-spec/spec.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test } from 'mapbox-gl-js-test';
import spec from '../../../src/style-spec/style-spec';

/* eslint-disable import/namespace */
import * as spec from '../../../src/style-spec/style-spec';

['v8', 'latest'].forEach((version) => {
['', 'min'].forEach((kind) => {
Expand Down