From 058b4da6db234b491d698300a2888299426ae433 Mon Sep 17 00:00:00 2001 From: Dan Leech Date: Thu, 1 Oct 2026 11:34:44 +0100 Subject: [PATCH 1/2] Make map engines optional externals and document bundler config --- docs/getting-started.md | 63 ++++++++++++++++++++++++++++++++++++++++ docs/plugins/datasets.md | 3 ++ docs/plugins/draw.md | 5 +++- package-lock.json | 33 ++++++++++++++++++++- package.json | 6 +++- rollup.esm.mjs | 42 ++++++++++++--------------- 6 files changed, 125 insertions(+), 27 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index da7230fd5..9c5f8532d 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -54,6 +54,69 @@ npm install ol proj4 **UMD:** `ol` and `proj4` are bundled — no separate install needed. +### Bundler configuration (ESM) + +Some plugins work with more than one map provider. They load an adapter for your provider at runtime, and each adapter imports its own map engine. Only the adapter for your provider is ever loaded in the browser, but your bundler still builds every adapter, so it fails to resolve the engines you haven't installed: + +``` +Module not found: Error: Can't resolve 'ol/layer/Vector.js' +``` + +Tell your bundler to ignore the engines for the providers you don't use. Plugins that need this say so at the top of their documentation. + +| Provider | Ignore | Pattern | +|---|---|---| +| MapLibre | `ol`, `proj4`, `@arcgis/core` | `/^(ol\|proj4\|@arcgis\/core)(\/\|$)/` | +| OpenLayers | `@arcgis/core` | `/^@arcgis\/core(\/\|$)/` | +| ESRI | `ol`, `proj4` | `/^(ol\|proj4)(\/\|$)/` | + +The examples below are for the MapLibre provider. For another provider, swap in its pattern. + +**Webpack** + +```js +import webpack from 'webpack' + +export default { + // ... + plugins: [ + new webpack.IgnorePlugin({ resourceRegExp: /^(ol|proj4|@arcgis\/core)(\/|$)/ }) + ] +} +``` + +**Vite** (production builds; the dev server only warns) + +```js +export default { + build: { + rollupOptions: { // rolldownOptions in Vite 8+ + external: [/^(ol|proj4|@arcgis\/core)(\/|$)/] + } + } +} +``` + +**Rollup** + +```js +export default { + // ... + external: [/^(ol|proj4|@arcgis\/core)(\/|$)/] +} +``` + +**esbuild** + +```js +await esbuild.build({ + // ... + external: ['ol', 'ol/*', 'proj4', '@arcgis/core', '@arcgis/core/*'] +}) +``` + +The ignored engines are only used by adapters for other providers, which are never loaded, so nothing is missing at runtime. If you switch provider, update the pattern to match. + ## Basic usage **ESM** — add a container element to your HTML and initialise the map in your JavaScript: diff --git a/docs/plugins/datasets.md b/docs/plugins/datasets.md index 213b17a11..bc8382dcc 100644 --- a/docs/plugins/datasets.md +++ b/docs/plugins/datasets.md @@ -5,6 +5,9 @@ The datasets plugin renders GeoJSON and vector tile datasets on the map, with su > [!IMPORTANT] > **Upgrading?** This plugin no longer renders key of symbols itself — that button and panel have been removed. Add the [Map Key](./map-key.md) plugin to restore it. Your `showInKey` config is unaffected and needs no changes. +> [!IMPORTANT] +> **Using a bundler (ESM)?** This plugin includes adapters for more than one map provider, so your bundler needs to ignore the map engines you haven't installed. See [Bundler configuration](../getting-started.md#bundler-configuration-esm). + ## ESM usage ```js diff --git a/docs/plugins/draw.md b/docs/plugins/draw.md index 015c4a368..beb9de9e7 100644 --- a/docs/plugins/draw.md +++ b/docs/plugins/draw.md @@ -1,6 +1,9 @@ # Draw Plugin -The draw plugin lets users draw and edit point, polygon and line features on the map — placing vertices by click, tap, or keyboard, snapping to existing map layers, and validating geometry as it's built. Polygons can also be split and merged. It works identically with both the MapLibre and OpenLayers map providers, determining the correct adapter to use from the `mapProvider` passed to `InteractiveMap` — there's nothing to configure. +The draw plugin lets users draw and edit point, polygon and line features on the map — placing vertices by click, tap, or keyboard, snapping to existing map layers, and validating geometry as it's built. Polygons can also be split and merged. It works identically with both the MapLibre and OpenLayers map providers, determining the correct adapter to use from the `mapProvider` passed to `InteractiveMap` — there's nothing to configure in the plugin itself. + +> [!IMPORTANT] +> **Using a bundler (ESM)?** This plugin includes adapters for more than one map provider, so your bundler needs to ignore the map engines you haven't installed. See [Bundler configuration](../getting-started.md#bundler-configuration-esm). ## ESM usage diff --git a/package-lock.json b/package-lock.json index 351c2b34e..6cffcc8ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "@turf/union": "^7.3.5", "accessible-autocomplete": "^3.0.1", "govuk-frontend": "^5.13.0", - "maplibre-gl": "^5.23.0", "polygon-splitter": "^0.0.11", "preact": "^10.27.2", "tslib": "^2.8.1" @@ -66,6 +65,7 @@ "jest-expect-message": "^1.1.3", "likec4": "^1.50.0", "mapbox-gl-snap": "^1.1.9", + "maplibre-gl": "^5.23.0", "mini-css-extract-plugin": "^2.9.2", "node-fetch": "^3.3.2", "npm-run-all": "^4.1.5", @@ -95,6 +95,7 @@ }, "peerDependencies": { "@arcgis/core": "^5.0.9", + "maplibre-gl": "^5.23.0", "ol": "^10.10.0", "proj4": "^2.20.8" }, @@ -102,6 +103,9 @@ "@arcgis/core": { "optional": true }, + "maplibre-gl": { + "optional": true + }, "ol": { "optional": true }, @@ -6175,6 +6179,7 @@ }, "node_modules/@mapbox/jsonlint-lines-primitives": { "version": "2.0.2", + "dev": true, "engines": { "node": ">= 0.6" } @@ -6202,18 +6207,22 @@ }, "node_modules/@mapbox/point-geometry": { "version": "1.1.0", + "dev": true, "license": "ISC" }, "node_modules/@mapbox/tiny-sdf": { "version": "2.0.7", + "dev": true, "license": "BSD-2-Clause" }, "node_modules/@mapbox/unitbezier": { "version": "0.0.1", + "dev": true, "license": "BSD-2-Clause" }, "node_modules/@mapbox/vector-tile": { "version": "2.0.4", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "@mapbox/point-geometry": "~1.1.0", @@ -6223,6 +6232,7 @@ }, "node_modules/@mapbox/whoots-js": { "version": "3.1.0", + "dev": true, "license": "ISC", "engines": { "node": ">=6.0.0" @@ -6232,6 +6242,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/@maplibre/geojson-vt/-/geojson-vt-6.1.0.tgz", "integrity": "sha512-2eIY4gZxeKIVOZVNkAMb+5NgXhgsMQpOveTQAvnp53LYqHGJZDidk7Ew0Tged9PThidpbS+NFTh0g4zivhPDzQ==", + "dev": true, "license": "ISC", "dependencies": { "kdbush": "^4.0.2" @@ -6241,6 +6252,7 @@ "version": "24.8.1", "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-24.8.1.tgz", "integrity": "sha512-zxa92qF96ZNojLxeAjnaRpjVCy+swoUNJvDhtpC90k7u5F0TMr4GmvNqMKvYrMoPB8d7gRSXbMG1hBbmgESIsw==", + "dev": true, "license": "ISC", "dependencies": { "@mapbox/jsonlint-lines-primitives": "~2.0.2", @@ -6261,6 +6273,7 @@ "version": "1.1.8", "resolved": "https://registry.npmjs.org/@maplibre/mlt/-/mlt-1.1.8.tgz", "integrity": "sha512-8vtfYGidr1rNkv5IwIoU2lfe3Oy+Wa8HluzQYcQi9cveU9K3pweAal/poQj4GJ0K/EW4bTQp2wVAs09g2yDRZg==", + "dev": true, "license": "(MIT OR Apache-2.0)", "dependencies": { "@mapbox/point-geometry": "^1.1.0" @@ -6270,6 +6283,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/@maplibre/vt-pbf/-/vt-pbf-4.3.0.tgz", "integrity": "sha512-jIvp8F5hQCcreqOOpEt42TJMUlsrEcpf/kI1T2v85YrQRV6PPXUcEXUg5karKtH6oh47XJZ4kHu56pUkOuqA7w==", + "dev": true, "license": "MIT", "dependencies": { "@mapbox/point-geometry": "^1.1.0", @@ -6285,6 +6299,7 @@ "version": "5.0.4", "resolved": "https://registry.npmjs.org/@maplibre/geojson-vt/-/geojson-vt-5.0.4.tgz", "integrity": "sha512-KGg9sma45S+stfH9vPCJk1J0lSDLWZgCT9Y8u8qWZJyjFlP8MNP1WGTxIMYJZjDvVT3PDn05kN1C95Sut1HpgQ==", + "dev": true, "license": "ISC" }, "node_modules/@mdx-js/mdx": { @@ -10972,6 +10987,7 @@ }, "node_modules/@types/supercluster": { "version": "7.1.3", + "dev": true, "license": "MIT", "dependencies": { "@types/geojson": "*" @@ -15097,6 +15113,7 @@ }, "node_modules/earcut": { "version": "3.0.2", + "dev": true, "license": "ISC" }, "node_modules/eastasianwidth": { @@ -17319,6 +17336,7 @@ }, "node_modules/gl-matrix": { "version": "3.4.4", + "dev": true, "license": "MIT" }, "node_modules/glob": { @@ -20344,6 +20362,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/json-stringify-pretty-compact/-/json-stringify-pretty-compact-4.0.0.tgz", "integrity": "sha512-3CNZ2DnrpByG9Nqj6Xo8vqbjT4F6N+tb4Gb28ESAZjYZ5yqvmc56J+/kuIwkaAMOyblTQhUW7PxMkUb8Q36N3Q==", + "dev": true, "license": "MIT" }, "node_modules/json5": { @@ -20384,6 +20403,7 @@ }, "node_modules/kdbush": { "version": "4.0.2", + "dev": true, "license": "ISC" }, "node_modules/keyv": { @@ -21307,6 +21327,7 @@ "version": "5.23.0", "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-5.23.0.tgz", "integrity": "sha512-aou8YBNFS8uVtDWFWt0W/6oorfl18wt+oIA8fnXk1kivjkbtXi9gGrQvflTpwrR3hG13aWdIdbYWeN0NFMV7ag==", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "@mapbox/jsonlint-lines-primitives": "^2.0.2", @@ -23930,6 +23951,7 @@ }, "node_modules/minimist": { "version": "1.2.8", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -24019,6 +24041,7 @@ }, "node_modules/murmurhash-js": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/nano-spawn": { @@ -25119,6 +25142,7 @@ }, "node_modules/pbf": { "version": "4.0.1", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "resolve-protobuf-schema": "^2.1.0" @@ -27162,6 +27186,7 @@ }, "node_modules/potpack": { "version": "2.1.0", + "dev": true, "license": "ISC" }, "node_modules/powershell-utils": { @@ -27330,6 +27355,7 @@ "version": "3.6.1", "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.1.tgz", "integrity": "sha512-VG2K63Igkiv9p76tk1lilczEK1cT+kCjKtkdhw1dQZV3k3IXJbd3o6Ho8b9zJZaHSnT2hKe4I+ObmX9w6m5SmQ==", + "dev": true, "license": "MIT" }, "node_modules/proxy-addr": { @@ -27473,6 +27499,7 @@ }, "node_modules/quickselect": { "version": "3.0.0", + "dev": true, "license": "ISC" }, "node_modules/range-parser": { @@ -28254,6 +28281,7 @@ }, "node_modules/resolve-protobuf-schema": { "version": "2.1.0", + "dev": true, "license": "MIT", "dependencies": { "protocol-buffers-schema": "^3.3.1" @@ -29365,6 +29393,7 @@ }, "node_modules/rw": { "version": "1.3.3", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/safe-array-concat": { @@ -30852,6 +30881,7 @@ }, "node_modules/supercluster": { "version": "8.0.1", + "dev": true, "license": "ISC", "dependencies": { "kdbush": "^4.0.2" @@ -31299,6 +31329,7 @@ }, "node_modules/tinyqueue": { "version": "3.0.0", + "dev": true, "license": "ISC" }, "node_modules/tldts": { diff --git a/package.json b/package.json index e8e3bb39c..96154e0f9 100755 --- a/package.json +++ b/package.json @@ -134,6 +134,7 @@ }, "peerDependencies": { "@arcgis/core": "^5.0.9", + "maplibre-gl": "^5.23.0", "ol": "^10.10.0", "proj4": "^2.20.8" }, @@ -141,6 +142,9 @@ "@arcgis/core": { "optional": true }, + "maplibre-gl": { + "optional": true + }, "ol": { "optional": true }, @@ -190,6 +194,7 @@ "jest-expect-message": "^1.1.3", "likec4": "^1.50.0", "mapbox-gl-snap": "^1.1.9", + "maplibre-gl": "^5.23.0", "mini-css-extract-plugin": "^2.9.2", "node-fetch": "^3.3.2", "npm-run-all": "^4.1.5", @@ -248,7 +253,6 @@ "@turf/union": "^7.3.5", "accessible-autocomplete": "^3.0.1", "govuk-frontend": "^5.13.0", - "maplibre-gl": "^5.23.0", "polygon-splitter": "^0.0.11", "preact": "^10.27.2", "tslib": "^2.8.1" diff --git a/rollup.esm.mjs b/rollup.esm.mjs index 238b6310c..cd1ac8672 100644 --- a/rollup.esm.mjs +++ b/rollup.esm.mjs @@ -82,7 +82,7 @@ const PREACT_EXTERNALS = [ // dependency so it auto-installs for consumers and is resolved transparently. const BABEL_RUNTIME_EXTERNAL = /@babel\/runtime/ -const createESMConfig = (entryPath, outDir, isCore = false, manualChunks = null, extraExternals = []) => { +const createESMConfig = (entryPath, outDir, isCore = false, manualChunks = null, chunkNames = {}) => { const esmDir = path.resolve(__dirname, outDir) // Use the parent dir as output.dir so CSS can be emitted to css/index.css // (a sibling subdir) without Rollup 4's ban on ".." in emitted file names. @@ -104,12 +104,13 @@ const createESMConfig = (entryPath, outDir, isCore = false, manualChunks = null, : [ ...PREACT_EXTERNALS, BABEL_RUNTIME_EXTERNAL, - // maplibre-gl is externalised so ESM consumers get a single shared - // instance from their own node_modules rather than a 1 MB copy bundled - // into the provider. (UMD keeps it bundled — no bundler available there.) + // Map engines (optional peers) are externalised so consumers share one copy + // from their own node_modules; they ignore the engines they don't install + // (see docs/getting-started.md). UMD keeps them bundled. 'maplibre-gl', - /^@arcgis\/core/, - ...extraExternals + /^ol\//, + 'proj4', + /^@arcgis\/core/ ], plugins: [ @@ -196,7 +197,7 @@ const createESMConfig = (entryPath, outDir, isCore = false, manualChunks = null, // - anything else → im-shell.js (the sync InteractiveMap + shared utils chunk) chunkFileNames: isCore ? (chunk) => chunk.name === 'initialiseApp' ? 'esm/im-core.js' : 'esm/im-shell.js' - : 'esm/[name].js', + : (chunk) => `esm/${chunkNames[chunk.name] || chunk.name}.js`, // Rollup ignores webpack magic comments; manualChunks is how we assign // meaningful names to lazy-loaded splits. // Core: no manualChunks — Rollup's natural algorithm keeps shared source @@ -234,7 +235,6 @@ const ALL_BUILDS = [ { entryPath: './providers/beta/openlayers/src/index.js', outDir: 'providers/beta/openlayers/dist/esm', - extraExternals: [/^ol\//, 'proj4'], manualChunks: (id) => id.includes('/openlayersProvider') ? 'im-openlayers-provider' : undefined }, @@ -262,13 +262,9 @@ const ALL_BUILDS = [ { entryPath: './plugins/datasets/src/index.js', outDir: 'plugins/datasets/dist/esm', - manualChunks: (id) => { - if (id.includes('/manifest')) { return 'im-datasets-plugin' } - if (id.includes('maplibreLayerAdapter')) { return 'im-datasets-ml-adapter' } - if (id.includes('openlayersLayerAdapter')) { return 'im-datasets-ol-adapter' } - if (id.includes('esriLayerAdapter')) { return 'im-datasets-esri-adapter' } - return undefined - } + // Adapters renamed rather than in manualChunks — see the draw build below + manualChunks: (id) => id.includes('/manifest') ? 'im-datasets-plugin' : undefined, + chunkNames: { maplibreLayerAdapter: 'im-datasets-ml-adapter', openlayersLayerAdapter: 'im-datasets-ol-adapter', esriLayerAdapter: 'im-datasets-esri-adapter' } }, { entryPath: './plugins/beta/map-styles/src/index.js', @@ -278,13 +274,12 @@ const ALL_BUILDS = [ { entryPath: './plugins/draw/src/index.js', outDir: 'plugins/draw/dist/esm', - extraExternals: [/^ol\//], - manualChunks: (id) => { - if (id.includes('/manifest')) { return 'im-draw-plugin' } - if (id.includes('MaplibreDrawAdapter')) { return 'im-draw-ml-adapter' } - if (id.includes('OLDrawAdapter')) { return 'im-draw-ol-adapter' } - return undefined - } + // Adapters are renamed rather than put in manualChunks: manual chunks absorb their + // dependencies, which put helpers shared by both adapters inside the MapLibre one, so + // OpenLayers hosts downloaded the whole MapLibre adapter. Left to Rollup, shared + // helpers get a small chunk of their own. + manualChunks: (id) => id.includes('/manifest') ? 'im-draw-plugin' : undefined, + chunkNames: { MaplibreDrawAdapter: 'im-draw-ml-adapter', OLDrawAdapter: 'im-draw-ol-adapter' } }, { entryPath: './plugins/beta/draw-ml/src/index.js', @@ -299,7 +294,6 @@ const ALL_BUILDS = [ { entryPath: './plugins/beta/draw-ol/src/index.js', outDir: 'plugins/beta/draw-ol/dist/esm', - extraExternals: [/^ol\//], manualChunks: (id) => id.includes('/manifest') ? 'im-draw-ol-plugin' : undefined }, { @@ -326,5 +320,5 @@ const buildsToRun = BUILD_TARGET : ALL_BUILDS export default buildsToRun.map(b => - createESMConfig(b.entryPath, b.outDir, b.isCore || false, b.manualChunks || null, b.extraExternals || []) + createESMConfig(b.entryPath, b.outDir, b.isCore || false, b.manualChunks || null, b.chunkNames) ) From a478ab63385d7216a3e190c5b3c60d92eb260110 Mon Sep 17 00:00:00 2001 From: Dan Leech Date: Thu, 1 Oct 2026 11:51:23 +0100 Subject: [PATCH 2/2] Keep maplibre-gl a dependency and leave Esri code out of UMD builds --- docs/getting-started.md | 8 +------- package-lock.json | 33 +-------------------------------- package.json | 6 +----- webpack.umd.mjs | 6 +++++- 4 files changed, 8 insertions(+), 45 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 9c5f8532d..468f2644c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -28,13 +28,7 @@ The map component also requires a **map provider** — a separate library that h ### MapLibre provider (recommended) -**ESM:** `maplibre-gl` is a peer dependency, install it separately: - -```shell -npm install maplibre-gl -``` - -**UMD:** `maplibre-gl` is bundled — no separate install needed. +`maplibre-gl` is installed with this package (ESM) or bundled (UMD) — no separate install needed. ### ESRI provider (optional) diff --git a/package-lock.json b/package-lock.json index 6cffcc8ef..351c2b34e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@turf/union": "^7.3.5", "accessible-autocomplete": "^3.0.1", "govuk-frontend": "^5.13.0", + "maplibre-gl": "^5.23.0", "polygon-splitter": "^0.0.11", "preact": "^10.27.2", "tslib": "^2.8.1" @@ -65,7 +66,6 @@ "jest-expect-message": "^1.1.3", "likec4": "^1.50.0", "mapbox-gl-snap": "^1.1.9", - "maplibre-gl": "^5.23.0", "mini-css-extract-plugin": "^2.9.2", "node-fetch": "^3.3.2", "npm-run-all": "^4.1.5", @@ -95,7 +95,6 @@ }, "peerDependencies": { "@arcgis/core": "^5.0.9", - "maplibre-gl": "^5.23.0", "ol": "^10.10.0", "proj4": "^2.20.8" }, @@ -103,9 +102,6 @@ "@arcgis/core": { "optional": true }, - "maplibre-gl": { - "optional": true - }, "ol": { "optional": true }, @@ -6179,7 +6175,6 @@ }, "node_modules/@mapbox/jsonlint-lines-primitives": { "version": "2.0.2", - "dev": true, "engines": { "node": ">= 0.6" } @@ -6207,22 +6202,18 @@ }, "node_modules/@mapbox/point-geometry": { "version": "1.1.0", - "dev": true, "license": "ISC" }, "node_modules/@mapbox/tiny-sdf": { "version": "2.0.7", - "dev": true, "license": "BSD-2-Clause" }, "node_modules/@mapbox/unitbezier": { "version": "0.0.1", - "dev": true, "license": "BSD-2-Clause" }, "node_modules/@mapbox/vector-tile": { "version": "2.0.4", - "dev": true, "license": "BSD-3-Clause", "dependencies": { "@mapbox/point-geometry": "~1.1.0", @@ -6232,7 +6223,6 @@ }, "node_modules/@mapbox/whoots-js": { "version": "3.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=6.0.0" @@ -6242,7 +6232,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/@maplibre/geojson-vt/-/geojson-vt-6.1.0.tgz", "integrity": "sha512-2eIY4gZxeKIVOZVNkAMb+5NgXhgsMQpOveTQAvnp53LYqHGJZDidk7Ew0Tged9PThidpbS+NFTh0g4zivhPDzQ==", - "dev": true, "license": "ISC", "dependencies": { "kdbush": "^4.0.2" @@ -6252,7 +6241,6 @@ "version": "24.8.1", "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-24.8.1.tgz", "integrity": "sha512-zxa92qF96ZNojLxeAjnaRpjVCy+swoUNJvDhtpC90k7u5F0TMr4GmvNqMKvYrMoPB8d7gRSXbMG1hBbmgESIsw==", - "dev": true, "license": "ISC", "dependencies": { "@mapbox/jsonlint-lines-primitives": "~2.0.2", @@ -6273,7 +6261,6 @@ "version": "1.1.8", "resolved": "https://registry.npmjs.org/@maplibre/mlt/-/mlt-1.1.8.tgz", "integrity": "sha512-8vtfYGidr1rNkv5IwIoU2lfe3Oy+Wa8HluzQYcQi9cveU9K3pweAal/poQj4GJ0K/EW4bTQp2wVAs09g2yDRZg==", - "dev": true, "license": "(MIT OR Apache-2.0)", "dependencies": { "@mapbox/point-geometry": "^1.1.0" @@ -6283,7 +6270,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/@maplibre/vt-pbf/-/vt-pbf-4.3.0.tgz", "integrity": "sha512-jIvp8F5hQCcreqOOpEt42TJMUlsrEcpf/kI1T2v85YrQRV6PPXUcEXUg5karKtH6oh47XJZ4kHu56pUkOuqA7w==", - "dev": true, "license": "MIT", "dependencies": { "@mapbox/point-geometry": "^1.1.0", @@ -6299,7 +6285,6 @@ "version": "5.0.4", "resolved": "https://registry.npmjs.org/@maplibre/geojson-vt/-/geojson-vt-5.0.4.tgz", "integrity": "sha512-KGg9sma45S+stfH9vPCJk1J0lSDLWZgCT9Y8u8qWZJyjFlP8MNP1WGTxIMYJZjDvVT3PDn05kN1C95Sut1HpgQ==", - "dev": true, "license": "ISC" }, "node_modules/@mdx-js/mdx": { @@ -10987,7 +10972,6 @@ }, "node_modules/@types/supercluster": { "version": "7.1.3", - "dev": true, "license": "MIT", "dependencies": { "@types/geojson": "*" @@ -15113,7 +15097,6 @@ }, "node_modules/earcut": { "version": "3.0.2", - "dev": true, "license": "ISC" }, "node_modules/eastasianwidth": { @@ -17336,7 +17319,6 @@ }, "node_modules/gl-matrix": { "version": "3.4.4", - "dev": true, "license": "MIT" }, "node_modules/glob": { @@ -20362,7 +20344,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/json-stringify-pretty-compact/-/json-stringify-pretty-compact-4.0.0.tgz", "integrity": "sha512-3CNZ2DnrpByG9Nqj6Xo8vqbjT4F6N+tb4Gb28ESAZjYZ5yqvmc56J+/kuIwkaAMOyblTQhUW7PxMkUb8Q36N3Q==", - "dev": true, "license": "MIT" }, "node_modules/json5": { @@ -20403,7 +20384,6 @@ }, "node_modules/kdbush": { "version": "4.0.2", - "dev": true, "license": "ISC" }, "node_modules/keyv": { @@ -21327,7 +21307,6 @@ "version": "5.23.0", "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-5.23.0.tgz", "integrity": "sha512-aou8YBNFS8uVtDWFWt0W/6oorfl18wt+oIA8fnXk1kivjkbtXi9gGrQvflTpwrR3hG13aWdIdbYWeN0NFMV7ag==", - "dev": true, "license": "BSD-3-Clause", "dependencies": { "@mapbox/jsonlint-lines-primitives": "^2.0.2", @@ -23951,7 +23930,6 @@ }, "node_modules/minimist": { "version": "1.2.8", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -24041,7 +24019,6 @@ }, "node_modules/murmurhash-js": { "version": "1.0.0", - "dev": true, "license": "MIT" }, "node_modules/nano-spawn": { @@ -25142,7 +25119,6 @@ }, "node_modules/pbf": { "version": "4.0.1", - "dev": true, "license": "BSD-3-Clause", "dependencies": { "resolve-protobuf-schema": "^2.1.0" @@ -27186,7 +27162,6 @@ }, "node_modules/potpack": { "version": "2.1.0", - "dev": true, "license": "ISC" }, "node_modules/powershell-utils": { @@ -27355,7 +27330,6 @@ "version": "3.6.1", "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.1.tgz", "integrity": "sha512-VG2K63Igkiv9p76tk1lilczEK1cT+kCjKtkdhw1dQZV3k3IXJbd3o6Ho8b9zJZaHSnT2hKe4I+ObmX9w6m5SmQ==", - "dev": true, "license": "MIT" }, "node_modules/proxy-addr": { @@ -27499,7 +27473,6 @@ }, "node_modules/quickselect": { "version": "3.0.0", - "dev": true, "license": "ISC" }, "node_modules/range-parser": { @@ -28281,7 +28254,6 @@ }, "node_modules/resolve-protobuf-schema": { "version": "2.1.0", - "dev": true, "license": "MIT", "dependencies": { "protocol-buffers-schema": "^3.3.1" @@ -29393,7 +29365,6 @@ }, "node_modules/rw": { "version": "1.3.3", - "dev": true, "license": "BSD-3-Clause" }, "node_modules/safe-array-concat": { @@ -30881,7 +30852,6 @@ }, "node_modules/supercluster": { "version": "8.0.1", - "dev": true, "license": "ISC", "dependencies": { "kdbush": "^4.0.2" @@ -31329,7 +31299,6 @@ }, "node_modules/tinyqueue": { "version": "3.0.0", - "dev": true, "license": "ISC" }, "node_modules/tldts": { diff --git a/package.json b/package.json index 96154e0f9..e8e3bb39c 100755 --- a/package.json +++ b/package.json @@ -134,7 +134,6 @@ }, "peerDependencies": { "@arcgis/core": "^5.0.9", - "maplibre-gl": "^5.23.0", "ol": "^10.10.0", "proj4": "^2.20.8" }, @@ -142,9 +141,6 @@ "@arcgis/core": { "optional": true }, - "maplibre-gl": { - "optional": true - }, "ol": { "optional": true }, @@ -194,7 +190,6 @@ "jest-expect-message": "^1.1.3", "likec4": "^1.50.0", "mapbox-gl-snap": "^1.1.9", - "maplibre-gl": "^5.23.0", "mini-css-extract-plugin": "^2.9.2", "node-fetch": "^3.3.2", "npm-run-all": "^4.1.5", @@ -253,6 +248,7 @@ "@turf/union": "^7.3.5", "accessible-autocomplete": "^3.0.1", "govuk-frontend": "^5.13.0", + "maplibre-gl": "^5.23.0", "polygon-splitter": "^0.0.11", "preact": "^10.27.2", "tslib": "^2.8.1" diff --git a/webpack.umd.mjs b/webpack.umd.mjs index a4b89b571..66ebe60ff 100755 --- a/webpack.umd.mjs +++ b/webpack.umd.mjs @@ -2,6 +2,7 @@ import path, { dirname } from 'path' import { fileURLToPath } from 'url' import fs from 'fs' +import webpack from 'webpack' import MiniCssExtractPlugin from 'mini-css-extract-plugin' import CssMinimizerPlugin from 'css-minimizer-webpack-plugin' import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts' @@ -30,7 +31,10 @@ const createUMDConfig = (entryName, entryPath, libraryPath, outDir, isCore = fal }), new RemoveFilesPlugin({ before: { include: [path.resolve(__dirname, outDir)] } - }) + }), + // There's no Esri provider in UMD, so Esri code can never run here: leave out + // @arcgis/core and the datasets Esri adapter rather than bundling ~100 MB of chunks. + new webpack.IgnorePlugin({ resourceRegExp: /^@arcgis\/core|esriLayerAdapter/ }) ] if (isCore) {