Skip to content

Commit 2caff6c

Browse files
committed
[fix] Improve CI coverage and fix webpack configurations
- Update CI to use matrix strategy for 'dev' (unit+browser), 'prod' (browser), and 'echarts-only' (browser) builds. - Remove unsafe Terser optimizations to ensure stability. - Fix 'InjectLeafletLoaderPlugin' regex to prevent accidental removal of plugin scripts. - Use 'http-server' via npx in CI for serving production builds. Signed-off-by: Sankalp <sankalp.nex@gmail.com>
1 parent ab2c0bd commit 2caff6c

File tree

8 files changed

+29
-17
lines changed

8 files changed

+29
-17
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ jobs:
4949
run: ./run-qa-checks
5050

5151
build:
52-
name: Tests and Coverage
52+
name: Tests and Coverage (${{ matrix.build-type }})
5353
runs-on: ubuntu-latest
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
build-type: [dev, prod, echarts-only]
5458

5559
steps:
5660
- uses: actions/checkout@v6
@@ -76,9 +80,22 @@ jobs:
7680
run: |
7781
yarn install
7882
79-
- name: Running Server
83+
- name: Build (Prod Full)
84+
if: matrix.build-type == 'prod'
85+
run: yarn build:full
86+
87+
- name: Build (Echarts Only)
88+
if: matrix.build-type == 'echarts-only'
89+
run: yarn build:echarts-only
90+
91+
- name: Running Server (Dev)
92+
if: matrix.build-type == 'dev'
8093
run: yarn start &
8194

95+
- name: Running Server (Dist)
96+
if: matrix.build-type == 'prod' || matrix.build-type == 'echarts-only'
97+
run: npx --yes http-server dist -p 8080 &
98+
8299
- name: Wait for server to be ready
83100
run: npx wait-on http://localhost:8080
84101

@@ -96,13 +113,15 @@ jobs:
96113
which chromedriver
97114
98115
- name: Unit tests
116+
if: matrix.build-type == 'dev'
99117
run: yarn coverage --testPathIgnorePatterns=test/netjsongraph.browser.test.js
100118

101119
- name: Browser tests
102120
# Test timeout set to 30 seconds in CI since it runs slower
103121
run: yarn test --runInBand --testTimeout=30000 test/netjsongraph.browser.test.js
104122

105123
- name: Coveralls
124+
if: matrix.build-type == 'dev'
106125
uses: coverallsapp/github-action@master
107126
with:
108127
github-token: ${{ secrets.GITHUB_TOKEN }}

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ <h1>NetJSONGraph.js Example Demos</h1>
242242
>
243243
</div>
244244

245-
246245
<div class="cards">
247246
<a href="./examples/netjsongraph-nodeExpand.html" target="_blank"
248247
>Nodes expand or fold</a

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"@babel/preset-env": "^7.23.9",
5959
"@testing-library/jest-dom": "^6.4.2",
6060
"@types/jest": "^30.0.0",
61-
"acorn": "^8.11.3",
6261
"compression-webpack-plugin": "^11.1.0",
6362
"copy-webpack-plugin": "^13.0.0",
6463
"coveralls": "^3.1.1",
@@ -89,8 +88,7 @@
8988
},
9089
"dependencies": {
9190
"echarts": "^5.6.0",
92-
"kdbush": "^4.0.2",
93-
"zrender": "^6.0.0"
91+
"kdbush": "^4.0.2"
9492
},
9593
"peerDependencies": {
9694
"leaflet": "^1.8.0"

src/js/echarts-leaflet/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import getLeaflet from "../leaflet-loader";
77
/**
88
* echarts register leaflet coord system
99
*/
10-
export function registerLeafletSystem() {
10+
function registerLeafletSystem() {
1111
const L = getLeaflet(true);
1212
if (!L) {
1313
// Leaflet is not available, so we can't register the Leaflet coordinate system.

src/js/leaflet-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function getLeaflet(suppressError = false) {
2626
} else {
2727
if (typeof window === "undefined" || !window.L) {
2828
if (!suppressError) {
29-
console.error(
29+
console.warn(
3030
"Leaflet (L) is not defined! Make sure Leaflet is loaded before NetJSONGraph.",
3131
);
3232
}

src/js/netjsongraph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import NetJSONGraphCore from "./netjsongraph.core";
44
import NetJSONGraphRender from "./netjsongraph.render";
55
import NetJSONGraphGUI from "./netjsongraph.gui";
66
import attachClientsOverlay from "./netjsongraph.clients";
7-
import {registerLeafletSystem} from "./echarts-leaflet";
7+
import registerLeafletSystem from "./echarts-leaflet";
88

99
let isLeafletRegistered = false;
1010

webpack-plugins/inject-leaflet-loader.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ class InjectLeafletLoaderPlugin {
1111
"netjsonmap-appendData.html",
1212
"netjsonmap-appendData2.html",
1313
"netjsonmap-indoormap.html",
14+
"netjsonmap-indoormap-overlay.html",
15+
"netjsonmap-moving-node.html",
1416
"netjsonmap-multipleTiles.html",
1517
"netjsonmap-nodeTiles.html",
18+
"netjsonmap-overrideData.html",
1619
"netjsonmap-plugins.html",
1720
"netjsonmap.html",
1821
"njg-geojson.html",
@@ -173,7 +176,7 @@ ${
173176
}
174177

175178
// Remove main leaflet.js script if present
176-
const leafletJSRegex = /<script[^>]*leaflet[^>]*>[\s\S]*?<\/script>/gi;
179+
const leafletJSRegex = /<script[^>]*leaflet\.js[^>]*>[\s\S]*?<\/script>/gi;
177180
let prev;
178181
do {
179182
prev = html;

webpack.config.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ const getMinimizers = (isProduction) => {
4646
hoist_funs: true,
4747
hoist_vars: false,
4848
pure_getters: true,
49-
unsafe: true,
50-
unsafe_comps: true,
51-
unsafe_Function: true,
52-
unsafe_math: true,
53-
unsafe_proto: true,
54-
unsafe_regexp: true,
55-
unsafe_undefined: true,
5649
},
5750
output: {
5851
comments: false,

0 commit comments

Comments
 (0)