Skip to content

Commit e2abbc1

Browse files
chriskrycholocks
authored andcommitted
Fix reloading of tmp directory. (#30)
- Add `broccoli-source` dependency. - Use `UnwatchedDir` for the root to prevent rebuilds of types. - Update README to note that changes to `tsconfig.json` require restarting the server. - Only pull in `.ts` files in the overwritten `include` value in the tsconfig passed to broccoli-typescript.
1 parent b1ae73a commit e2abbc1

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ ember install ember-cli-typescript
1919

2020
All dependencies will be added to your package.json, and you're ready to roll!
2121

22-
## Configuration file
22+
## Configuration file notes
2323

24+
If you make changes to the paths included in your `tsconfig.json`, you will need to restart the server to take the changes into account.
2425

2526
### Problem ###
2627

27-
The configuration file is used by both Ember
28-
CLI/[broccoli](http://broccolijs.com/) and [VS
29-
Code](http://code.visualstudio.com/)/`tsc` command line compiler.
28+
The configuration file is used by both Ember CLI/[broccoli](http://broccolijs.com/) and [VS Code](http://code.visualstudio.com/)/`tsc` command line compiler.
3029

3130
Broccoli controls the inputs and the output folder of the various build steps
3231
that make the Ember build pipeline. Its expectation are impacted by Typescript

lib/typescript-preprocessor.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Funnel = require("broccoli-funnel");
77
const MergeTrees = require("broccoli-merge-trees");
88
const ts = require('typescript');
99
const tsc = require('broccoli-typescript-compiler').typescript;
10+
const UnwatchedDir = require('broccoli-source').UnwatchedDir;
1011

1112
function readConfig(configFile) {
1213
const result = ts.readConfigFile(configFile, ts.sys.readFile);
@@ -57,21 +58,23 @@ class TypeScriptPreprocessor {
5758

5859
// The `include` setting is meant for the IDE integration; broccoli manages
5960
// manages its own input files.
60-
tsconfig.include = ["**/*"];
61+
tsconfig.include = ["**/*.ts"];
6162

6263
// tsc needs to emit files on the broccoli pipeline, but not in the default
6364
// config. Otherwise its compiled `.js` files may be created inadvertently.
6465
tsconfig.compilerOptions.noEmit = false;
65-
if (tsconfig.compilerOptions.outDir) {
66-
delete tsconfig.compilerOptions.outDir;
67-
}
66+
delete tsconfig.compilerOptions.outDir;
6867

6968
// Create a funnel with the type files used by the typescript compiler.
70-
const types = find(process.cwd(), {
71-
include: typePaths(tsconfig).map(a => `${a}/**/*`),
72-
exclude: ["**/*.js"]
69+
// These will change infrequently (read: usually not at all) so grab each as
70+
// an *unwatched* directory, and return it at the proper location.
71+
const typeTrees = typePaths(tsconfig).map((typePath) => {
72+
const typeTree = new UnwatchedDir(typePath);
73+
return new Funnel(typeTree, { destDir: typePath });
7374
});
7475

76+
const types = new MergeTrees(typeTrees);
77+
7578
// Passthrough all the javascript files existing in the source/test folders.
7679
const passthrough = new Funnel(inputNode, {
7780
exclude: ["**/*.ts"],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"broccoli-funnel": "^1.0.6",
3131
"broccoli-merge-trees": "^1.1.4",
3232
"broccoli-plugin": "^1.2.1",
33+
"broccoli-source": "^1.1.0",
3334
"broccoli-stew": "^1.4.0",
3435
"broccoli-typescript-compiler": "^1.0.1",
3536
"debug": "^2.2.0",

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES6",
4-
"allowJs": true,
4+
"allowJs": false,
55
"moduleResolution": "node",
66
"noEmitOnError": true,
77
"baseUrl": ".",

0 commit comments

Comments
 (0)