-
-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Labels
Description
When a ts file in a subfolder is transpiled with a source map and output to another folder (using outDir), the source map does not contain the correct relative path information to find the original source.
Example:
tsconfig.json
{
"compilerOptions": {
"sourceMap": true,
"rootDir": "ts",
"outDir": "lua"
},
"include": [
"ts/sub/foobar.ts"
]
}lua/sub/foobar.lua.map
{"version":3,"sources":["foobar.ts"],"names":[],"mappings":";MAAY","file":"foobar.lua","sourceRoot":"..\\ts"}
In this example, the map would point to lua/ts/foobar.ts instead of ts/sub/foobar.ts.
The obvious thing to do would be to fix sourceRoot in these situations:
{"version":3,"sources":["foobar.ts"],"names":[],"mappings":";MAAY","file":"foobar.lua","sourceRoot":"..\\..\\ts\\sub"}
But, looking at typescript's output for the same project, it seems they opt to include the path information in sources:
{"version":3,"file":"foobar.js","sourceRoot":"","sources":["../../ts/sub/foobar.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC"}
TS only uses sourceRoot when it's explicitly declared in tsconfig.json:
{
"compilerOptions": {
...
"sourceRoot": "ts"
},
...
}
{"version":3,"file":"foobar.js","sourceRoot":"ts/","sources":["sub/foobar.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC"}
Perhaps emulating that would be the ideal solution.
Reactions are currently unavailable