Skip to content

Commit 2674082

Browse files
committed
Remove now-defunct TS file munging.
1 parent 06112a3 commit 2674082

File tree

1 file changed

+12
-58
lines changed

1 file changed

+12
-58
lines changed

lib/typescript-preprocessor.js

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,21 @@ const path = require('path');
33

44
const debug = require('debug')('ember-cli-typescript');
55
const find = require('broccoli-stew').find;
6-
const Funnel = require("broccoli-funnel");
7-
const MergeTrees = require("broccoli-merge-trees");
6+
const Funnel = require('broccoli-funnel');
7+
const MergeTrees = require('broccoli-merge-trees');
88
const ts = require('typescript');
99
const tsc = require('broccoli-typescript-compiler').typescript;
1010
const UnwatchedDir = require('broccoli-source').UnwatchedDir;
1111

1212
function readConfig(configFile) {
1313
const result = ts.readConfigFile(configFile, ts.sys.readFile);
1414
if (result.error) {
15-
const message = ts.flattenDiagnosticMessageText(result.error.messageText, "\n");
15+
const message = ts.flattenDiagnosticMessageText(result.error.messageText, '\n');
1616
throw new Error(message);
1717
}
1818
return result.config;
1919
}
2020

21-
/**
22-
* Return the paths which contain type information.
23-
*/
24-
function typePaths(config) {
25-
const cfgPaths = (config.compilerOptions && config.compilerOptions.paths) || {};
26-
27-
const toTypePaths = paths => (splitPaths, key) => {
28-
// paths may end in a `/*`; keep everything before it
29-
const upToSlashStar = path => path.split("/\*")[0];
30-
31-
// only store unique paths
32-
const notAlreadyStoredIn = storedPaths => path => !storedPaths.includes(path);
33-
34-
const newPaths = paths[key]
35-
.map(upToSlashStar)
36-
.filter(notAlreadyStoredIn(splitPaths));
37-
38-
return splitPaths.concat(newPaths);
39-
};
40-
41-
const out = Object.keys(cfgPaths).reduce(toTypePaths(cfgPaths), []);
42-
debug("type paths", out);
43-
return out;
44-
}
45-
4621
class TypeScriptPreprocessor {
4722
constructor(options) {
4823
debug('creating new instance with options ', options);
@@ -52,49 +27,28 @@ class TypeScriptPreprocessor {
5227
}
5328

5429
toTree(inputNode, inputPath, outputPath) {
55-
const tsconfig = readConfig(path.join(".", "tsconfig.json"));
56-
57-
// The `include` setting is meant for the IDE integration; broccoli manages
58-
// manages its own input files.
59-
tsconfig.include = ["**/*.ts"];
30+
const tsconfig = readConfig(path.join('.', 'tsconfig.json'));
6031

6132
// tsc needs to emit files on the broccoli pipeline, but not in the default
6233
// config. Otherwise its compiled `.js` files may be created inadvertently.
6334
tsconfig.compilerOptions.noEmit = false;
6435
delete tsconfig.compilerOptions.outDir;
6536

66-
// Create a funnel with the type files used by the typescript compiler.
67-
// These will change infrequently (read: usually not at all) so grab each as
68-
// an *unwatched* directory, and return it at the proper location.
69-
const typeTrees = typePaths(tsconfig).map((typePath) => {
70-
const typeTree = new UnwatchedDir(typePath);
71-
return new Funnel(typeTree, { destDir: typePath });
37+
const js = new Funnel(inputNode, {
38+
exclude: [/ts$/],
39+
annotation: 'JS files',
7240
});
7341

74-
const types = new MergeTrees(typeTrees);
75-
76-
// Passthrough all the javascript files existing in the source/test folders.
77-
const passthrough = new Funnel(inputNode, {
78-
exclude: ["**/*.ts"],
79-
annotation: "TypeScript passthrough"
42+
const tsFiles = new Funnel(inputNode, {
43+
annotation: 'TS files',
8044
});
8145

82-
// Files to run through the typescript compiler.
83-
const filter = new MergeTrees([
84-
types,
85-
new Funnel(inputNode, {
86-
include: ["**/*.ts"],
87-
annotation: "TypeScript input"
88-
})
89-
]);
46+
const ts = tsc(tsFiles, { tsconfig });
9047

9148
// Put everything together.
92-
return new MergeTrees([
93-
passthrough,
94-
tsc(filter, { tsconfig })
95-
], {
49+
return new MergeTrees([js, ts], {
9650
overwrite: true,
97-
annotation: "TypeScript passthrough + ouput"
51+
annotation: 'compiled TypeScript',
9852
});
9953
}
10054
}

0 commit comments

Comments
 (0)