forked from aurelia/event-aggregator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aurelia TypeScript build - with working dependencies definitions (jsp…
…m) and doc generation - karma tests not yet working
- Loading branch information
1 parent
d0849e0
commit e1161d3
Showing
10 changed files
with
144 additions
and
143 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,65 @@ | ||
var gulp = require('gulp'); | ||
var runSequence = require('run-sequence'); | ||
var to5 = require('gulp-babel'); | ||
var ts = require('gulp-typescript'); | ||
var sourcemaps = require('gulp-sourcemaps'); | ||
var merge = require('merge2'); | ||
var paths = require('../paths'); | ||
var compilerOptions = require('../babel-options'); | ||
var compilerOptions = require('../ts-options'); | ||
var assign = Object.assign || require('object.assign'); | ||
var rename = require('gulp-rename'); | ||
|
||
var jsName = paths.packageName + '.js'; | ||
var tsName = paths.packageName + '.ts'; | ||
|
||
gulp.task('build-index', function(){ | ||
return gulp.src(paths.root + 'index.js') | ||
.pipe(rename(jsName)) | ||
return gulp.src(paths.root + 'index.ts') | ||
.pipe(rename(tsName)) | ||
.pipe(gulp.dest(paths.output)); | ||
}); | ||
|
||
gulp.task('build-es6', function () { | ||
return gulp.src(paths.output + jsName) | ||
.pipe(gulp.dest(paths.output + 'es6')); | ||
return buildModule('es6', 'es6'); | ||
}); | ||
|
||
gulp.task('build-commonjs', function () { | ||
return gulp.src(paths.output + jsName) | ||
.pipe(to5(assign({}, compilerOptions, {modules:'common'}))) | ||
.pipe(gulp.dest(paths.output + 'commonjs')); | ||
return buildModule('es5', 'commonjs'); | ||
}); | ||
|
||
gulp.task('build-amd', function () { | ||
return gulp.src(paths.output + jsName) | ||
.pipe(to5(assign({}, compilerOptions, {modules:'amd'}))) | ||
.pipe(gulp.dest(paths.output + 'amd')); | ||
return buildModule('es5', 'amd'); | ||
}); | ||
|
||
gulp.task('build-system', function () { | ||
return gulp.src(paths.output + jsName) | ||
.pipe(to5(assign({}, compilerOptions, {modules:'system'}))) | ||
.pipe(gulp.dest(paths.output + 'system')); | ||
return buildModule('es5', 'system'); | ||
}); | ||
|
||
gulp.task('build-dts', function(){ | ||
return gulp.src(paths.output + paths.packageName + '.d.ts') | ||
.pipe(rename(paths.packageName + '.d.ts')) | ||
.pipe(gulp.dest(paths.output + 'es6')) | ||
.pipe(gulp.dest(paths.output + 'commonjs')) | ||
.pipe(gulp.dest(paths.output + 'amd')) | ||
.pipe(gulp.dest(paths.output + 'system')); | ||
function buildModule(target, targetName) { | ||
var tsResult = gulp.src([ | ||
paths.output + tsName, | ||
paths.aureliaDependenciesDefinitions]) | ||
.pipe(sourcemaps.init()) | ||
.pipe(ts(assign({}, compilerOptions, {"target":target,"module":targetName}))); | ||
|
||
return merge([ | ||
tsResult.dts.pipe(gulp.dest(paths.output + targetName)), | ||
tsResult.js | ||
.pipe(sourcemaps.write()) | ||
.pipe(gulp.dest(paths.output + targetName)) | ||
]); | ||
} | ||
|
||
gulp.task('copy-dts-for-docs', function () { | ||
return gulp.src([ | ||
paths.output + 'es6/*.d.ts' | ||
]) | ||
.pipe(gulp.dest(paths.output)); | ||
}); | ||
|
||
gulp.task('build', function(callback) { | ||
return runSequence( | ||
'clean', | ||
'build-index', | ||
['build-es6', 'build-commonjs', 'build-amd', 'build-system'], | ||
'build-dts', | ||
'copy-dts-for-docs', | ||
callback | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
"target": "", | ||
"declarationFiles": true, | ||
"noExternalResolve": true, | ||
"noImplicitAny": false, | ||
"noEmitOnError": true, | ||
"experimentalDecorators": true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Why don't You just use tsconfig.json for gulp also (so that You don't have to maintain more than one configuration for typeScript compiler).
I guess You want all d.ts files to be included from the project, except node_modules, so this can be achieved using simple
"exclude": ["node_modules"]
as seen from @ctoran pull request: https://github.com/aurelia/event-aggregator/pull/13/files#diff-e5e546dd2eb0351f813d63d1b39dbc48R9 .See also https://github.com/aurelia/event-aggregator/pull/13/files#diff-40e62be8220b9aeab02f5a664980bd73R12 to use the same tsconfig.json file for gulp (with exactly the same setup) that is used for IDE
var tsProject = ts.createProject('tsconfig.json', {
and then use it in build-ts task:
.pipe(ts(tsProject))
as shown here:
https://github.com/aurelia/event-aggregator/pull/13/files#diff-40e62be8220b9aeab02f5a664980bd73R24