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

Add transpiled ES Module build with microbundle #9

Merged
merged 5 commits into from
Feb 8, 2019
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules/
/package-lock.json
/dist/api
/dist/main.js
/dist/main.*
/dist/sources.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just /dist/?

Copy link
Author

@romanzoller romanzoller Feb 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because dist/index.html is (and was already before) part of the git source, it's the example entry point, so it should not be ignored. Ideally it should not be in dist IMHO, I can change that in a follow-up PR if you agree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 :-)

7 changes: 0 additions & 7 deletions .npmignore

This file was deleted.

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,40 @@
"name": "@geoblocks/sources",
"version": "0.1.3",
"description": "Geoblocks sources",
"module": "src/index.js",
"main": "dist/sources.js",
gberaudo marked this conversation as resolved.
Show resolved Hide resolved
"module": "dist/sources.js",
"geoblocks_src": "src/index.js",
"scripts": {
"eslint": "eslint src/*.js",
"eslint-fix": "eslint src/*.js --fix",
"build": "webpack --mode production",
"build-debug": "webpack --mode development",
"build": "microbundle --format es",
"build-example": "webpack --mode production",
"build-example-debug": "webpack --mode development",
"start": "webpack-dev-server --mode development --content-base dist/ --watch",
"typecheck": "tsc --pretty",
"lint": "npm run eslint && npm run typecheck",
"test": "npm run lint && npm run build && npm run build-debug",
"test": "npm run lint && npm run build && npm run build-example && npm run build-example-debug",
"doc": "typedoc --out dist/api --theme minimal --readme none --hideGenerator --listInvalidSymbolLinks --toc none"
},
"files": [
"/src",
"/dist/sources.*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just /dist?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, /dist/index.html and /dist/main.js[.map] are example / example build files that don't need to be included in the npm package.

],
"author": "",
"license": "bsd",
"peerDependencies": {
"@geoblocks/proj": "^0.3.0",
"@geoblocks/proj": "^0.4.0",
"ol": "^5.2.0",
"proj4": "^2.4.4"
},
"devDependencies": {
"@geoblocks/base": "^0.1.1",
"@geoblocks/proj": "^0.3.0",
"@geoblocks/proj": "^0.4.0",
"@types/ol": "^4.6.2",
"@types/proj4": "^2.3.4",
"eslint": "5.9.0",
"eslint-config-openlayers": "11.0.0",
"microbundle": "^0.9.0",
"ol": "^5.2.0",
"proj4": "2.5.0",
"tsconfig-paths": "3.7.0",
Expand Down
13 changes: 6 additions & 7 deletions src/Swisstopo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import olSourceWMTS from 'ol/source/WMTS.js';
import olTilegridWMTS from 'ol/tilegrid/WMTS.js';
import EPSG_2056 from '@geoblocks/proj/src/EPSG_2056.js';
import EPSG_21781 from '@geoblocks/proj/src/EPSG_21781.js';
import {EPSG_2056, EPSG_21781} from '@geoblocks/proj';


/**
Expand Down Expand Up @@ -44,8 +43,8 @@ export const createSwisstopoMatrixSet = function(level) {
* Extents of Swiss projections.
*/
const extents = {
[EPSG_2056]: [2420000, 1030000, 2900000, 1350000],
[EPSG_21781]: [420000, 30000, 900000, 350000]
[EPSG_2056.code]: [2420000, 1030000, 2900000, 1350000],
[EPSG_21781.code]: [420000, 30000, 900000, 350000]
};

/**
Expand Down Expand Up @@ -76,9 +75,9 @@ function createUrl(baseUrl, projection, format) {
return baseUrl;
}
let url = `${baseUrl}/1.0.0/{Layer}/default/{Time}`;
if (projection === EPSG_2056) {
if (projection === EPSG_2056.code) {
url += `/2056/{TileMatrix}/{TileCol}/{TileRow}.${format}`;
} else if (projection === EPSG_21781) {
} else if (projection === EPSG_21781.code) {
url += `/21781/{TileMatrix}/{TileRow}/{TileCol}.${format}`;
} else {
throw new Error(`Unsupported projection ${projection}`);
Expand Down Expand Up @@ -112,7 +111,7 @@ export default class SwisstopoSource extends olSourceWMTS {
constructor(options) {
const format = options.format || 'image/png';
const projection = options.projection;
console.assert(projection === EPSG_21781 || projection === EPSG_2056);
console.assert(projection === EPSG_21781.code || projection === EPSG_2056.code);
const tilegrid = createTileGrid(projection, options.level || 27);
const projectionCode = projection.split(':')[1];
const extension = format.split('/')[1];
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Swisstopo from './Swisstopo';

export {Swisstopo};
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
entry: './examples/swisstopo.js',
devtool: 'source-map',
resolve: {symlinks: false},
output: {
filename: 'main.js'
}
Expand Down