Skip to content

Commit e238e32

Browse files
committed
feat(): add typings to the blueprints.
1 parent af904c9 commit e238e32

File tree

6 files changed

+67
-21
lines changed

6 files changed

+67
-21
lines changed

addon/ng2/blueprints/ng2/files/gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
/libpeerconnection.log
1919
npm-debug.log
2020
testem.log
21+
/typings/
2122

2223
# e2e
2324
/e2e/*.js
2425
/e2e/*.map
26+

addon/ng2/blueprints/ng2/files/package.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,31 @@
88
"playSound": false
99
}
1010
},
11+
"scripts": {
12+
"start": "ng server",
13+
"postinstall": "typings install --ambient"
14+
},
1115
"private": true,
1216
"dependencies": {
13-
"angular2": "2.0.0-beta.0",
17+
"angular2": "2.0.0-beta.3",
1418
"es6-promise": "^3.0.2",
1519
"es6-shim": "^0.33.3",
1620
"reflect-metadata": "0.1.2",
1721
"rxjs": "5.0.0-beta.0",
1822
"systemjs": "0.19.4",
19-
"zone.js": "0.5.10"
23+
"zone.js": "0.5.11"
2024
},
2125
"devDependencies": {
2226
"angular-cli": "0.0.*",
2327
"angular-cli-github-pages": "^0.2.0",
2428
"ember-cli-inject-live-reload": "^1.3.0",
29+
"glob": "^6.0.4",
2530
"jasmine-core": "^2.3.4",
2631
"karma": "^0.13.15",
2732
"karma-chrome-launcher": "^0.2.1",
2833
"karma-jasmine": "^0.3.6",
2934
"protractor": "^3.0.0",
30-
"typescript": "^1.7.3"
35+
"typescript": "^1.7.3",
36+
"typings": "^0.6.6"
3137
}
3238
}

addon/ng2/blueprints/ng2/files/src/tsconfig.json

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../tsconfig.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": false,
4+
"emitDecoratorMetadata": true,
5+
"experimentalDecorators": true,
6+
"mapRoot": "",
7+
"module": "system",
8+
"moduleResolution": "node",
9+
"noEmitOnError": true,
10+
"noImplicitAny": false,
11+
"outDir": "../dist/",
12+
"rootDir": ".",
13+
"sourceMap": true,
14+
"sourceRoot": "/",
15+
"target": "es5"
16+
},
17+
"exclude": [
18+
"e2e/",
19+
"node_modules/",
20+
"typings/main",
21+
"typings/main.d.ts"
22+
]
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"dependencies": {},
3+
"devDependencies": {
4+
},
5+
"ambientDevDependencies": {
6+
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee"
7+
},
8+
"ambientDependencies": {
9+
}
10+
}

lib/broccoli/angular2-app.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
var path = require('path');
12
var Concat = require('broccoli-concat');
23
var configReplace = require('./broccoli-config-replace');
34
var compileWithTypescript = require('./broccoli-typescript').default;
45
var fs = require('fs');
6+
var glob = require('glob');
57
var Funnel = require('broccoli-funnel');
68
var mergeTrees = require('broccoli-merge-trees');
79
var Project = require('ember-cli/lib/models/project');
@@ -32,7 +34,25 @@ Angular2App.prototype.toTree = function() {
3234
vendorNpmFiles = vendorNpmFiles.concat(this.options.vendorNpmFiles);
3335
}
3436

35-
var tsConfigCompilerOptions = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8')).compilerOptions;
37+
var tsConfig = JSON.parse(fs.readFileSync('tsconfig.json', 'utf-8'));
38+
var tsConfigCompilerOptions = tsConfig.compilerOptions;
39+
40+
// `rootFilesPath` is used by the broccoli-typescript to add files to the compilation.
41+
// It is _not_ part of the `tsconfig.json` spec, so it won't be found in
42+
// tsConfigCompilerOptions. This adds the typings manually to the compilation step.
43+
// We pass in all files except those that matches excluded paths.
44+
var exclude = tsConfig.exclude || [];
45+
var files = glob.sync('**/*.ts');
46+
tsConfigCompilerOptions.rootFilePaths = files
47+
.filter(function(x) {
48+
// Remove those who start with paths in the tsconfig exclude list.
49+
return !exclude.some(function(y) { return x.startsWith(y); });
50+
})
51+
.map((function(x) {
52+
// Map them around the current working directory.
53+
return path.join(process.cwd(), x);
54+
}));
55+
3656
var tsTree = compileWithTypescript(sourceTree, tsConfigCompilerOptions);
3757
var tsSrcTree = new Funnel(sourceTree, {
3858
include: ['**/*.ts'],
@@ -46,7 +66,7 @@ Angular2App.prototype.toTree = function() {
4666

4767
var assetTree = new Funnel(sourceTree, {
4868
include: ['**/*.*'],
49-
exclude: ['**/*.ts', '**/*.js', 'src/tsconfig.json'],
69+
exclude: ['**/*.ts', '**/*.js'],
5070
allowEmpty: true
5171
});
5272

0 commit comments

Comments
 (0)