Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

feat(compile): fix #892, upgrade to typescript 2.3.4, support for...of when build zone-node #897

Merged
merged 2 commits into from
Sep 13, 2017
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
21 changes: 18 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ function generateScript(inFile, outFile, minify, callback) {
.pipe(rollup({
entry: inFile,
format: 'umd',
onwarn: function (warning) {
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
if (warning.code === 'THIS_IS_UNDEFINED') {
return;
}
console.error(warning.message);
},
banner: '/**\n'
+ '* @license\n'
+ '* Copyright Google Inc. All Rights Reserved.\n'
Expand Down Expand Up @@ -71,16 +78,24 @@ gulp.task('compile', function(cb) {
tsc('tsconfig.json', cb);
});

gulp.task('compile-node', function(cb) {
tsc('tsconfig-node.json', cb);
});

gulp.task('compile-esm', function(cb) {
tsc('tsconfig-esm.json', cb);
});

gulp.task('compile-esm-node', function(cb) {
tsc('tsconfig-esm-node.json', cb);
});

gulp.task('build/zone.js.d.ts', ['compile-esm'], function() {
return gulp.src('./build-esm/lib/zone.d.ts').pipe(rename('zone.js.d.ts')).pipe(gulp.dest('./dist'));
});

// Zone for Node.js environment.
gulp.task('build/zone-node.js', ['compile-esm'], function(cb) {
gulp.task('build/zone-node.js', ['compile-esm-node'], function(cb) {
return generateScript('./lib/node/rollup-main.ts', 'zone-node.js', false, cb);
});

Expand All @@ -90,7 +105,7 @@ gulp.task('build/zone.js', ['compile-esm'], function(cb) {
});

// Zone for electron/nw environment.
gulp.task('build/zone-mix.js', ['compile-esm'], function(cb) {
gulp.task('build/zone-mix.js', ['compile-esm-node'], function(cb) {
return generateScript('./lib/mix/rollup-mix.ts', 'zone-mix.js', false, cb);
});

Expand Down Expand Up @@ -257,7 +272,7 @@ gulp.task('build', [
'build/closure.js'
]);

gulp.task('test/node', ['compile'], function(cb) {
gulp.task('test/node', ['compile-node'], function(cb) {
var JasmineRunner = require('jasmine');
var jrunner = new JasmineRunner();

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"ts-loader": "^0.6.0",
"tslint": "^4.1.1",
"tslint-eslint-rules": "^3.1.0",
"typescript": "2.2.1",
"typescript": "2.3.4",
"vrsource-tslint-rules": "^4.0.0",
"webdriver-manager": "^12.0.6",
"webdriverio": "^4.8.0",
Expand Down
24 changes: 24 additions & 0 deletions test/common/Promise.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/

import {isNode} from '../../lib/common/utils';
import {ifEnvSupports} from '../test-util';

declare const global: any;

class MicroTaskQueueZoneSpec implements ZoneSpec {
Expand Down Expand Up @@ -365,6 +367,28 @@ describe(
expect(value).toEqual(['resolution', 'v1']);
});
});

it('should resolve generators', ifEnvSupports(
() => {
return isNode;
},
() => {
const generators: any = function*() {
yield Promise.resolve(1);
yield Promise.resolve(2);
return;
};
queueZone.run(() => {
let value = null;
Promise.all(generators()).then(val => {
value = val;
});
// expect(Zone.current.get('queue').length).toEqual(2);
flushMicrotasks();
expect(value).toEqual([1, 2]);
});

}));
});
});

Expand Down
26 changes: 26 additions & 0 deletions tsconfig-esm-node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "es2015",
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": false,
"noImplicitThis": false,
"outDir": "build-esm",
"inlineSourceMap": false,
"inlineSources": false,
"declaration": true,
"noEmitOnError": false,
"stripInternal": true,
"sourceMap": true,
"downlevelIteration": true,
"moduleResolution": "node",
"lib": ["es5", "dom", "es2015.promise"]
},
"exclude": [
"node_modules",
"build",
"build-esm",
"dist",
"lib/closure"
]
}
2 changes: 1 addition & 1 deletion tsconfig-esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"dist",
"lib/closure"
]
}
}
24 changes: 24 additions & 0 deletions tsconfig-node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": false,
"noImplicitThis": false,
"outDir": "build",
"inlineSourceMap": true,
"inlineSources": true,
"declaration": false,
"downlevelIteration": true,
"noEmitOnError": false,
"stripInternal": false,
"lib": ["es5", "dom", "es2015.promise"]
},
"exclude": [
"node_modules",
"build",
"build-esm",
"dist",
"lib/closure"
]
}