-
Notifications
You must be signed in to change notification settings - Fork 12.2k
/
outputPaths.ts
117 lines (110 loc) · 4.67 KB
/
outputPaths.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
namespace ts {
describe("unittests:: tsbuild - output file paths", () => {
const noChangeProject: TscIncremental = {
buildKind: BuildKind.NoChangeRun,
modifyFs: noop,
subScenario: "Normal build without change, that does not block emit on error to show files that get emitted",
commandLineArgs: ["-p", "/src/tsconfig.json"],
};
const incrementalScenarios: TscIncremental[] = [
noChangeRun,
noChangeProject,
];
function verify(input: Pick<VerifyTsBuildInput, "subScenario" | "fs" | "incrementalScenarios">, expectedOuptutNames: readonly string[]) {
verifyTscSerializedIncrementalEdits({
scenario: "outputPaths",
commandLineArgs: ["--b", "/src/tsconfig.json", "-v"],
...input
});
it("verify getOutputFileNames", () => {
const sys = new fakes.System(input.fs().makeReadonly(), { executingFilePath: "/lib/tsc" }) as TscCompileSystem;
;
assert.deepEqual(
getOutputFileNames(
parseConfigFileWithSystem("/src/tsconfig.json", {}, {}, sys, noop)!,
"/src/src/index.ts",
/*ignoreCase*/ false
),
expectedOuptutNames
);
});
}
verify({
subScenario: "when rootDir is not specified",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist"
}
})
}),
incrementalScenarios,
}, ["/src/dist/index.js"]);
verify({
subScenario: "when rootDir is not specified and is composite",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
composite: true
}
})
}),
incrementalScenarios: [
noChangeRun,
{
...noChangeProject,
cleanBuildDescripencies: () => {
const map = new Map<string, CleanBuildDescripency>();
map.set("/src/dist/tsconfig.tsbuildinfo", CleanBuildDescripency.CleanFileTextDifferent); // tsbuildinfo will have -p setting when built using -p vs no build happens incrementally because of no change.
return map;
}
}
],
}, ["/src/dist/src/index.js", "/src/dist/src/index.d.ts"]);
verify({
subScenario: "when rootDir is specified",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
rootDir: "src"
}
})
}),
incrementalScenarios,
}, ["/src/dist/index.js"]);
verify({
subScenario: "when rootDir is specified but not all files belong to rootDir",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/types/type.ts": "export type t = string;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
rootDir: "src"
}
})
}),
incrementalScenarios,
}, ["/src/dist/index.js"]);
verify({
subScenario: "when rootDir is specified but not all files belong to rootDir and is composite",
fs: () => loadProjectFromFiles({
"/src/src/index.ts": "export const x = 10;",
"/src/types/type.ts": "export type t = string;",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: {
outDir: "dist",
rootDir: "src",
composite: true
}
})
}),
incrementalScenarios,
}, ["/src/dist/index.js", "/src/dist/index.d.ts"]);
});
}