Skip to content

Commit 76ff3f0

Browse files
authored
Merge branch 'master' into mu
2 parents d5712e0 + c46ec3b commit 76ff3f0

File tree

4 files changed

+46
-47
lines changed

4 files changed

+46
-47
lines changed

CHANGELOG.md

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,31 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9-
## [1.3.0-beta.5]
9+
## [1.3.1] - 2018-05-14
1010

1111
### Fixed
1212

13-
* Simplified the file watching implementation, fixing some odd behavior when trees of files were deleted or moved all at once.
14-
15-
## [1.3.0-beta.4]
16-
17-
* Updated the generated `tsconfig.json` to use the maximum strictness we can with Ember's typings.
18-
19-
## [1.3.0-beta.3]
20-
21-
### Fixed
22-
23-
* The synchronization tweak made in 1.3.0-beta.2 now works properly on Windows.
13+
* No longer requires TypeScript before it has been installed.
14+
* Properly ignore the root across platforms.
2415

25-
## [1.3.0-beta.2]
16+
## [1.3.0] - 2018-05-01
2617

2718
### Fixed
2819

20+
* Simplified the file watching implementation, fixing some odd behavior when trees of files were deleted or moved all at once.
2921
* Synchronization between tsc and the broccoli build process has been improved, reducing spurious rebuilds.
30-
31-
## [1.3.0-beta.1]
32-
33-
### Added
34-
35-
* The addon now supports failing the build when there are type errors, using `"noEmitOnError": true` in `tsconfig.json`.
22+
* TypeScript no longer churns on every change in the `tmp` directory.
23+
* Make sure ember-cli-typescript is a dev dependency when generating in-repo-addons, so their TypeScript gets built correctly.
24+
* Eliminated some lint errors in the build.
3625

3726
### Changed
3827

28+
* Updated the generated `tsconfig.json` to use the maximum strictness we can with Ember's typings.
3929
* Clarified instructions for sourcemaps.
4030

41-
### Fixed
31+
### Added
4232

43-
* TypeScript no longer churns on every change in the `tmp` directory.
44-
* Make sure ember-cli-typescript is a dev dependency when generating in-repo-addons, so their TypeScript gets built correctly.
45-
* Eliminated some lint errors in the build.
33+
* The addon now supports failing the build when there are type errors, using `"noEmitOnError": true` in `tsconfig.json`.
4634

4735
## [1.2.1] - 2018-03-14
4836

@@ -244,12 +232,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
244232
* Basic, semi-working functionality.
245233

246234
[ember-cli-typify]: https://github.com/winding-lines/ember-cli-typify
247-
[unreleased]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.3.0-beta.5...HEAD
248-
[1.3.0-beta.5]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.3.0-beta.4...v1.3.0-beta.5
249-
[1.3.0-beta.4]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.3.0-beta.3...v1.3.0-beta.4
250-
[1.3.0-beta.3]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.3.0-beta.2...v1.3.0-beta.3
251-
[1.3.0-beta.2]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.3.0-beta.1...v1.3.0-beta.2
252-
[1.3.0-beta.1]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.2.1...v1.3.0-beta.1
235+
[unreleased]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.3.0...HEAD
236+
[1.3.1]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.3.0...v1.3.1
237+
[1.3.0]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.2.1...v1.3.0
253238
[1.2.1]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.2.0...v1.2.1
254239
[1.2.0]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.1.6...v1.2.0
255240
[1.1.6]: https://github.com/typed-ember/ember-cli-typescript/compare/v1.1.5...v1.1.6

lib/incremental-typescript-compiler/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const path = require('path');
77
const fs = require('fs-extra');
88
const resolve = require('resolve');
99
const compile = require('../utilities/compile');
10-
const ts = require('typescript');
1110
const TypescriptOutput = require('./typescript-output-plugin');
1211
const CompilerState = require('./compiler-state');
1312

@@ -28,6 +27,7 @@ module.exports = class IncrementalTypescriptCompiler {
2827
this.addons = this._discoverAddons(project, []);
2928
this.state = new CompilerState();
3029

30+
this._ts = project.require('typescript');
3131
this._watchProgram = null;
3232
}
3333

@@ -118,14 +118,11 @@ module.exports = class IncrementalTypescriptCompiler {
118118

119119
this._watchProgram = compile(project, { outDir, watch: true }, {
120120
watchedFileChanged: () => this.state.tscDidStart(),
121+
buildComplete: () => this.state.tscDidEnd(),
121122

122123
reportWatchStatus: (diagnostic) => {
123124
let text = diagnostic.messageText;
124125
debugTsc(text);
125-
126-
if (text.indexOf('Compilation complete') !== -1) {
127-
this.state.tscDidEnd();
128-
}
129126
},
130127

131128
reportDiagnostic: (diagnostic) => {
@@ -146,10 +143,10 @@ module.exports = class IncrementalTypescriptCompiler {
146143
}
147144

148145
_formatDiagnosticMessage(diagnostic) {
149-
return ts.formatDiagnostic(diagnostic, {
146+
return this._ts.formatDiagnostic(diagnostic, {
150147
getCanonicalFileName: path => path,
151-
getCurrentDirectory: ts.sys.getCurrentDirectory,
152-
getNewLine: () => ts.sys.newLine,
148+
getCurrentDirectory: this._ts.sys.getCurrentDirectory,
149+
getNewLine: () => this._ts.sys.newLine,
153150
});
154151
}
155152

lib/utilities/compile.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const chokidar = require('chokidar');
55
const fs = require('fs-extra');
6+
const escapeRegex = require('escape-string-regexp');
67
const debug = require('debug')('ember-cli-typescript:tsc:trace');
78

89
module.exports = function compile(project, tsOptions, callbacks) {
@@ -18,23 +19,37 @@ module.exports = function compile(project, tsOptions, callbacks) {
1819
}, tsOptions);
1920

2021
let ts = project.require('typescript');
22+
let host = createWatchCompilerHost(ts, fullOptions, project, callbacks);
23+
24+
return ts.createWatchProgram(host);
25+
};
26+
27+
function createWatchCompilerHost(ts, options, project, callbacks) {
2128
let configPath = ts.findConfigFile('./', ts.sys.fileExists, 'tsconfig.json');
2229
let createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
2330
let host = ts.createWatchCompilerHost(
2431
configPath,
25-
fullOptions,
26-
buildWatchHooks(ts.sys, callbacks),
32+
options,
33+
buildWatchHooks(project, ts.sys, callbacks),
2734
createProgram,
2835
diagnosticCallback(callbacks.reportDiagnostic),
2936
diagnosticCallback(callbacks.reportWatchStatus)
3037
);
3138

39+
let afterCreate = host.afterProgramCreate;
40+
host.afterProgramCreate = function() {
41+
afterCreate.apply(this, arguments);
42+
if (callbacks.buildComplete) {
43+
callbacks.buildComplete();
44+
}
45+
};
46+
3247
if (debug.enabled) {
3348
host.trace = str => debug(str.trim());
3449
}
3550

36-
return ts.createWatchProgram(host);
37-
};
51+
return host;
52+
}
3853

3954
function diagnosticCallback(callback) {
4055
if (callback) {
@@ -47,13 +62,17 @@ function diagnosticCallback(callback) {
4762
}
4863
}
4964

50-
function buildWatchHooks(sys, callbacks) {
65+
function buildWatchHooks(project, sys, callbacks) {
66+
let root = escapeRegex(project.root);
67+
let sep = `[/\\\\]`;
68+
let patterns = ['\\..*?', 'dist', 'node_modules', 'tmp'];
69+
let ignored = new RegExp(`^${root}${sep}(${patterns.join('|')})${sep}`);
70+
5171
return Object.assign({}, sys, {
5272
watchFile: null,
5373
watchDirectory(dir, callback) {
5474
if (!fs.existsSync(dir)) return;
5575

56-
let ignored = /\/(\..*?|dist|node_modules|tmp)\//;
5776
let watcher = chokidar.watch(dir, { ignored, ignoreInitial: true });
5877

5978
watcher.on('all', (type, path) => {

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-cli-typescript",
3-
"version": "1.3.0-beta.5",
3+
"version": "1.3.1",
44
"description": "Allow ember apps to use typescript files.",
55
"keywords": [
66
"ember-addon",
@@ -48,6 +48,7 @@
4848
"ember-cli-valid-component-name": "^1.0.0",
4949
"ember-cli-version-checker": "^2.1.0",
5050
"ember-router-generator": "^1.2.3",
51+
"escape-string-regexp": "^1.0.5",
5152
"execa": "^0.9.0",
5253
"exists-sync": "^0.0.4",
5354
"fs-extra": "^5.0.0",
@@ -96,9 +97,6 @@
9697
"resolutions": {
9798
"@types/ember": "2.8.13"
9899
},
99-
"peerDependencies": {
100-
"typescript": "^2.4.2"
101-
},
102100
"engines": {
103101
"node": "^4.5 || 6.* || >= 7.*"
104102
},

0 commit comments

Comments
 (0)