Trouble requiring mapd-connector's browser-connector

Hi!

I’ve followed your How To: Require Stubborn Modules guide, but am still having trouble trying to require mapd-connector’s browser connector module.

Unfortunately the mapd-connector library is not (yet) on NPM, so I’ve copied and pasted its browser-connector.js file to a Github Gist:

https://gist.github.com/clhenrick/68ef0aee10e71fe6d8a2b2f4003d9769

and am trying to require it as follows:

MapdCon = require("https://gist.githubusercontent.com/clhenrick/68ef0aee10e71fe6d8a2b2f4003d9769/raw/af6de2b5d033e69a14d6ff6ef9fdc9b35da130c3/mapd-browser-connector.js").catch(() => window.MapdCon)

The browser-connector should expose a global object called MapdCon, which is what I’ve tried to do above, but unfortunately Observable reports MapdCon as undefined.

Here is an example Block where I can successfully load data using mapd-connector's browser-connector module:

https://bl.ocks.org/clhenrick/7e4061e69cc8ba86f15391009cc55e4e

Any advice would be appreciated, thanks in advance!

The MapD Connector is especially tricky because it’s not just an IIFE, it also has a bunch of dependencies that are not declared in the browser-connector.js. I was able to follow their basic example on GitHub and it appears to work after you jump through a few hoops:

https://beta.observablehq.com/@mbostock/hello-mapd-connector

1 Like

Terrific, thanks very much Mike for the help!

I’m fairly certain that the browser-connector bundle includes the necessary deps, (I’ll double check with my team) but it seems that part of the reason it won’t work in Observable has to do with those deps not having a Promise based API.

Anyhow, I’m excited to use MapD connector in Observable and am sure others will be as well!