Skip to content

Commit

Permalink
Provide a transpiled bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Dec 18, 2019
1 parent 2793af1 commit 0277bcd
Show file tree
Hide file tree
Showing 37 changed files with 56 additions and 37 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.circleci/
.git/
example/
examples/
test/
.editorconfig
.eslintrc
webpack.*.js
tsconfig.*.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ for rendering.
### stylefunction

```js
import stylefunction from 'ol-mapbox-style/stylefunction';
import stylefunction from 'ol-mapbox-style/dist/stylefunction';
```

Creates a style function from the `glStyle` object for all layers that use
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ol-mapbox-style",
"version": "5.0.2",
"description": "Create OpenLayers maps from Mapbox Style objects",
"main": "index.js",
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git://github.com/openlayers/ol-mapbox-style.git"
Expand All @@ -17,37 +17,37 @@
],
"license": "BSD-2-Clause",
"scripts": {
"start": "webpack-dev-server --config ./webpack.config.js",
"start": "webpack-dev-server --config ./webpack.config.examples.js",
"prepare": "npm run doc && npm run build",
"build": "webpack-cli --mode=production --config ./webpack.config.olms.js && webpack-cli --mode=production",
"doc": "documentation readme -s API index.js stylefunction.js --document-exported true",
"build": "tsc --project tsconfig-build.json && webpack-cli --mode=production --config ./webpack.config.olms.js && webpack-cli --mode=production --config ./webpack.config.examples.js",
"doc": "documentation readme -s API src/index.js src/stylefunction.js --document-exported true",
"karma": "karma start test/karma.conf.js",
"lint": "eslint test example *.js",
"lint": "eslint test examples src",
"typecheck": "tsc --project tsconfig-typecheck.json",
"pretest": "npm run lint && npm run typecheck",
"test": "npm run karma -- --single-run --log-level error"
},
"dependencies": {
"@mapbox/mapbox-gl-style-spec": "^13.9.0",
"@mapbox/mapbox-gl-style-spec": "^13.10.1",
"mapbox-to-css-font": "^2.4.0",
"webfont-matcher": "^1.1.0"
},
"peerDependencies": {
"ol": "^6.1.0"
},
"devDependencies": {
"@types/node": "^12.7.12",
"@types/node": "^12.12.19",
"babel-loader": "^8.0.6",
"buble": "^0.19.8",
"buble-loader": "^0.5.1",
"copy-webpack-plugin": "^4.6.0",
"css-loader": "^1.0.1",
"css-loader": "^3.4.0",
"deep-freeze": "0.0.1",
"documentation": "^11.0.1",
"documentation": "^12.1.4",
"eslint": "^5.16.0",
"eslint-config-openlayers": "^11.0.0",
"html-webpack-plugin": "^3.2.0",
"karma": "^4.3.0",
"karma": "^4.4.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-mocha": "^1.3.0",
Expand All @@ -56,14 +56,14 @@
"mapbox-gl-styles": "^2.0.2",
"mini-css-extract-plugin": "^0.4.5",
"mocha": "^5.2.0",
"ol": "^6.0.1",
"ol": "^6.1.1",
"puppeteer": "^1.20.0",
"should": "^13.2.3",
"sinon": "^7.5.0",
"style-loader": "^0.23.1",
"typescript": "^3.6.3",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9",
"webpack-dev-server": "^3.8.2"
"typescript": "3.5.3",
"webpack": "^4.41.3",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
}
}
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion stylefunction.js → src/stylefunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import Icon from 'ol/style/Icon';
import Text from 'ol/style/Text';
import Circle from 'ol/style/Circle';
import RenderFeature from 'ol/render/Feature';

//TODO Import derefLayers directly from '@mapbox/mapbox-gl-style-spec' when
// https://github.com/mapbox/mapbox-gl-js/pull/9121 is merged.
import derefLayers from '@mapbox/mapbox-gl-style-spec/deref';

import {
expression, Color,
function as fn,
Expand Down Expand Up @@ -168,7 +172,7 @@ function fromTemplate(text, properties) {

/**
* ```js
* import stylefunction from 'ol-mapbox-style/stylefunction';
* import stylefunction from 'ol-mapbox-style/dist/stylefunction';
* ```
* Creates a style function from the `glStyle` object for all layers that use
* the specified `source`, which needs to be a `"type": "vector"` or
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/applyStyle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import styleEmptySprite from './fixtures/style-empty-sprite.json';
import styleMissingSprite from './fixtures/style-missing-sprite.json';
import styleInvalidSpriteURL from './fixtures/style-invalid-sprite-url.json';

import {applyStyle} from '../index.js';
import {applyStyle} from '../src/index.js';


describe('applyStyle style argument validation', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/finalizeLayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TileSource from 'ol/source/Tile';
import glStyle from './fixtures/osm-liberty/style.json';
import invalidStyle from './fixtures/style-invalid-version.json';

import {_finalizeLayer as finalizeLayer} from '../index';
import {_finalizeLayer as finalizeLayer} from '../src/index';

describe('finalizeLayer promise', function() {

Expand Down
4 changes: 2 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import should from 'should';
import olms, {applyBackground, apply, getLayer, getLayers, getSource} from '..';
import {_getFonts as getFonts} from '../index';
import {_getFonts as getFonts} from '../src/index';
import Map from 'ol/Map';
import TileSource from 'ol/source/Tile';
import VectorSource from 'ol/source/Vector';
Expand All @@ -10,7 +10,7 @@ import {toLonLat} from 'ol/proj';

import brightV9 from 'mapbox-gl-styles/styles/bright-v9.json';
import backgroundStyle from './fixtures/background.json';
import {defaultResolutions} from '../util';
import {defaultResolutions} from '../src/util';
delete brightV9.sprite;

describe('ol-mapbox-style', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/stylefunction-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
_fromTemplate as fromTemplate,
_getValue as getValue,
_functionCache as functionCache
} from '../stylefunction';
} from '../src/stylefunction';


describe('utility functions currently in stylefunction.js', function() {
Expand Down
4 changes: 2 additions & 2 deletions test/stylefunction.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import should from 'should';
import deepFreeze from 'deep-freeze';
import applyStyleFunction from '../stylefunction';
import olms from '../index';
import applyStyleFunction from '../src/stylefunction';
import olms from '../src/index';
import states from './fixtures/states.json';
import Feature from 'ol/Feature';
import VectorLayer from 'ol/layer/Vector';
Expand Down
14 changes: 14 additions & 0 deletions tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"outDir": "./dist",
"target": "ES5",
"module": "es2015",
"sourceMap": true,
"allowJs": true,
"importHelpers": false,
},
"include": [
"./src/**/*.js"
],
"exclude": []
}
2 changes: 1 addition & 1 deletion tsconfig-typecheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
]
},
"include": [
"*.js"
"src/*.js"
]
}
17 changes: 9 additions & 8 deletions webpack.config.js → webpack.config.examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

/** Get the list of examples from the example directory.
/** Get the list of examples from the examples directory.
*
* @param {String} dirName - Name of the directory to read.
* @param {Function} callback - Function to execute for each example.
Expand Down Expand Up @@ -77,7 +77,7 @@ module.exports = (env, argv) => {
context: __dirname,
target: 'web',
mode: prod ? 'production' : 'development',
entry: getEntries(path.resolve(__dirname, './example')),
entry: getEntries(path.resolve(path.join(__dirname, 'examples'))),
optimization: {
runtimeChunk: {
name: 'common'
Expand All @@ -90,11 +90,11 @@ module.exports = (env, argv) => {
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'dist')
path: path.join(__dirname, 'dist', 'examples')
},
resolve: {
alias: {
'ol-mapbox-style': path.join(__dirname, '.')
'ol-mapbox-style': path.join(__dirname, 'src')
}
},
devtool: 'source-map',
Expand All @@ -112,7 +112,7 @@ module.exports = (env, argv) => {
test: /\.js$/,
include: [
__dirname,
/node_modules\/(?!(ol|@mapbox\/mapbox-gl-style-spec)\/)/
/node_modules\/(?!(@mapbox\/mapbox-gl-style-spec)\/)/
],
use: {
loader: 'buble-loader'
Expand All @@ -129,16 +129,17 @@ module.exports = (env, argv) => {
}),
// ensure the data is copied over.
// currently the index.html is manually created.
// @ts-ignore
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, './example/data'),
from: path.resolve(__dirname, './examples/data'),
to: 'data'
},
{
from: path.resolve(__dirname, './example/index.html'),
from: path.resolve(__dirname, './examples/index.html'),
to: 'index.html'
}
])
].concat(getHtmlTemplates('./example'))
].concat(getHtmlTemplates('./examples'))
};
};
5 changes: 2 additions & 3 deletions webpack.config.olms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');

module.exports = {
entry: './olms.js',
entry: './src/olms.js',
devtool: 'source-map',
node: {fs: 'empty'},
mode: 'production',
Expand All @@ -10,8 +10,7 @@ module.exports = {
{
test: /\.js$/,
include: [
__dirname,
/node_modules\/(?!(ol|@mapbox\/mapbox-gl-style-spec)\/)/
__dirname
],
use: {
loader: 'buble-loader'
Expand Down

0 comments on commit 0277bcd

Please sign in to comment.