mathjax / MathJax-src

MathJax source code for version 3 and beyond

Home Page:https://www.mathjax.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

leveraging baseURL in imports

pkra opened this issue · comments

I often find it difficult to grok the nested ../ in import statements so I was wondering if there's interest in replacing ./ and (nested) ../ with paths using the baseURL from tsconfig.

A limited test compiled fine but maybe there are technical reasons I didn't spot.

Happy to do the grunt work for this.

Maybe, I'm not sure. Because MathJax is used in several settings (web packed files in browser and node, direct access in node, potentially in <scrip type="module"> tags, and via system.js), there are a lot of interactions that need to work. Things may have changed since we set it all up years ago, so something better may work now.

I'll have to check into it and see what I can figure out.

Because MathJax is used in several settings (web packed files in browser and node, direct access in node, potentially in tags, and via system.js),

Right, I figured there could be more side effects in those corners. If there's a way for me to test those things, let me know.

I'm not able to get it to work. For example, if I change the baseURL to ./js or ./ts and use something like

import {split} from 'util/string.js';

this compiles, but the resulting js file contains

... require("util/string.js");

and so fails when the file is used in node or system.js or during webpacking. I could not find a pattern that would produce a require() that works.

Can you be more specific about what you did that worked for you? I must be missing something important.

Can you be more specific about what you did that worked for you? I must be missing something important.

No you were not. I was just very naive about this - I just meant that npx tsc didn't fail. But you nerd-sniped me to learn more about TS and path rewrite issues. I found some interesting leads but I don't know how further I'll get. It's definitely a paper-cut-bug for me but then again it's only that.

But you nerd-sniped me to learn more about TS and path rewrite issues.

:-)

If you come up with anything, let me know. I have had to put it aside for now.