Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/compiler/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ func sourceFileMayBeEmitted(sourceFile *ast.SourceFile, host SourceFileMayBeEmit
return false
}

// Otherwise if rootDir or composite config file, we know common sourceDir and can check if file would be emitted in same location
if options.RootDir != "" || (options.Composite.IsTrue() && options.ConfigFilePath != "") {
// Otherwise, if rootDir is specified or a config file exists, we know the common source directory and can check if the file would be emitted in the same location
if options.RootDir != "" || options.ConfigFilePath != "" {
commonDir := tspath.GetNormalizedAbsolutePath(outputpaths.GetCommonSourceDirectory(options, func() []string { return nil }, host.GetCurrentDirectory(), host.UseCaseSensitiveFileNames()), host.GetCurrentDirectory())
outputPath := outputpaths.GetSourceFilePathInNewDirWorker(sourceFile.FileName(), options.OutDir, host.GetCurrentDirectory(), commonDir, host.UseCaseSensitiveFileNames())
if tspath.ComparePaths(sourceFile.FileName(), outputPath, tspath.ComparePathsOptions{
Expand Down
2 changes: 1 addition & 1 deletion internal/execute/tsctests/tscbuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ func TestBuildOutputPaths(t *testing.T) {
}`),
},
expectedDtsNames: []string{
"/home/src/workspaces/project/dist/index.js",
"/home/src/workspaces/project/dist/src/index.js",
},
},
{
Expand Down
7 changes: 4 additions & 3 deletions internal/module/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio
finalPath = tspath.GetNormalizedAbsolutePath(resolvedTarget+subpath, r.resolver.host.GetCurrentDirectory())
}
if inputLink := r.tryLoadInputFileForPath(finalPath, subpath, tspath.CombinePaths(scope.PackageDirectory, "package.json"), isImports); !inputLink.shouldContinueSearching() {
inputLink.packageId = r.getPackageId(inputLink.path, scope)
return inputLink
}
if result := r.loadFileNameFromPackageJSONField(extensions, finalPath, targetString, false /*onlyRecordFailures*/); !result.shouldContinueSearching() {
Expand Down Expand Up @@ -807,9 +808,9 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string
if r.compilerOptions.RootDir != "" {
// A `rootDir` compiler option strongly indicates the root location
rootDir = r.compilerOptions.RootDir
} else if r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath != "" {
// A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations
rootDir = r.compilerOptions.ConfigFilePath
} else if r.compilerOptions.ConfigFilePath != "" {
// When no explicit rootDir is set, treat the config file's directory as the project root, which establishes the common source directory, so no other locations need to be checked.
rootDir = tspath.GetDirectoryPath(r.compilerOptions.ConfigFilePath)
} else {
diagnostic := ast.NewDiagnostic(
nil,
Expand Down
5 changes: 2 additions & 3 deletions internal/outputpaths/commonsourcedirectory.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ func GetCommonSourceDirectory(options *core.CompilerOptions, files func() []stri
if options.RootDir != "" {
// If a rootDir is specified use it as the commonSourceDirectory
commonSourceDirectory = options.RootDir
} else if options.Composite.IsTrue() && options.ConfigFilePath != "" {
// If the rootDir is not specified, but the project is composite, then the common source directory
// is the directory of the config file.
} else if options.ConfigFilePath != "" {
// If the rootDir is not specified, then the common source directory is the directory of the config file.
commonSourceDirectory = tspath.GetDirectoryPath(options.ConfigFilePath)
} else {
commonSourceDirectory = computeCommonSourceDirectoryOfFilenames(files(), currentDirectory, useCaseSensitiveFileNames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ declare const y: number;
export const x = y;


//// [/app/bin/index.js]
//// [/app/bin/src/index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = void 0;
/// <reference path="../lib/bar.d.ts" preserve="true" />
exports.x = y;
//# sourceMappingURL=../src/myMapRoot/index.js.map
//# sourceMappingURL=../../myMapRoot/src/index.js.map

//// [/app/bin/index.d.ts]
/// <reference path="../lib/bar.d.ts" preserve="true" />
//// [/app/bin/src/index.d.ts]
/// <reference path="../../lib/bar.d.ts" preserve="true" />
export declare const x: number;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- old.commonSourceDirectory_dts.js
+++ new.commonSourceDirectory_dts.js
@@= skipped -7, +7 lines =@@
export const x = y;


-//// [/app/bin/index.js]
+//// [/app/bin/src/index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.x = void 0;
/// <reference path="../lib/bar.d.ts" preserve="true" />
exports.x = y;
-//# sourceMappingURL=../src/myMapRoot/index.js.map
+//# sourceMappingURL=../../myMapRoot/src/index.js.map

-//// [/app/bin/index.d.ts]
-/// <reference path="../lib/bar.d.ts" preserve="true" />
+//// [/app/bin/src/index.d.ts]
+/// <reference path="../../lib/bar.d.ts" preserve="true" />
export declare const x: number;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- old.commonSourceDirectory_dts.js.map
+++ new.commonSourceDirectory_dts.js.map
@@= skipped -0, +0 lines =@@
-//// [/app/bin/index.js.map]
-{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AAC3C,QAAA,CAAC,GAAG,CAAC,CAAC"}
-//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCmV4cG9ydHMueCA9IHZvaWQgMDsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL2xpYi9iYXIuZC50cyIgcHJlc2VydmU9InRydWUiIC8+DQpleHBvcnRzLnggPSB5Ow0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9Li4vc3JjL215TWFwUm9vdC9pbmRleC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsiaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsd0RBQXdEO0FBQzNDLFFBQUEsQ0FBQyxHQUFHLENBQUMsQ0FBQyJ9,Ly8vIDxyZWZlcmVuY2UgcGF0aD0iLi4vbGliL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4KZXhwb3J0IGNvbnN0IHggPSB5Owo=
+//// [/app/bin/src/index.js.map]
+{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AAC3C,QAAA,CAAC,GAAG,CAAC,CAAC"}
+//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCmV4cG9ydHMueCA9IHZvaWQgMDsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL2xpYi9iYXIuZC50cyIgcHJlc2VydmU9InRydWUiIC8+DQpleHBvcnRzLnggPSB5Ow0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9Li4vLi4vbXlNYXBSb290L3NyYy9pbmRleC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsic3JjL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHdEQUF3RDtBQUMzQyxRQUFBLENBQUMsR0FBRyxDQUFDLENBQUMifQ==,Ly8vIDxyZWZlcmVuY2UgcGF0aD0iLi4vbGliL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4KZXhwb3J0IGNvbnN0IHggPSB5Owo=
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
===================================================================
JsFile: index.js
mapUrl: ../src/myMapRoot/index.js.map
mapUrl: ../../myMapRoot/src/index.js.map
sourceRoot: mySourceRoot/
sources: index.ts
sources: src/index.ts
===================================================================
-------------------------------------------------------------------
emittedFile:/app/bin/index.js
sourceFile:index.ts
emittedFile:/app/bin/src/index.js
sourceFile:src/index.ts
-------------------------------------------------------------------
>>>"use strict";
>>>Object.defineProperty(exports, "__esModule", { value: true });
Expand All @@ -26,7 +26,7 @@ sourceFile:index.ts
4 > ^^^
5 > ^
6 > ^
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>export const
2 >
Expand All @@ -41,4 +41,4 @@ sourceFile:index.ts
5 >Emitted(5, 14) Source(2, 19) + SourceIndex(0)
6 >Emitted(5, 15) Source(2, 20) + SourceIndex(0)
---
>>>//# sourceMappingURL=../src/myMapRoot/index.js.map
>>>//# sourceMappingURL=../../myMapRoot/src/index.js.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- old.commonSourceDirectory_dts.sourcemap.txt
+++ new.commonSourceDirectory_dts.sourcemap.txt
@@= skipped -0, +0 lines =@@
===================================================================
JsFile: index.js
-mapUrl: ../src/myMapRoot/index.js.map
+mapUrl: ../../myMapRoot/src/index.js.map
sourceRoot: mySourceRoot/
-sources: index.ts
+sources: src/index.ts
===================================================================
-------------------------------------------------------------------
-emittedFile:/app/bin/index.js
-sourceFile:index.ts
+emittedFile:/app/bin/src/index.js
+sourceFile:src/index.ts
-------------------------------------------------------------------
>>>"use strict";
>>>Object.defineProperty(exports, "__esModule", { value: true });
@@= skipped -25, +25 lines =@@
4 > ^^^
5 > ^
6 > ^
-7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
+7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>export const
2 >
@@= skipped -15, +15 lines =@@
5 >Emitted(5, 14) Source(2, 19) + SourceIndex(0)
6 >Emitted(5, 15) Source(2, 20) + SourceIndex(0)
---
->>>//# sourceMappingURL=../src/myMapRoot/index.js.map
+>>>//# sourceMappingURL=../../myMapRoot/src/index.js.map

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import * as me from "@this/package";
>me : Symbol(me, Decl(index.ts, 0, 6))

me.thing();
>me.thing : Symbol(thing, Decl(index.ts, 2, 11))
>me : Symbol(me, Decl(index.ts, 0, 6))
>thing : Symbol(thing, Decl(index.ts, 2, 11))

export function thing(): void {}
>thing : Symbol(thing, Decl(index.ts, 2, 11))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

=== index.ts ===
import * as me from "@this/package";
>me : any
>me : typeof me

me.thing();
>me.thing() : any
>me.thing : any
>me : any
>thing : any
>me.thing() : void
>me.thing : () => void
>me : typeof me
>thing : () => void

export function thing(): void {}
>thing : () => void
Expand Down

This file was deleted.

This file was deleted.

Loading