MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

`mathjax-full/js/output/svg/DefaultFont.js` and `mathjax-full/js/output/chtml/DefaultFont.js` are provided as ES module at `[email protected]`

Open tamuratak opened this issue 3 years ago • 4 comments

Issue Summary

mathjax-full/js/output/svg/DefaultFont.js and mathjax-full/js/output/chtml/DefaultFont.js are provided as ES module at [email protected].

Other .js files are provided in CJS format.

It causes issues when directly using mathjax-full from Node.js applications. I would like mathjax-full to be provided fully in CJS format if possible.

Steps to Reproduce:

  1. Install [email protected]
  2. Execute cat node_modules/mathjax-full/js/output/svg/DefaultFont.js
$  cat node_modules/mathjax-full/js/output/svg/DefaultFont.js
export {MathJaxModernFont as DefaultFont} from 'mathjax-modern-font/js/output/fonts/mathjax-modern/svg.js';
export const fontName = 'mathjax-modern';

Technical details:

tamuratak avatar Oct 02 '22 23:10 tamuratak

https://github.com/mathjax/MathJax-src/issues/866#issuecomment-1294825767 suggests to use node -r esm as a workaround.

However, this workaround crashes for me. IIRC esm doesn't support mixing ESM and CJS - and my code base is using ESM.

Also, esm is somewhat (in)famous for no longer being maintained.

Of course it would be lovely if v4 could simply ship ESM instead of CJS. But for the time being, a fix would be helpful..

pkra avatar Oct 28 '22 14:10 pkra

I have made changes in the new-default-font branch that replace the DefaultFont.js file and its associated .d.ts file with an actual Typescript file, so it should compile properly to the corresponding .js file in the js/output/<jax> directory. But this required some changes to the font packages themselves, so I've published updated versions of mathjax-stix2-font, etc, that have the needed changes. I've left the latest version of the packages as the original 1.0.0-alpha.1 versions, since those are what work with [email protected], so if you want to use the updates in the new-default-font branch, you will need to install the font package with an explicit 1.0.0-beta.1 version, as in

npm install [email protected]

dpvc avatar Jan 31 '23 20:01 dpvc

npm install [email protected]

I believe it's 1.0.0-beta.1 (not sure if that's a typo or you want to align versions).

The folders in the package have also changed (much shorter - which I find quite nice).

pkra avatar Feb 01 '23 14:02 pkra

I believe it's 1.0.0-beta.1

Right you are! Sorry for the mix up. I've edited my post.

The folders in the package have also changed (much shorter - which I find quite nice).

Yes, that was one of the motivations for the update as well (and why the 1.0.0-alpha.1 versions won't work with the new new-default-font branch, which references the shorter locations).

dpvc avatar Feb 01 '23 16:02 dpvc