Navigation Menu

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

Commit

Permalink
feat(compile): fix #892, upgrade to typescript 2.3.4, support for...o…
Browse files Browse the repository at this point in the history
…f when build zone-node (#897)

* feat(compile): fix #892, upgrade to typescript 2.3.4(same with angular), add downlevelIteration options when build zone-node

* local test should also use downlevelIteration option
  • Loading branch information
JiaLiPassion authored and mhevery committed Sep 13, 2017
1 parent aec4bd4 commit e999593
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 5 deletions.
21 changes: 18 additions & 3 deletions gulpfile.js
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
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
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
@@ -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
Expand Up @@ -22,4 +22,4 @@
"dist",
"lib/closure"
]
}
}
24 changes: 24 additions & 0 deletions 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"
]
}

0 comments on commit e999593

Please sign in to comment.