Skip to content

feat: add subpath exports for individual layer modules - #224

Open
jsve wants to merge 1 commit into
geoarrow:mainfrom
jsve:fix/layer-subpath-exports
Open

jsve wants to merge 1 commit into
geoarrow:mainfrom
jsve:fix/layer-subpath-exports

Conversation

@jsve

@jsve jsve commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Closes #221

Summary

Adds a ./layers/* subpath export so each layer module can be imported on its own:

import { GeoArrowPolygonLayer } from "@geoarrow/deck.gl-geoarrow/layers/polygon-layer";

Importing through the package root makes the bundler resolve every layer module before tree-shaking. That includes the ones that import @deck.gl/geo-layers (A5, Geohash, H3 hexagon, S2, trips) and @deck.gl/aggregation-layers (heatmap). With subpaths, an app that only uses, say, the path, polygon, and scatterplot layers never has to resolve those packages.

Changes

  • package.json: add ./layers/* pointing at dist/layers/*.js / *.d.ts. The root "." export is unchanged.
  • ./layers/text-layer: null keeps the experimental text layer out of the subpaths, so it is still only reachable as _GeoArrowTextLayer from the root.
  • README: short section documenting the subpath imports.

Note that a subpath exposes everything its module exports, e.g. defaultProps from path-layer and getPolygonExterior/getMultiPolygonExterior from polygon-layer. Happy to switch to an explicit list of layer entries, or adjust those module exports, if you'd prefer to keep them out of the public surface.

Testing

  • pnpm typecheck, pnpm test, and biome ci . pass.
  • Packed the package with pnpm pack and bundled it with Vite in a consumer project that has @deck.gl/core and @deck.gl/layers, but not @deck.gl/geo-layers or @deck.gl/aggregation-layers:
    • importing path/polygon/scatterplot from the root fails: failed to resolve import "@deck.gl/geo-layers" from ".../dist/layers/trips-layer.js"
    • importing the same layers from their subpaths bundles without pulling in either package
    • layers/text-layer is rejected by Vite, Node (ERR_PACKAGE_PATH_NOT_EXPORTED) and TypeScript (TS2307)
  • TypeScript (moduleResolution: "bundler") resolves the subpath declaration files with full types.

Expose each module in dist/layers as @geoarrow/deck.gl-geoarrow/layers/<name>
so consumers can import only the layers they use, without their bundler
having to resolve @deck.gl/geo-layers or @deck.gl/aggregation-layers.

The root entry point is unchanged. The experimental text layer stays
reachable only as _GeoArrowTextLayer from the root.

Closes geoarrow#221
@kylebarron

Copy link
Copy Markdown
Member

I commented on this in #221

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add public subpath exports for individual layer modules

2 participants