From fe0e80974223f33baa3afa6351becbcb5aa43298 Mon Sep 17 00:00:00 2001 From: Alexader Date: Wed, 9 May 2018 12:17:19 +0300 Subject: [PATCH 1/2] Fix #23180 - Generating source maps with relative path in sourceRoot option produces maps with absolute file paths --- src/compiler/commandLineParser.ts | 2 -- tests/baselines/reference/commonSourceDirectory.js | 2 +- tests/baselines/reference/commonSourceDirectory.js.map | 2 +- .../reference/commonSourceDirectory.sourcemap.txt | 8 ++++---- tests/baselines/reference/commonSourceDirectory_dts.js | 2 +- .../baselines/reference/commonSourceDirectory_dts.js.map | 2 +- .../reference/commonSourceDirectory_dts.sourcemap.txt | 8 ++++---- .../tsConfig/Default initialized TSConfig/tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../Initialized TSConfig with files options/tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- 16 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f648bddefe9a7..395fe633a03f8 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -443,7 +443,6 @@ namespace ts { { name: "sourceRoot", type: "string", - isFilePath: true, paramType: Diagnostics.LOCATION, category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, @@ -451,7 +450,6 @@ namespace ts { { name: "mapRoot", type: "string", - isFilePath: true, paramType: Diagnostics.LOCATION, category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, diff --git a/tests/baselines/reference/commonSourceDirectory.js b/tests/baselines/reference/commonSourceDirectory.js index ca705a5b34ed8..44991d1b84e73 100644 --- a/tests/baselines/reference/commonSourceDirectory.js +++ b/tests/baselines/reference/commonSourceDirectory.js @@ -24,7 +24,7 @@ exports.__esModule = true; var foo_1 = require("foo"); var bar_1 = require("bar"); foo_1.x + bar_1.y; -//# sourceMappingURL=/app/myMapRoot/index.js.map +//# sourceMappingURL=../myMapRoot/index.js.map //// [/app/bin/index.d.ts] /// diff --git a/tests/baselines/reference/commonSourceDirectory.js.map b/tests/baselines/reference/commonSourceDirectory.js.map index fd88719859b7a..737c1dc3df1e6 100644 --- a/tests/baselines/reference/commonSourceDirectory.js.map +++ b/tests/baselines/reference/commonSourceDirectory.js.map @@ -1,2 +1,2 @@ //// [/app/bin/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,2BAAwB;AACxB,2BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,yCAAyC;AACzC,2BAAwB;AACxB,2BAAwB;AACxB,OAAC,GAAG,OAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory.sourcemap.txt b/tests/baselines/reference/commonSourceDirectory.sourcemap.txt index c880d2d0059fb..567e435ce555c 100644 --- a/tests/baselines/reference/commonSourceDirectory.sourcemap.txt +++ b/tests/baselines/reference/commonSourceDirectory.sourcemap.txt @@ -1,7 +1,7 @@ =================================================================== JsFile: index.js -mapUrl: /app/myMapRoot/index.js.map -sourceRoot: /app/mySourceRoot/ +mapUrl: ../myMapRoot/index.js.map +sourceRoot: mySourceRoot/ sources: index.ts =================================================================== ------------------------------------------------------------------- @@ -43,7 +43,7 @@ sourceFile:index.ts 3 > ^^^ 4 > ^^^^^^^ 5 > ^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > 2 >x @@ -56,4 +56,4 @@ sourceFile:index.ts 4 >Emitted(6, 18) Source(4, 6) + SourceIndex(0) 5 >Emitted(6, 19) Source(4, 7) + SourceIndex(0) --- ->>>//# sourceMappingURL=/app/myMapRoot/index.js.map \ No newline at end of file +>>>//# sourceMappingURL=../myMapRoot/index.js.map \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory_dts.js b/tests/baselines/reference/commonSourceDirectory_dts.js index 249edecedddaa..1009ff9475bb2 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.js +++ b/tests/baselines/reference/commonSourceDirectory_dts.js @@ -15,7 +15,7 @@ export const x = y; exports.__esModule = true; /// exports.x = y; -//# sourceMappingURL=/app/myMapRoot/index.js.map +//# sourceMappingURL=../src/myMapRoot/index.js.map //// [/app/bin/index.d.ts] /// diff --git a/tests/baselines/reference/commonSourceDirectory_dts.js.map b/tests/baselines/reference/commonSourceDirectory_dts.js.map index 552da577884d8..2950d165917a6 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.js.map +++ b/tests/baselines/reference/commonSourceDirectory_dts.js.map @@ -1,2 +1,2 @@ //// [/app/bin/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"/app/mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,wCAAwC;AAC3B,QAAA,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;AAAA,wCAAwC;AAC3B,QAAA,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt b/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt index 925a3d30ed4a2..fb2ef3596c602 100644 --- a/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt +++ b/tests/baselines/reference/commonSourceDirectory_dts.sourcemap.txt @@ -1,7 +1,7 @@ =================================================================== JsFile: index.js -mapUrl: /app/myMapRoot/index.js.map -sourceRoot: /app/mySourceRoot/ +mapUrl: ../src/myMapRoot/index.js.map +sourceRoot: mySourceRoot/ sources: index.ts =================================================================== ------------------------------------------------------------------- @@ -25,7 +25,7 @@ sourceFile:index.ts 4 > ^^^ 5 > ^ 6 > ^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >export const 2 > @@ -40,4 +40,4 @@ sourceFile:index.ts 5 >Emitted(4, 14) Source(2, 19) + SourceIndex(0) 6 >Emitted(4, 15) Source(2, 20) + SourceIndex(0) --- ->>>//# sourceMappingURL=/app/myMapRoot/index.js.map \ No newline at end of file +>>>//# sourceMappingURL=../src/myMapRoot/index.js.map \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 0b72c3fd8a779..261cdca7011c3 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json index 4d5c6053bcc76..d3a9f8e9f4708 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index f84c7f3abf3f2..8484e61bcfadd 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index b65582c7841d2..35aa1cf7eab87 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 86d25e2362ac7..fbc441b823ce4 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index b623b1198c232..f758c1f6c20e4 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 0b72c3fd8a779..261cdca7011c3 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index ea9df560138df..cdb52963ccb2f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index bab4947a8e51b..fd6419e1e3531 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -47,8 +47,8 @@ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ From f007c3586bb9755ff29d1384435943669efed8d4 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Tue, 12 Jun 2018 18:17:04 +0300 Subject: [PATCH 2/2] mapRoot is not filePath --- tests/cases/fourslash/getEditsForFileRename_tsconfig.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/cases/fourslash/getEditsForFileRename_tsconfig.ts b/tests/cases/fourslash/getEditsForFileRename_tsconfig.ts index 611bff185393a..62a4d835f5f4d 100644 --- a/tests/cases/fourslash/getEditsForFileRename_tsconfig.ts +++ b/tests/cases/fourslash/getEditsForFileRename_tsconfig.ts @@ -4,7 +4,6 @@ ////{ //// "compilerOptions": { //// "baseUrl": "./old", -//// "mapRoot": "../src/old", //// "paths": { //// "foo": ["old"], //// }, @@ -25,7 +24,6 @@ verify.getEditsForFileRename({ `{ "compilerOptions": { "baseUrl": "new", - "mapRoot": "new", "paths": { "foo": ["new"], },