Skip to content

Commit a09ebf6

Browse files
committed
Fix tsc not properly outputting javascript files
1 parent aa9632f commit a09ebf6

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

lib/buildtools/src/prebuild/tsc.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ export const {
8080
const { results: tsconfig, fileNames } = tsconfigRes;
8181

8282
try {
83-
const tsc = ts.createProgram(fileNames, tsconfig);
84-
const results = tsc.emit();
85-
const diagnostics = ts.getPreEmitDiagnostics(tsc)
83+
const typecheckProgram = ts.createProgram({
84+
rootNames: fileNames,
85+
options: {
86+
...tsconfig,
87+
noEmit: true
88+
}});
89+
const results = typecheckProgram.emit();
90+
const diagnostics = ts.getPreEmitDiagnostics(typecheckProgram)
8691
.concat(results.diagnostics);
8792

8893
const severity = findSeverity(diagnostics, ({ category }) => {
@@ -96,6 +101,21 @@ export const {
96101
}
97102
});
98103

104+
if (severity !== 'error' && !tsconfig.noEmit) {
105+
// If noEmit isn't specified, then run tsc again without including test
106+
// files and actually output the files
107+
const filesWithoutTests = fileNames.filter(p => {
108+
const segments = p.split(pathlib.sep);
109+
return !segments.includes('__tests__');
110+
});
111+
const compileProgram = ts.createProgram({
112+
rootNames: filesWithoutTests,
113+
options: tsconfig,
114+
oldProgram: typecheckProgram
115+
});
116+
compileProgram.emit();
117+
}
118+
99119
return {
100120
severity,
101121
results: diagnostics,

src/bundles/curve/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"build": "buildtools build bundle .",
2121
"test": "buildtools test .",
22-
"tsc": "tsc --project ./tsconfig.prod.json",
22+
"tsc": "tsc --project ./tsconfig.json",
2323
"lint": "buildtools lint ."
2424
}
2525
}

src/bundles/curve/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"./src"
66
],
77
"compilerOptions": {
8-
"noEmit": true
8+
"outDir": "./dist"
99
},
1010
"typedocOptions": {
1111
"name": "curve"

src/bundles/curve/tsconfig.prod.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)