MathJax-src icon indicating copy to clipboard operation
MathJax-src copied to clipboard

fix: Remove circular dependency

Open edeustace opened this issue 3 years ago • 3 comments

When bundling mathjax - you are warned that there is a circular dependency:

code: CIRCULAR_DEPENDENCY, message: Circular dependency: node_modules/mathjax-full/js/input/tex/TexParser.js -> node_modules/mathjax-full/js/input/tex/ParseUtil.js -> node_modules/mathjax-full/js/input/tex/TexParser.js

This can lead to runtime errors as the bundler has to guess which module to define first.

This commit removes this circular dependency by moving the functions in ParseUtil that TexParser used into 2 new namespaces.

  • DimensionUtil -> matchDimen
  • StringUtil -> trimSpaces

I'm trying to be consistent with how the modules are laid out.

edeustace avatar Sep 06 '21 14:09 edeustace

Thanks for the PR. The issue's been on the todo list for some time, so I appreciate you taking it on. There are three changes I would like you to make before we can merge:

  • Rebase the PR onto the mathjax:develop branch (master branch always contains the latest stable version)
  • Move the content of ts/input/tex/StringUtil.ts into ts/util/string.ts.
  • Move the content of ts/input/tex/DimensionUtil.ts into ts/util/lengths.ts.

That should similarly take care of the circular dependency and will put all the utilities into the module where they actually should go. There might even be some scope for future code rationalisation in lengths.ts.

zorkow avatar Sep 09 '21 10:09 zorkow

Hi @zorkow - I've applied the changes you requested - however - I've noted some other circular deps that should also be fixed. I'm a bit time pressed to do all the fixes right now. So we can merge and re-visit, or if you want to keep it all on the branch?

edeustace avatar Sep 09 '21 11:09 edeustace

Nice that you guys have already tackled the problem! The Branch seems to be stable, can it be merged now?

I'm very interested in this and future fixes to this circular deps problem, since I'd like to write an Obsidian Plug-in, which can't compile on Rollup with marp-core (Markdown presentation engine), since it uses mathjax.

My issue is already linked above.

I'm also very time limited currently, but if there's something I can help with, I'll try to give it somewhat prio :)

bjesuiter avatar Oct 28 '21 18:10 bjesuiter