mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 07:45:18 -06:00
Fix the source map directory resolution with non case sensitive file names
This commit is contained in:
parent
fe8f736207
commit
710bac6d81
@ -476,7 +476,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, isAbsolutePathAnUrl: boolean) {
|
||||
export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) {
|
||||
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
||||
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
||||
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
|
||||
@ -487,7 +487,7 @@ module ts {
|
||||
|
||||
// Find the component that differs
|
||||
for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
|
||||
if (directoryComponents[joinStartIndex] !== pathComponents[joinStartIndex]) {
|
||||
if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,7 +527,8 @@ module ts {
|
||||
sourceMapData.sourceMapSources.push(getRelativePathToDirectoryOrUrl(sourcesDirectoryPath,
|
||||
node.filename,
|
||||
compilerHost.getCurrentDirectory(),
|
||||
/*isAbsolutePathAnUrl*/ true));
|
||||
compilerHost.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ true));
|
||||
sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1;
|
||||
|
||||
// The one that can be used from program to get the actual source file
|
||||
@ -692,7 +693,8 @@ module ts {
|
||||
getDirectoryPath(normalizePath(jsFilePath)), // get the relative sourceMapDir path based on jsFilePath
|
||||
combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), // this is where user expects to see sourceMap
|
||||
compilerHost.getCurrentDirectory(),
|
||||
/*isAbsolutePathAnUrl*/ true);
|
||||
compilerHost.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ true);
|
||||
}
|
||||
else {
|
||||
sourceMapData.jsSourceMappingURL = combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL);
|
||||
@ -3170,7 +3172,8 @@ module ts {
|
||||
getDirectoryPath(normalizeSlashes(jsFilePath)),
|
||||
declFileName,
|
||||
compilerHost.getCurrentDirectory(),
|
||||
/*isAbsolutePathAnUrl*/ false);
|
||||
compilerHost.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ false);
|
||||
|
||||
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
|
||||
}
|
||||
|
||||
@ -226,7 +226,8 @@ class ProjectRunner extends RunnerBase {
|
||||
? filename
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(filename);
|
||||
|
||||
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, getCurrentDirectory(), false);
|
||||
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName,
|
||||
getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
|
||||
// If the generated output file resides in the parent folder or is rooted path,
|
||||
// we need to instead create files that can live in the project reference folder
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
//// [fooResult.js.map]
|
||||
{"version":3,"file":"fooResult.js","sourceRoot":"","sources":["../testFiles/app.ts","../testFiles/app2.ts"],"names":["c","c.constructor","d","d.constructor"],"mappings":"AAEA,AAFA,gFAAgF;AAChF,0GAA0G;IACpG,CAAC;IAAPA,SAAMA,CAACA;IACPC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC;ACHD,IAAM,CAAC;IAAPE,SAAMA,CAACA;IACPC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"}
|
||||
{"version":3,"file":"fooResult.js","sourceRoot":"","sources":["app.ts","app2.ts"],"names":["c","c.constructor","d","d.constructor"],"mappings":"AAEA,AAFA,gFAAgF;AAChF,0GAA0G;IACpG,CAAC;IAAPA,SAAMA,CAACA;IACPC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC;ACHD,IAAM,CAAC;IAAPE,SAAMA,CAACA;IACPC,CAACA;IAADD,QAACA;AAADA,CAACA,AADD,IACC"}
|
||||
@ -2,11 +2,11 @@
|
||||
JsFile: fooResult.js
|
||||
mapUrl: fooResult.js.map
|
||||
sourceRoot:
|
||||
sources: ../testFiles/app.ts,../testFiles/app2.ts
|
||||
sources: app.ts,app2.ts
|
||||
===================================================================
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/testfiles/fooResult.js
|
||||
sourceFile:../testFiles/app.ts
|
||||
sourceFile:app.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>// Note in the out result we are using same folder name only different in casing
|
||||
1 >
|
||||
@ -88,7 +88,7 @@ sourceFile:../testFiles/app.ts
|
||||
---
|
||||
-------------------------------------------------------------------
|
||||
emittedFile:tests/cases/compiler/testfiles/fooResult.js
|
||||
sourceFile:../testFiles/app2.ts
|
||||
sourceFile:app2.ts
|
||||
-------------------------------------------------------------------
|
||||
>>>var d = (function () {
|
||||
1->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user