Skip to content

Commit

Permalink
build: Load geostyler-qml-parser dynamically
Browse files Browse the repository at this point in the history
Rarely used package which adds up around 100kb to the vendor bundle
  • Loading branch information
FilipLeitner committed Feb 13, 2024
1 parent e5f752f commit af394f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
"sourceMap": true,
"namedChunks": true,
"extractLicenses": true,
"vendorChunk": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
Expand Down
13 changes: 8 additions & 5 deletions projects/hslayers/shared/styler/styler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from 'geostyler-sld-parser';
import {Feature, getUid} from 'ol';
import {
FillSymbolizer,
Filter,
Style as GeoStylerStyle,
Rule,
Expand All @@ -21,7 +20,6 @@ import {Geometry} from 'ol/geom';
import {Icon, Style} from 'ol/style';
import {Layer, Vector as VectorLayer} from 'ol/layer';
import {OlStyleParser as OpenLayersParser} from 'geostyler-openlayers-parser';
import {QGISStyleParser} from 'geostyler-qgis-parser';
import {StyleFunction, StyleLike, createDefaultStyle} from 'ol/style/Style';

import {HsCommonLaymanService} from 'hslayers-ng/common/layman';
Expand Down Expand Up @@ -63,7 +61,6 @@ export class HsStylerService {
onSet: Subject<VectorLayer<VectorSource>> = new Subject();
layerTitle: string;
styleObject: GeoStylerStyle;
qmlParser = new QGISStyleParser();

sld: string;
qml: string;
Expand Down Expand Up @@ -490,7 +487,10 @@ export class HsStylerService {
* @returns
*/
async qmlToJson(qml: string): Promise<GeoStylerStyle> {
const result = await this.qmlParser.readStyle(qml);
const {QGISStyleParser} = await import('geostyler-qgis-parser');
const qmlParser = new QGISStyleParser();

const result = await qmlParser.readStyle(qml);
if (result.output) {
return result.output;
} else {
Expand Down Expand Up @@ -753,7 +753,10 @@ export class HsStylerService {
await sldParser.readStyle(styleString);
this.sld = styleString;
} else if (styleFmt == 'qml') {
await this.qmlParser.readStyle(styleString);
const {QGISStyleParser} = await import('geostyler-qgis-parser');
const qmlParser = new QGISStyleParser();

await qmlParser.readStyle(styleString);
this.qml = styleString;
}
this.resolveSldChange();
Expand Down

0 comments on commit af394f5

Please sign in to comment.