josdejong/mathjs

Load mathjs in a browser module (ES import)

Open

#1.841 geöffnet am 3. Mai 2020

Auf GitHub ansehen
 (13 Kommentare) (4 Reaktionen) (0 zugewiesene Personen)JavaScript (1.298 Forks)batch import
featurehelp wanted

Repository-Metriken

Stars
 (13.832 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Currently it looks like it's not possible to use mathjs in a browser module like:

<script type="module">
  import { create, all } from 'mathjs'
</script>

I think the existing bundles in dist do not have the right exports to be consumed as an ES module.

What should work (but doesn't) is loading like:

import { create, all} from 'mathjs/main/es/index.js'

I think the reason is that many import paths in the code are missing the explicit "*.js" extension, which is the normal way to go in nodejs and webpack environments, but not in browser ES environments which require a real path to a file.

Contributor Guide