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

Transpile to JS considering paths from tsconifg #18951

Closed
wclr opened this issue Oct 4, 2017 · 3 comments
Closed

Transpile to JS considering paths from tsconifg #18951

wclr opened this issue Oct 4, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@wclr
Copy link

wclr commented Oct 4, 2017

For convenience to get rid of relative paths one may use:

import { sharedStuff } from '~/shared'

For this to work in tsconfig I have:

"baseUrl": ".",
    "paths": {
      "~/*": ["./*"]
    }

Transpired JS still have require('~/shared') and node will fail to find the module. Loaders like webpack has mechanics for this, but node as a standard runtime for JS AFAIN has not standardized/common approach to handle such paths correctly.

So if TS uses paths for looking up of the modules, why for convenience not convert such paths to relative to module paths so node (and other loaders) could require it? This probably should be a compiler option.

What do you think? Am I missing something why it can not be implemented? Maybe some unsafe/irrelevant cases of paths mapping?

@mhegazy
Copy link
Contributor

mhegazy commented Oct 4, 2017

Please see #16640

@mhegazy mhegazy added the Duplicate An existing issue was already created label Oct 4, 2017
@wclr
Copy link
Author

wclr commented Oct 4, 2017

Ok, I see, but there is was no strong reasoning why this should not be implemented. Yes, loaders can do it. But nodejs can not, would require to use some not standard way. Also, it would really simplify configuration because would be no need to configure loaders for this. And of course, this should be the optional feature, who want to live old way - always will.

I mean, TS could make a goodness for devs. I propose to think about it again (invite others team members), maybe there are strong reasons not to do this, but maybe not.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 19, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants