Closed
Description
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?