Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit cae4d00

Browse files
author
Stanislav Panferov
committed
feat(*): use a compiler from a client app
1 parent 55ab75b commit cae4d00

File tree

5 files changed

+52
-11
lines changed

5 files changed

+52
-11
lines changed

Gruntfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = function(grunt) {
66
ts: {
77
default : {
88
options: {
9-
compiler: './node_modules/ntypescript/bin/tsc',
9+
compiler: './node_modules/typescript/bin/tsc',
1010
module: "commonjs",
1111
fast: 'never',
1212
preserveConstEnums: true
@@ -16,7 +16,7 @@ module.exports = function(grunt) {
1616
},
1717
watch : {
1818
options: {
19-
compiler: './node_modules/ntypescript/bin/tsc',
19+
compiler: './node_modules/typescript/bin/tsc',
2020
module: "commonjs",
2121
fast: 'never',
2222
preserveConstEnums: true

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ Comma-separated list of paths to .d.ts files that must be included in program. U
115115

116116
Use this setting to disable type checking if you want.
117117

118-
### forkChecker *experimental!* *(string) (default=false)*
118+
### forkChecker *(string) (default=false)*
119119

120-
Do type checking in a separate process, so webpack don't need to wait. **Significantly** development workflow.
120+
Do type checking in a separate process, so webpack don't need to wait. **Significantly** improves development workflow.
121121

122122
## Using with --watch or webpack-dev-server
123123

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
"bluebird": "^2.7.1",
2828
"loader-utils": "^0.2.6",
2929
"lodash": "^3.10.0",
30-
"ntypescript": "1.201507220720.1",
3130
"object-assign": "^2.0.0",
32-
"typescript": "1.5.3",
3331
"colors": "^1.1.2"
3432
},
3533
"devDependencies": {
34+
"typescript": "1.6.0-dev.20150723",
3635
"git-hooks": "0.0.10",
3736
"grunt": "^0.4.5",
3837
"grunt-bump": "^0.3.1",

src/checker.ts

+33-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
import { ICompilerOptions, ICompilerInfo, IFile } from './host';
22
import * as colors from 'colors';
3+
import * as _ from 'lodash';
4+
5+
const AWESOME_SYNONYMS = [
6+
'awesome',
7+
'impressive',
8+
'amazing',
9+
'grand',
10+
'majestic',
11+
'magnificent',
12+
'wonderful',
13+
'great',
14+
'marvellous',
15+
'incredible',
16+
'fabulous',
17+
'outstanding',
18+
'unbelievable',
19+
'beautiful',
20+
'excellent',
21+
'mind-blowing',
22+
'superb',
23+
'badass',
24+
'brilliant',
25+
'exciting',
26+
'eye-opening',
27+
'fucking good',
28+
'fine',
29+
'perfect',
30+
'cool',
31+
'fantastical',
32+
'five-star'
33+
];
334

435
export enum MessageType {
536
Init = <any>'init',
@@ -80,7 +111,7 @@ function processInit(payload: IInitPayload) {
80111
env.host = new Host();
81112
env.compilerInfo = payload.compilerInfo;
82113
env.options = payload.compilerOptions;
83-
env.service = this.ts.createLanguageService(env.host, env.compiler.createDocumentRegistry());
114+
env.service = env.compiler.createLanguageService(env.host, env.compiler.createDocumentRegistry());
84115
}
85116

86117
function processCompile(payload: ICompilePayload) {
@@ -98,10 +129,9 @@ function processCompile(payload: ICompilePayload) {
98129
} else {
99130
console.error(colors.red(message));
100131
}
101-
102132
});
103133
} else {
104-
console.error(colors.green('Your program is fine!'))
134+
console.error(colors.green('Your program is ' + AWESOME_SYNONYMS[_.random(AWESOME_SYNONYMS.length - 1)] + '!'));
105135
}
106136

107137
}

src/index.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/// <reference path='../node_modules/ntypescript/bin/typescriptServices.d.ts' />
1+
/// <reference path='../node_modules/typescript/bin/typescriptServices.d.ts' />
22
/// <reference path='../typings/tsd.d.ts' />
33

44
import * as Promise from 'bluebird';
55
import * as path from 'path';
66
import * as fs from 'fs';
77
import * as _ from 'lodash';
88
import * as childProcess from 'child_process';
9+
import * as colors from 'colors';
910

1011
import { ICompilerOptions, TypeScriptCompilationError, State, ICompilerInfo } from './host';
1112
import { IResolver, ResolutionError } from './deps';
@@ -101,6 +102,10 @@ function createChecker(compilerInfo: ICompilerInfo, compilerOptions: ICompilerOp
101102
return checker;
102103
}
103104

105+
const COMPILER_ERROR = colors.red(`\n\nTypescript compiler cannot be found, please add it to your package.json file:
106+
npm install --save-dev typescript
107+
`);
108+
104109
/**
105110
* Creates compiler instance
106111
*/
@@ -120,7 +125,14 @@ function ensureInstance(webpack: IWebPack, options: ICompilerOptions, instanceNa
120125
compilerPath = compilerName
121126
}
122127

123-
let tsImpl: typeof ts = require(compilerName);
128+
let tsImpl: typeof ts;
129+
try {
130+
console.log(compilerName);
131+
tsImpl = require(compilerName);
132+
} catch (e) {
133+
console.error(COMPILER_ERROR);
134+
process.exit(1);
135+
}
124136

125137
let compilerInfo: ICompilerInfo = {
126138
compilerName,

0 commit comments

Comments
 (0)