Skip to content

Commit 9cae86b

Browse files
author
Marius Seritan
committed
Set noEmit compiler option during broccoli processing.
1 parent 8bd6de2 commit 9cae86b

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

README.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,66 @@ Enable typescript preprocessing on Ember 2.x apps.
55

66
## Installation
77

8-
In addition to ember-cli-typescript, [typescript](https://github.com/Microsoft/TypeScript) and [@type/ember](https://www.npmjs.com/package/@types/ember) are required. You can install all of these at once with:
8+
In addition to ember-cli-typescript, the following files are required:
9+
10+
- [typescript](https://github.com/Microsoft/TypeScript) version 2.0.0 or better
11+
- [@type/ember](https://www.npmjs.com/package/@types/ember)
12+
- [tsconfig](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)
13+
14+
You can setup all of these at once with:
915

1016
```
1117
ember install "ember-cli-typescript@emberwatch/ember-cli-typescript"
1218
```
1319

14-
All 3 dependencies will be added to your package.json, and you're ready to roll!
20+
All dependencies will be added to your package.json, and you're ready to roll!
21+
22+
## Configuration file
23+
24+
25+
### Problem ###
26+
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.
30+
31+
Broccoli controls the inputs and the output folder of the various build steps
32+
that make the Ember build pipeline. Its expectation are impacted by Typescript
33+
configuration properties like "include", "exclude", "outFile", "outDir".
34+
35+
We want to allow you to change unrelated properties in the tsconfig file.
36+
37+
### Solution ###
38+
39+
This addon takes the following approach to allow this dual use:
40+
41+
- is starts with the following [blueprint](https://github.com/emberwatch/ember-cli-typescript/blob/master/blueprints/ember-cli-typescript/files/tsconfig.json)
42+
43+
- the generated tsconfig file does not set "outDir" and sets "noEmit" to true.
44+
This allows you to run vscode and tsc without creating `.js` files throughout
45+
your codebase.
46+
47+
- before calling broccoli the addon removes "outDir" and sets "noEmit" and "includes"
48+
49+
50+
Please let us know if this does not satisfy your use cases by opening issues on this repo.
51+
52+
### Customization ###
53+
54+
You can customize this file further for your use case. For example to see the
55+
output of the compilation in a separate folder you are welcome to set and
56+
outDir and set noEmit to false. Then VS Code and tsc will generate files here
57+
while the broccoli pipeline will use its own temp folder.
1558

1659

1760
## Incremental adoption
1861

19-
Rename the files you want to check from `.js` to `.ts`.
62+
If you porting an existing app to typescript you can install this addon and
63+
migrate your files incrementally by changing their extensions from `.js` to
64+
`.ts`. A good approach is to start at your leaf files and then work your way
65+
up. As typescript starts to find errors make sure to celebrate your (small)
66+
wins with your team, specially if some people are not convinced yet. We would also
67+
love to hear your stories.
2068

2169
## VSCode setup
2270

lib/typescript-preprocessor.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ TypeScriptPreprocessor.prototype.toTree = function(inputNode, inputPath, outputP
5353
}
5454
config.include = ["**/*"];
5555

56+
// tsc needs to emit files on the broccoli pipeline, but not in the default config
57+
// otherwise it compiled .js files may be created inadvertently.
58+
config.compilerOptions.noEmit = false;
59+
if (config.compilerOptions.outDir) {
60+
delete config.compilerOptions.outDir;
61+
}
62+
5663
/*
5764
* Create a funnel with the type files used by the typescript compiler.
5865
*

0 commit comments

Comments
 (0)