Skip to content

feat(): add typings to the blueprints. #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addon/ng2/blueprints/ng2/files/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
/libpeerconnection.log
npm-debug.log
testem.log
/typings/

# e2e
/e2e/*.js
/e2e/*.map

12 changes: 9 additions & 3 deletions addon/ng2/blueprints/ng2/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@
"playSound": false
}
},
"scripts": {
"start": "ng server",
"postinstall": "typings install --ambient"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should test what happens when a typing is removed from typings.json - make sure that this will remove it from the typings dir. otherwise contributors end up with stale extra typings files in their working dir

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not remove the typings removed from typings.json.

I filed typings/typings#170 to do just that.

},
"private": true,
"dependencies": {
"angular2": "2.0.0-beta.0",
"angular2": "2.0.0-beta.3",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"systemjs": "0.19.4",
"zone.js": "0.5.10"
"zone.js": "0.5.11"
},
"devDependencies": {
"angular-cli": "0.0.*",
"angular-cli-github-pages": "^0.2.0",
"ember-cli-inject-live-reload": "^1.3.0",
"glob": "^6.0.4",
"jasmine-core": "^2.3.4",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.2.1",
"karma-jasmine": "^0.3.6",
"protractor": "^3.0.0",
"typescript": "^1.7.3"
"typescript": "^1.7.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should opt angular-cli users into the TS 1.8 beta. Then you get features like comments in the tsconfig.json which is really nice in a templated file - gives the user in-situ instructions for editing it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make those kind of version upgrade a separate PR, but I agree. I can do a quick follow up today.

"typings": "^0.6.6"
}
}
16 changes: 0 additions & 16 deletions addon/ng2/blueprints/ng2/files/src/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions addon/ng2/blueprints/ng2/files/src/tsconfig.json
23 changes: 23 additions & 0 deletions addon/ng2/blueprints/ng2/files/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "",
"module": "system",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"outDir": "../dist/",
"rootDir": ".",
"sourceMap": true,
"sourceRoot": "/",
"target": "es5"
},
"exclude": [
"e2e/",
"node_modules/",
"typings/main",
"typings/main.d.ts"
]
}
10 changes: 10 additions & 0 deletions addon/ng2/blueprints/ng2/files/typings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {},
"devDependencies": {
},
"ambientDevDependencies": {
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee"
},
"ambientDependencies": {
}
}
24 changes: 22 additions & 2 deletions lib/broccoli/angular2-app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var path = require('path');
var Concat = require('broccoli-concat');
var configReplace = require('./broccoli-config-replace');
var compileWithTypescript = require('./broccoli-typescript').default;
var fs = require('fs');
var glob = require('glob');
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var Project = require('ember-cli/lib/models/project');
Expand Down Expand Up @@ -32,7 +34,25 @@ Angular2App.prototype.toTree = function() {
vendorNpmFiles = vendorNpmFiles.concat(this.options.vendorNpmFiles);
}

var tsConfigCompilerOptions = JSON.parse(fs.readFileSync('src/tsconfig.json', 'utf-8')).compilerOptions;
var tsConfig = JSON.parse(fs.readFileSync('tsconfig.json', 'utf-8'));
var tsConfigCompilerOptions = tsConfig.compilerOptions;

// `rootFilesPath` is used by the broccoli-typescript to add files to the compilation.
// It is _not_ part of the `tsconfig.json` spec, so it won't be found in
// tsConfigCompilerOptions. This adds the typings manually to the compilation step.
// We pass in all files except those that matches excluded paths.
var exclude = tsConfig.exclude || [];
var files = glob.sync('**/*.ts');
tsConfigCompilerOptions.rootFilePaths = files
.filter(function(x) {
// Remove those who start with paths in the tsconfig exclude list.
return !exclude.some(function(y) { return x.startsWith(y); });
})
.map((function(x) {
// Map them around the current working directory.
return path.join(process.cwd(), x);
}));

var tsTree = compileWithTypescript(sourceTree, tsConfigCompilerOptions);
var tsSrcTree = new Funnel(sourceTree, {
include: ['**/*.ts'],
Expand All @@ -46,7 +66,7 @@ Angular2App.prototype.toTree = function() {

var assetTree = new Funnel(sourceTree, {
include: ['**/*.*'],
exclude: ['**/*.ts', '**/*.js', 'src/tsconfig.json'],
exclude: ['**/*.ts', '**/*.js'],
allowEmpty: true
});

Expand Down