widcardw / markdown-it-asciimath

MIT License
3 stars 0 forks source link

Question: Reduce package size? #3

Closed tk-100 closed 1 year ago

tk-100 commented 1 year ago

I would like to include your module in a single page application that already uses katex (latest version, installed with npm, included as dependency in package.json).

I noticed that the size of my project increases significantly (+292 kB) when I add markdown-it-asciimath.

However, if I add markdown-it-texmath (which also uses katex) for comparison, the size hardly changes (+5 kB).

Could it be that markdown-it-asciimath itself includes a full katex implementation and doesn't use the one already included in my project? If so, would it be possible to change this so that katex shows up as a dependency but isn't included in your module?

widcardw commented 1 year ago

Yeah, I use unbuild to build this module, and it would include the full KaTeX. I have thought about how to reduce the package size, such as changing KaTeX to peer dependencies, but I used to think "it's okay". However, it's better to separate KaTeX from this single module...

I will try to move KaTeX to peer dependencies, as well as change the README (since KaTeX should be installed with this module). If it really reduces the package size and would not cause any problem, I will release a new version. Thanks for your report!

widcardw commented 1 year ago

Now in v0.5.5, I change KaTeX to peer dependencies, that means you should install katex separately, otherwise the plugin would not work. If this plugin causes any problem, please report me later, thanks.

tk-100 commented 1 year ago

That was lightning fast - thanks a lot! I performed some small tests:

Page for my students: https://kippenbergs.de/mint-ascii-math PS: Would you be ok if I link your profile as "thanks" at the bottom of the page?

widcardw commented 1 year ago

It depends on you! It's also okay to mark https://asciimath.widcard.win or https://github.com/widcardw/asciimath-parser as the source of this tool.

Note that the syntax of this tool is not exactly consistent with the original project (http://asciimath.org) especially the matrix, so it's recommended to add https://asciimath.widcard.win as the user manual, or give some examples in the page.

BTW, the matrix syntax is like [a, b; c, d], instead of [[a, b], [c, d]].

tk-100 commented 1 year ago

Thanks for the clarification, I'm happy to add that.