Skip to content

Commit

Permalink
0.2.0 - Built to ESModule (#3)
Browse files Browse the repository at this point in the history
* Moved to ESModule

* Bumped node version in GitHub Workflows

* Added job when unit tests are finished
  • Loading branch information
ponlawat-w authored Nov 25, 2023
1 parent 1d9698c commit d0f84df
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
registry-url: https://registry.npmjs.org/
- name: Install
run: npm ci
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: Unit Tests
on: workflow_call
jobs:
unit-tests:
name: Unit Tests
strategy:
fail-fast: true
matrix:
node: [16, 18, 20]
name: Unit Tests Node ${{ matrix.node }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -12,8 +16,14 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: ${{ matrix.node }}
- name: Install
run: npm ci
- name: Test
run: npm run test
unit-tests-finished:
name: Unit Tests Finished
needs: unit-tests
runs-on: ubuntu-latest
steps:
- run: exit 0
2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<span id="way-status"></span>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js"></script>
<script src="https://www.unpkg.com/ol-osmoverpass/dist/webpack/index.js"></script>
<script src="https://www.unpkg.com/ol-osmoverpass/dist/bundle/index.js"></script>
<script lang="js">
const basemap = new ol.layer.Tile({ source: new ol.source.OSM() });

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "ol-osmoverpass",
"version": "0.1.0",
"type": "module",
"version": "0.2.0",
"description": "OverLayers vector layer source for OpenStreetMap elements using Overpass API",
"main": "dist/index.js",
"keywords": [
"osm",
"openstreetmap",
"openlayers",
"gis",
"map",
"road-snapping"
"map"
],
"scripts": {
"build": "npx tsc && npx webpack",
"test": "npx vitest run --config ./vitest.config.ts"
"test": "npm run build && npx vitest run --config ./vitest.config.ts"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion tests/overpass-api.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, beforeAll, it, expect } from 'vitest';
import { boundingExtent, containsXY } from 'ol/extent';
import { Overpass, type OSMNode } from '../src';
import { Overpass, type OSMNode } from '../dist';
import type { Coordinate } from 'ol/coordinate';


Expand Down
7 changes: 4 additions & 3 deletions tests/overpass-osm.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { type OSMElementConverter, OSMOverpass, Overpass, OSMNode, OSMWay } from '../src';
import { Feature } from 'ol';
import { boundingExtent, containsCoordinate } from 'ol/extent';
import { LineString } from 'ol/geom';
import { Projection } from 'ol/proj';
import { OSMOverpass, Overpass, OSMNode, OSMWay } from '../dist';
import type { OSMElementConverter } from '../dist';
import type { Coordinate } from 'ol/coordinate';
import { LineString } from 'ol/geom';
import { Feature } from 'ol';

describe('Test OSMOverpass', () => {
const coor1: Coordinate = [98.98017, 18.78764];
Expand Down
6 changes: 3 additions & 3 deletions tests/source-node.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { beforeAll, beforeEach, describe, expect, it, vi, test } from 'vitest';
import { Map, View } from 'ol';
import { Vector as VectorLayer } from 'ol/layer';
import { OSMOverpassNodeSource, Overpass } from '../src';
import { Window } from 'happy-dom';
import { boundingExtent, buffer, containsCoordinate } from 'ol/extent';
import { Vector as VectorLayer } from 'ol/layer';
import { Projection, transform, transformExtent } from 'ol/proj';
import { Window } from 'happy-dom';
import { OVERPASS_API_ENDPOINT, OVERPASS_FETCH_TIMEOUT } from './common';
import { OSMOverpassNodeSource, Overpass } from '../dist';

describe('Test OSMOverpassNodeSource', () => {
const epsg4326 = new Projection({ code: 'EPSG:4326' });
Expand Down
8 changes: 4 additions & 4 deletions tests/source-way.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Window } from 'happy-dom';
import { expect, test, vi } from 'vitest';
import { OVERPASS_API_ENDPOINT, OVERPASS_FETCH_TIMEOUT } from './common';
import { Map, View } from 'ol';
import { boundingExtent, containsCoordinate } from 'ol/extent';
import { Vector as VectorLayer } from 'ol/layer';
import { Projection, transform } from 'ol/proj';
import { expect, test, vi } from 'vitest';
import { OSMOverpassWaySource } from '../src';
import VectorLayer from 'ol/layer/Vector';
import { Window } from 'happy-dom';
import { OSMOverpassWaySource } from '../dist';

test('Test OSMOverpassWaySource', async() => {
const epsg4326 = new Projection({ code: 'EPSG:4326' });
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"module": "CommonJS",
"target": "es6",
"module": "ES2020",
"moduleResolution": "Node",
"target": "ES2020",
"rootDir": "./src",
"declaration": true,
"declarationMap": true,
Expand Down
18 changes: 15 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
const path = require('path');
import path from 'path';
import { fileURLToPath } from 'url';

module.exports = {
const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default {
mode: 'production',
entry: './dist/index.js',
module: {
rules: [{
test: /\.(js)$/,
exclude: /node_modules/,
resolve: {
fullySpecified: false
}
}]
},
resolve: {
alias: { ol: false }
},
Expand All @@ -17,7 +29,7 @@ module.exports = {
'ol/style': 'ol.style'
},
output: {
path: path.resolve(__dirname, 'dist', 'webpack'),
path: path.resolve(__dirname, 'dist', 'bundle'),
filename: 'index.js',
library: {
type: 'var',
Expand Down

0 comments on commit d0f84df

Please sign in to comment.