Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Pre-bundling map-interface dependencies #1

Description

@falseinput

Hi,

thanks for your work on this project!

I wanted to try out MapGrab to write tests for https://github.com/falseinput/geogrid-maplibre-gl, but when I imported
the map interface via script tag I got:

Uncaught TypeError: Failed to resolve module specifier "tslib". Relative references must start with either "/", "./", or "../".

map-interface is exported as ESM module, so theoretically it allows me to use it without a bundler, however @mapgrab/map-interface/index.esm.js imports dependencies like the tslib explicitly. In other words: dependencies are not pre-bundled.

To get it work I had to use JSPM Generator to generate import maps:

<script type="importmap">
    {
      "imports": {
        "@mapgrab/map-interface": "https://ga.jspm.io/npm:@mapgrab/map-interface@0.0.3/index.esm.js"
      },
      "scopes": {
        "https://ga.jspm.io/": {
          "@mapbox/point-geometry": "https://ga.jspm.io/npm:@mapbox/point-geometry@1.1.0/index.js",
          "@mapgrab/map-interface-types": "https://ga.jspm.io/npm:@mapgrab/map-interface-types@0.1.1/src/index.js",
          "@mapgrab/map-locator": "https://ga.jspm.io/npm:@mapgrab/map-locator@0.0.2/src/index.js",
          "@turf/bbox-clip": "https://ga.jspm.io/npm:@turf/bbox-clip@7.0.0/dist/esm/index.js",
          "@turf/helpers": "https://ga.jspm.io/npm:@turf/helpers@7.1.0/dist/esm/index.js",
          "@turf/invariant": "https://ga.jspm.io/npm:@turf/invariant@7.1.0/dist/esm/index.js",
          "@turf/meta": "https://ga.jspm.io/npm:@turf/meta@7.0.0/dist/esm/index.js",
          "tslib": "https://ga.jspm.io/npm:tslib@2.8.1/tslib.es6.mjs"
        }
      }
    }
</script>
<script type="module">
  import * as MapInterface from "@mapgrab/map-interface";

  // ...
</script>

While this works, I had spend some time trying to figure it out. The way import maps work or the fact they exist is not yet well known in general.

Pre-bundling this package would be great, because it would just allow to import as a module without extra steps.

Btw. I was trying to make a PR, but map-interface is a submodule and I could not clone it.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions