Description
Problem
tsc does not support transforming absolute module paths into relative paths for modules located outside node_modules. In client side apps, this is often not an issue because people tend to use Webpack or similar tool for transformations and bundling, but for TypeScript apps targeting Node.js, this is an issue because there is usually no need for complex transformations and bundling, and adding additional build steps and tools on top of tsc only for path transformation is cumbersome.
Example input (es2015 style):
import { myModule } from 'myModuleRoot/a/b/my_module';
Example output (CommonJS style):
const myModule = require('./a/b/my_module');
My personal opinion is that relative module paths (import { ... } from '../../xxx/yyy';
) are an abomination and make it difficult to figure out and change application structure. The possibility of using absolute paths would also be a major benefit of using TypeScript for Node.js apps.
Solution
Compiler options for tsc similar to Webpack's resolve.modules.
Could this be achieved for example with existing baseUrl
and paths
options and adding a new --rewriteAbsolute option?