diff --git a/package.json b/package.json index bcfefbaa..eed1de95 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "test": "npm run karma -- --single-run --log-level error" }, "dependencies": { - "@mapbox/mapbox-gl-style-spec": "^13.10.1", + "@mapbox/mapbox-gl-style-spec": "^13.11.0", "mapbox-to-css-font": "^2.4.0", "webfont-matcher": "^1.1.0" }, diff --git a/src/olms.js b/src/olms.js index 85806d3d..040f2e6b 100644 --- a/src/olms.js +++ b/src/olms.js @@ -1,10 +1,4 @@ -import olms, {apply, applyBackground, applyStyle} from './index'; -import stylefunction from './stylefunction'; +export {default as olms} from './index'; +export {apply, applyBackground, applyStyle} from './index'; +export {default as stylefunction} from './stylefunction'; -const exports = /** @type {Object} */ (olms); -exports.apply = apply; -exports.applyBackground = applyBackground; -exports.applyStyle = applyStyle; -exports.stylefunction = stylefunction; - -export default exports; diff --git a/webpack.config.olms.js b/webpack.config.olms.js index 7527b64d..5fe4261b 100644 --- a/webpack.config.olms.js +++ b/webpack.config.olms.js @@ -1,5 +1,40 @@ const path = require('path'); +const externals = { + 'ol/style/Style': 'ol.style.Style', + 'ol/style/Circle': 'ol.style.Circle', + 'ol/style/Icon': 'ol.style.Icon', + 'ol/style/Stroke': 'ol.style.Stroke', + 'ol/style/Fill': 'ol.style.Fill', + 'ol/proj': 'ol.proj', + 'ol/tilegrid': 'ol.tilegrid', + 'ol/tilegrid/TileGrid': 'ol.tilegrid.TileGrid', + 'ol/format/GeoJSON': 'ol.format.GeoJSON', + 'ol/format/MVT': 'ol.format.MVT', + 'ol/Map': 'ol.Map', + 'ol/View': 'ol.View', + 'ol/Observable': 'ol.Observable', + 'ol/layer/Tile': 'ol.layer.Tile', + 'ol/layer/Vector': 'ol.layer.Vector', + 'ol/layer/VectorTile': 'ol.layer.VectorTile', + 'ol/source/TileJSON': 'ol.source.TileJSON', + 'ol/source/Vector': 'ol.source.Vector', + 'ol/source/VectorTile': 'ol.source.VectorTile' +}; + +function createExternals() { + const createdExternals = {}; + for (const key in externals) { + createdExternals[key] = { + root: externals[key].split('.'), + commonjs: key, + commonjs2: key, + amd: key + }; + } + return createdExternals; +} + module.exports = { entry: './src/olms.js', devtool: 'source-map', @@ -22,28 +57,8 @@ module.exports = { path: path.resolve('./dist'), // Path of output file filename: 'olms.js', library: 'olms', - libraryTarget: 'assign', + libraryTarget: 'umd', libraryExport: 'default' }, - externals: { - 'ol/style/Style': 'ol.style.Style', - 'ol/style/Circle': 'ol.style.Circle', - 'ol/style/Icon': 'ol.style.Icon', - 'ol/style/Stroke': 'ol.style.Stroke', - 'ol/style/Fill': 'ol.style.Fill', - 'ol/proj': 'ol.proj', - 'ol/tilegrid': 'ol.tilegrid', - 'ol/tilegrid/TileGrid': 'ol.tilegrid.TileGrid', - 'ol/format/GeoJSON': 'ol.format.GeoJSON', - 'ol/format/MVT': 'ol.format.MVT', - 'ol/Map': 'ol.Map', - 'ol/View': 'ol.View', - 'ol/Observable': 'ol.Observable', - 'ol/layer/Tile': 'ol.layer.Tile', - 'ol/layer/Vector': 'ol.layer.Vector', - 'ol/layer/VectorTile': 'ol.layer.VectorTile', - 'ol/source/TileJSON': 'ol.source.TileJSON', - 'ol/source/Vector': 'ol.source.Vector', - 'ol/source/VectorTile': 'ol.source.VectorTile' - } + externals: createExternals() };