feat: convert to npm workspaces monorepo with per-package publishing#368
Draft
alexluckett wants to merge 23 commits into
Draft
feat: convert to npm workspaces monorepo with per-package publishing#368alexluckett wants to merge 23 commits into
alexluckett wants to merge 23 commits into
Conversation
maplibre-gl is already externalised by rollup for ESM builds, making it functionally a peer dependency. This aligns package.json with the build behaviour and the existing docs guidance, consistent with how @arcgis/core and ol are declared. Also removes a try/catch in the ESRI provider that was swallowing the native module-not-found error with a less informative message.
Move beta providers (esri, openlayers, open-names) and beta plugins (scale-bar, datasets, draw-ml, draw-es, draw-ol, frame, map-styles, use-location) to their canonical locations at the root of providers/ and plugins/ directories. This aligns with the new npm workspaces monorepo structure where publishConfig.tag will indicate beta status rather than directory convention.
Add package.json files for maplibre (stable), esri, openlayers, and open-names (beta) providers. Each declares @defra/interactive-map and required engine peer dependencies, with files field limiting published output to dist/ only.
…l workspace packages
- Remove ./css export from interact plugin (no SCSS source files) - Add missing ./css export to draw-ol plugin (has SCSS source files) - Add rollup entry for datasets maplibre adapter sub-path export - Add adapter index.js re-exporting maplibreLayerAdapter as named export - Fix publish script: replace npm publish --prefix with npm publish ./ (--prefix targets the npm prefix dir, not the package dir; bare paths are treated as git URLs — ./ prefix is required for local directories)
# Conflicts: # plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.js
Main-side commits added logger imports at the old beta/ directory depth. The merge auto-applied them verbatim onto the flattened paths, leaving one too many '../' levels. Build (rollup) caught these; jest masked them via mocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
@defra/interactive-mapcurrently ships as a single npm package where map provider dependencies (maplibre-gl,@arcgis/core,ol, etc.) are declared as optional peer dependencies at the package root.A single
package.jsoncannot declare different peer dependencies for different sub-path exports. A consumer installsinteractive-mapbut npm has no knowledge of whether they're using the MapLibre or ESRI provider — npm's checks run at a different level. The result: any consuming service can silently drop a required map provider and npm won't flag the breakage. In the case offorms-engine-plugin,maplibre-glwas almost accidentally dropped with no build-time error — the build would have succeeded and failed only at runtime, potentially in production.The only way to make
maplibre-gla required peer dependency of the MapLibre provider — without also forcing ESRI consumers to install it — is to give each provider and plugin its own published package.Solution
Converts the repository to an npm workspaces monorepo. Each provider and plugin becomes its own scoped npm package with required peer dependencies based only on what that package actually needs. The existing file hierarchy, CI pipeline, and build system remain architecturally consistent — publishing gains a loop to publish each package individually.
New package naming convention:
Benefits:
What changed
package.jsonwith scoped name and required peer depsbeta/directory is dropped — beta status is now signalled viapublishConfig.tag: "beta"per package rather than file hierarchyscripts/publish-package.shextended to stamp lockstep versions into all workspace packages and publish each one./adapters/maplibresub-path exportnode_modules/import paths indraw-mlreplaced with publicMapboxDrawAPI equivalentsnpm publish --prefixwas silently publishing the root package instead of each workspace packageConsumer migration
The only breaking change is the import path. Update sub-path imports to the new package names:
@defra/interactive-map/providers/maplibre@defra/interactive-map-provider-maplibre@defra/interactive-map/plugins/interact@defra/interactive-map-plugin-interact@defra/interactive-map/plugins/search@defra/interactive-map-plugin-search@defra/interactive-map/plugins/datasets/adapters/maplibre@defra/interactive-map-plugin-datasets/adapters/maplibre