Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 beta mathtools prescript error #3080

Closed
pkra opened this issue Aug 7, 2023 · 2 comments
Closed

v4 beta mathtools prescript error #3080

pkra opened this issue Aug 7, 2023 · 2 comments

Comments

@pkra
Copy link
Contributor

pkra commented Aug 7, 2023

Not sure if it's related to #3078.

While investigating another issue, I ran into a crash from mathtools when using v4 client-side.

Minimal example:

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <title>mj test</title>
</head>
<body>
<script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.3/tex-mml-chtml.js">
</script>
\(\require{mathtools}  \prescript {h_{l-1}}{}{P}\)
</body>
</html>

The console logs out:

Uncaught ReferenceError: can't access lexical declaration 'F' before initialization
    r https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.3/input/tex/extensions/mathtools.js:1
    <anonymous> https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.3/input/tex/extensions/mathtools.js:1
    <anonymous> https://cdn.jsdelivr.net/npm/mathjax@4.0.0-beta.3/input/tex/extensions/mathtools.js:1
mathtools.js:1:183
@dpvc
Copy link
Member

dpvc commented Aug 7, 2023

It's actually #3072, not 3078. I know what the problem is, but unfortunately I can't give you a patch as the file needs too be rebuilt.

It has to do with how webpack handled the Symbol class in input/tex/Symbol.js, and requires that we change the name of that class to something else so that it doesn't clash with the default Symbol class in javascript. Webpack makes the imported Symbol a global variable, overriding the default one, but it also references Symbol in its startup code, leading to the error you are seeing (when it is minified). This only affects the packing of ESM modules because the imports are handled differently there. I thought I had worked around it, but it only worked when input/tex/Symbol.js was imported directly, not when it is a shared library, as it is in TeX packages like mathtools. This also affects several other packages as well.

The fix requires a new release, but I can't do that until we are a little father with the code cleanup PRs.

@pkra
Copy link
Contributor Author

pkra commented Aug 7, 2023

Thanks, Davide.

@pkra pkra closed this as completed Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants