MatejBransky/react-katex

react-katex.modern.js fails to compile in Create React App

TyMick opened this issue · 0 comments

Describe the bug

After upgrading to @matejmazur/react-katex v3.1.2 in my Create React App project, the project now fails to compile, showing the following error message in the browser:

Failed to compile

./node_modules/@matejmazur/react-katex/dist/react-katex.modern.js 14:15
Module parse failed: Unexpected token (14:15)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| }) => {
|   const E = c || (i ? "div" : "span"),
>         f = e ?? a,
|         [h, p] = n({
|     innerHtml: ""

This error occurred during the build time and cannot be dismissed.

This error also occurs with @matejmazur/react-katex v3.1.1, but my project does compile correctly with v3.1.0.

To Reproduce

If you don't mind cloning a branch of my project, that'll give you the most complete context for the error:

git clone --single-branch --branch react-katex-bug https://github.com/tywmick/rt-simulator.git
yarn
yarn start

Expected behavior

For my page to compile correctly like it did with v3.0.2.

Screenshots

"Failed to compile" error in Chrome

Desktop (please complete the following information):

  • OS: macOS 10.15.6 (19G73)
  • Browsers:
    • Chrome 84.0.4147.105 (Official Build) (64-bit)
    • Safari 13.1.2 (15609.3.5.1.3)
    • Firefox 79.0 (64-bit)

Additional context

I think I've figured out how to fix it, the issue being the new modern bundle being mapped to the "module" field in package.json. I'll write a PR with my fix next—I just felt like I should document the issue itself separately for some reason.