Tom: wanna try to fix gl-matrix?

I’m getting glMatrix = dt: invalid module on a whole bunch of notebooks that try to require gl-matrix. The alternative works okay, but maybe isn’t ideal.

There are a whole bunch of now broken notebooks

It seems like maybe gl-matrix 2.X worked okay with a bare require but now version 3 does not?

I don’t have time to investigate deeper. Maybe someone else wants to take a look?

Also: folks, at least major-version pin your external dependencies!

Maybe this would be a good new feature for the :sparkles: magic fixer :sparkles: !

In the meantime, you can use import('gl-matrix'). Looks like the most recent gl-matrix npm publish was 6 months ago.

I think I’d prefer an audit feature that tells me which require or import calls have no explicit version. Perhaps Observable could warn if I publish a notebook without a pinned (major) version?

1 Like

At some point in the future, we plan to ship automatic version pinning that will function similarly to a yarn.lock, pinning the exact version of transitive dependencies the first time they are loaded (and some sort of UI for upgrading dependencies). But we’re still working out the details, implementation, and user interface.


In the meantime, you can use import('gl-matrix').

Is this a good idea as general practice? It still doesn’t work in a bunch of browsers, right?

Firefox was the major hold-out, but now that the last two versions of FF have supported dynamic import, it’s pretty close to the point where we can recommend without reservation.

1 Like

So, works in current FF, Chrome, Safari, up-to-date mobile browsers, but no Edge?

Is there any estimate of the proportion of random web visitors who have old browsers without dynamic import?

import(module_name) is also fairly experimental because it relies on unpkg’s import rewriting. But you can import(url) to load an arbitrary ES module.

I’m not sure that Edge is worth optimizing for at the moment, given that its market share is below IE, and that future versions will be based on Chromium.

Not 100% on-topic, but for those who like the more targeted imports of, I cloned a bunch of gl-matrix modules into some notebooks:

I’m not sure how I feel about cloning existing/established code into notebooks like this, but it was pretty low-hanging fruit and has the nice result that you can directly click the imported token and jump to the implementation.

1 Like