Skip to content

ml-matrix Matrix constructor fails #1221

Answered by mbostock
kletts asked this question in Q&A
Discussion options

You must be logged in to vote

You can fix this by changing how you import ml-matrix like so:

import {Matrix} from "npm:ml-matrix/src/index.js/+esm";

The problem is that the default entry point for ml-matrix is matrix.mjs, which imports matrix.js, which is CommonJS generated by rollup. Unfortunately converting ES modules to CommonJS and back again loses information. If you look at the generated matrix.js, it imports is-any-array like this:

var isAnyArray = require('is-any-array');

and then references isAnyArray.isAnyArray. So when jsDelivr tries to convert this CommonJS back to an ES module, you get:

import t from"/npm/[email protected]/+esm";

and t.isAnyArray. But here t is the default export, not a namespace, so you…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@kletts
Comment options

@Fil
Comment options

Answer selected by kletts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn’t working
3 participants
Converted from issue

This discussion was converted from issue #1220 on April 10, 2024 23:08.