diff --git a/gulpfile.js b/gulpfile.js index ccd5a2327..e30cfb842 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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' @@ -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); }); @@ -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); }); @@ -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(); diff --git a/package.json b/package.json index 10a32b0ae..083f47404 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index bfed003d6..f8f0e8e1b 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -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 { @@ -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]); + }); + + })); }); }); diff --git a/tsconfig-esm-node.json b/tsconfig-esm-node.json new file mode 100644 index 000000000..8aecae97e --- /dev/null +++ b/tsconfig-esm-node.json @@ -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" + ] +} diff --git a/tsconfig-esm.json b/tsconfig-esm.json index 0f7cf2776..c563ffda8 100644 --- a/tsconfig-esm.json +++ b/tsconfig-esm.json @@ -22,4 +22,4 @@ "dist", "lib/closure" ] -} \ No newline at end of file +} diff --git a/tsconfig-node.json b/tsconfig-node.json new file mode 100644 index 000000000..4e5512c20 --- /dev/null +++ b/tsconfig-node.json @@ -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" + ] +}