question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to handle mathlive.mjs with webpack

See original GitHub issue

I was using https://github.com/sveltejs/template-webpack And only one line, that is import 'mathlive', is added into App.svelte

<script>
 import 'mathlive'
 ......
</script>

And When I run npm run dev, it reports error:

ERROR in ./node_modules/mathlive/dist/mathlive.mjs 2:180267
Module parse failed: Unexpected token (2:180267)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| /* MathLive 0.53.3  */
<here is the code of mathlive ...>

Is there any required setup of webpack to use mathlive?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
arnogcommented, Jul 20, 2020

FYI, I have a fix pending that will remove the need for import.meta.url. I just need to do a bit more testing.

0reactions
arnogcommented, Apr 14, 2022

Two years later, but there is still an issue in the toolchain. Webpack 4, in particular, does not support the optional chaining operator (although all evergreen browser do). To work around this MathLive is now packaged differently:

  • the mathlive.min.js library is compiled targeting an older version of JavaScript that should be compatible with Webpack 4
  • the mathlive.min.mjs library is compiled for up to date toolchains.

So, if you run into errors integrating MathLive, try to use the dist/mathlive.min.js library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add MathLive to your Project - CortexJS
Your bundler/transpiler (for example Rollup , WebPack , Babel , TypeScript ) will locate the MathLive library in the node_modules directory and ...
Read more >
I would like to know how to install and use mathlive in NuxtJS
If I run nuxt webpack --dev , I can see an entry in the rules for .mjs . However, I still receive the...
Read more >
Module Methods - webpack
Specify a whole group of dependencies using a path to the directory , an option to includeSubdirs , a filter for more fine...
Read more >
How to transpile ES modules with webpack and Node.js
js runtime to treat JavaScript code as ESM, since the Node runtime treats JavaScript code as a CommonJS module by default. In this...
Read more >
systemjs-webpack-interop - npm
systemjs -webpack-interop is an npm package that exports functions that help you create a webpack bundle that is consumable by SystemJS as an ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found