Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leveraging baseURL in imports #789

Open
pkra opened this issue Mar 9, 2022 · 5 comments
Open

leveraging baseURL in imports #789

pkra opened this issue Mar 9, 2022 · 5 comments

Comments

@pkra
Copy link
Contributor

pkra commented Mar 9, 2022

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.

@dpvc
Copy link
Member

dpvc commented Mar 9, 2022

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.

@pkra
Copy link
Contributor Author

pkra commented Mar 9, 2022

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.

@dpvc
Copy link
Member

dpvc commented Mar 9, 2022

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.

@pkra
Copy link
Contributor Author

pkra commented Mar 9, 2022

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.

@dpvc
Copy link
Member

dpvc commented Mar 9, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants