Mathjax: ES6 export

Created on 25 May 2018  路  8Comments  路  Source: mathjax/MathJax

Might you provide an ES6 module export? Thanks!

Feature Request

Most helpful comment

@tannakartikey, I think you should be able to do that if you change the Typescript configuration to output ES6 instead of ES5. You will probably want to use the direct approach to loading and configuring MathJax, rather than MathJax's components mechanism.

All 8 comments

MathJax would have to be restructured for this to make sense. Can you say something more about your use case?

We are in the process of rewriting MathJax for version 3 and this will consist of proper modules. We are currently in alpha release (see the MathJax v3 repository).

Just would like to provide our users (of SVG-edit) with the option of using a fully-ES6-module-based version of our MathJax extension (assuming your own extensions, for our needs, TeX-AMS-MML_SVG.js, could also be made available as modules). Nothing critical, just something that'd be nice...

Good to know about the v3 repo, thanks! I can close this issue, but it'd be nice to confirm if the SVG extension mentioned above will work and work modularly with v3...

That will not be possible in version 2.7, so you will have to wait for version 3.0 for that; but yes, everything in version 3 will be modules.

Great, thanks!

@dpvc now with version 3 released can ES6 modules be used on the browser side?

@tannakartikey, Version 3 is written in Typescript, and transpiled to ES5, and then webpacked to form single-file downloads (and also dynamically loaded components). You could modify the tsconfig.json to produce ES6 files instead; that might allow you to use <script type="module" src="..."> to load the MathJax files as ES6 modules. I have not tried it. You could probably webpack those in order to make a single ES6 file as well. Finally, for testing purposes, we use SystemJS to load the (non-webpacked) transpiled js files (ES5), and I assume you could use that for the ES6 files if the <script type="module"> approach doesn't work. You can see our interactive testing lab in the v3-tools branch of the MathJax-dev repository.

Thanks @dpvc

I will look into everything you have mentioned. Let me explain my use case as well.

I want to use MathJAX in a React application and want to use ES6 modules and Webpack to include MathJAX in the project. I don't want to use <script> if possible.

@tannakartikey, I think you should be able to do that if you change the Typescript configuration to output ES6 instead of ES5. You will probably want to use the direct approach to loading and configuring MathJax, rather than MathJax's components mechanism.

Was this page helpful?
0 / 5 - 0 ratings