Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-bundling map-interface dependencies #1

Open
falseinput opened this issue Dec 1, 2024 · 0 comments
Open

Pre-bundling map-interface dependencies #1

falseinput opened this issue Dec 1, 2024 · 0 comments

Comments

@falseinput
Copy link

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/[email protected]/index.esm.js"
      },
      "scopes": {
        "https://ga.jspm.io/": {
          "@mapbox/point-geometry": "https://ga.jspm.io/npm:@mapbox/[email protected]/index.js",
          "@mapgrab/map-interface-types": "https://ga.jspm.io/npm:@mapgrab/[email protected]/src/index.js",
          "@mapgrab/map-locator": "https://ga.jspm.io/npm:@mapgrab/[email protected]/src/index.js",
          "@turf/bbox-clip": "https://ga.jspm.io/npm:@turf/[email protected]/dist/esm/index.js",
          "@turf/helpers": "https://ga.jspm.io/npm:@turf/[email protected]/dist/esm/index.js",
          "@turf/invariant": "https://ga.jspm.io/npm:@turf/[email protected]/dist/esm/index.js",
          "@turf/meta": "https://ga.jspm.io/npm:@turf/[email protected]/dist/esm/index.js",
          "tslib": "https://ga.jspm.io/npm:[email protected]/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.

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

No branches or pull requests

1 participant