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

Commit edf3e29

Browse files
committed
feat(rollup): use new rollup config to prevent warning
1 parent 6852f1d commit edf3e29

File tree

1 file changed

+105
-83
lines changed

1 file changed

+105
-83
lines changed

gulpfile.js

+105-83
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
var gulp = require('gulp');
1111
var rollup = require('gulp-rollup');
12-
var rename = require("gulp-rename");
12+
var rename = require('gulp-rename');
1313
var uglify = require('gulp-uglify');
1414
var pump = require('pump');
1515
var path = require('path');
@@ -21,28 +21,36 @@ function generateScript(inFile, outFile, minify, callback) {
2121
var parts = [
2222
gulp.src('./build-esm/lib/**/*.js')
2323
.pipe(rollup({
24-
entry: inFile,
25-
format: 'umd',
26-
onwarn: function (warning) {
24+
input: inFile,
25+
onwarn: function(warning) {
2726
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
2827
if (warning.code === 'THIS_IS_UNDEFINED') {
2928
return;
3029
}
3130
console.error(warning.message);
3231
},
33-
banner: '/**\n'
34-
+ '* @license\n'
35-
+ '* Copyright Google Inc. All Rights Reserved.\n'
36-
+ '*\n'
37-
+ '* Use of this source code is governed by an MIT-style license that can be\n'
38-
+ '* found in the LICENSE file at https://angular.io/license\n'
39-
+ '*/',
40-
globals: {
41-
'rxjs/Observable': 'Rx',
42-
'rxjs/Subscriber': 'Rx',
43-
'rxjs/Subscription': 'Rx',
44-
'rxjs/scheduler/asap': 'Rx.Scheduler',
45-
'rxjs/symbol/rxSubscriber': 'Rx.Symbol'
32+
output: {
33+
format: 'umd',
34+
banner: '/**\n' +
35+
'* @license\n' +
36+
'* Copyright Google Inc. All Rights Reserved.\n' +
37+
'*\n' +
38+
'* Use of this source code is governed by an MIT-style license that can be\n' +
39+
'* found in the LICENSE file at https://angular.io/license\n' +
40+
'*/',
41+
globals: {
42+
'rxjs/Observable': 'Rx',
43+
'rxjs/Subscriber': 'Rx',
44+
'rxjs/Subscription': 'Rx',
45+
'rxjs/scheduler/asap': 'Rx.Scheduler',
46+
'rxjs/symbol/rxSubscriber': 'Rx.Symbol'
47+
}
48+
},
49+
external: id => {
50+
if (/build-esm/.test(id)) {
51+
return false;
52+
}
53+
return /rxjs/.test(id);
4654
}
4755
}))
4856
.pipe(rename(outFile)),
@@ -56,21 +64,22 @@ function generateScript(inFile, outFile, minify, callback) {
5664

5765
// returns the script path for the current platform
5866
function platformScriptPath(path) {
59-
return /^win/.test(os.platform()) ? `${path}.cmd` : path;
67+
return /^win/.test(os.platform()) ? `${path}.cmd` : path;
6068
}
6169

6270
function tsc(config, cb) {
63-
spawn(path.normalize(platformScriptPath('./node_modules/.bin/tsc')), ['-p', config], {stdio: 'inherit'})
64-
.on('close', function(exitCode) {
65-
if (exitCode) {
66-
var err = new Error('TypeScript compiler failed');
67-
// The stack is not useful in this context.
68-
err.showStack = false;
69-
cb(err);
70-
} else {
71-
cb();
72-
}
73-
});
71+
spawn(path.normalize(platformScriptPath('./node_modules/.bin/tsc')), ['-p', config], {
72+
stdio: 'inherit'
73+
}).on('close', function(exitCode) {
74+
if (exitCode) {
75+
var err = new Error('TypeScript compiler failed');
76+
// The stack is not useful in this context.
77+
err.showStack = false;
78+
cb(err);
79+
} else {
80+
cb();
81+
}
82+
});
7483
}
7584

7685
// This is equivalent to `npm run tsc`.
@@ -91,7 +100,9 @@ gulp.task('compile-esm-node', function(cb) {
91100
});
92101

93102
gulp.task('build/zone.js.d.ts', ['compile-esm'], function() {
94-
return gulp.src('./build-esm/lib/zone.d.ts').pipe(rename('zone.js.d.ts')).pipe(gulp.dest('./dist'));
103+
return gulp.src('./build-esm/lib/zone.d.ts')
104+
.pipe(rename('zone.js.d.ts'))
105+
.pipe(gulp.dest('./dist'));
95106
});
96107

97108
// Zone for Node.js environment.
@@ -125,7 +136,7 @@ gulp.task('build/zone-testing.js', ['compile-esm'], function(cb) {
125136

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

131142
gulp.task('build/zone-error.js', ['compile-esm'], function(cb) {
@@ -137,59 +148,68 @@ gulp.task('build/zone-error.min.js', ['compile-esm'], function(cb) {
137148
});
138149

139150
gulp.task('build/webapis-media-query.js', ['compile-esm'], function(cb) {
140-
return generateScript('./lib/browser/webapis-media-query.ts', 'webapis-media-query.js', false, cb);
151+
return generateScript(
152+
'./lib/browser/webapis-media-query.ts', 'webapis-media-query.js', false, cb);
141153
});
142154

143155
gulp.task('build/webapis-media-query.min.js', ['compile-esm'], function(cb) {
144-
return generateScript('./lib/browser/webapis-media-query.ts', 'webapis-media-query.min.js', true, cb);
156+
return generateScript(
157+
'./lib/browser/webapis-media-query.ts', 'webapis-media-query.min.js', true, cb);
145158
});
146159

147160
gulp.task('build/webapis-notification.js', ['compile-esm'], function(cb) {
148-
return generateScript('./lib/browser/webapis-notification.ts', 'webapis-notification.js', false, cb);
161+
return generateScript(
162+
'./lib/browser/webapis-notification.ts', 'webapis-notification.js', false, cb);
149163
});
150164

151165
gulp.task('build/webapis-notification.min.js', ['compile-esm'], function(cb) {
152-
return generateScript('./lib/browser/webapis-notification.ts', 'webapis-notification.min.js', true, cb);
166+
return generateScript(
167+
'./lib/browser/webapis-notification.ts', 'webapis-notification.min.js', true, cb);
153168
});
154169

155170
gulp.task('build/webapis-rtc-peer-connection.js', ['compile-esm'], function(cb) {
156-
return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.js', false, cb);
171+
return generateScript(
172+
'./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.js', false, cb);
157173
});
158174

159175
gulp.task('build/webapis-rtc-peer-connection.min.js', ['compile-esm'], function(cb) {
160-
return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.min.js', true, cb);
176+
return generateScript(
177+
'./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.min.js', true,
178+
cb);
161179
});
162180

163181
gulp.task('build/webapis-shadydom.js', ['compile-esm'], function(cb) {
164-
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb);
182+
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb);
165183
});
166184

167185
gulp.task('build/webapis-shadydom.min.js', ['compile-esm'], function(cb) {
168-
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.min.js', true, cb);
186+
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.min.js', true, cb);
169187
});
170188

171189
gulp.task('build/zone-patch-cordova.js', ['compile-esm'], function(cb) {
172-
return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.js', false, cb);
190+
return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.js', false, cb);
173191
});
174192

175193
gulp.task('build/zone-patch-cordova.min.js', ['compile-esm'], function(cb) {
176-
return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.min.js', true, cb);
194+
return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.min.js', true, cb);
177195
});
178196

179197
gulp.task('build/zone-patch-electron.js', ['compile-esm'], function(cb) {
180-
return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.js', false, cb);
198+
return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.js', false, cb);
181199
});
182200

183201
gulp.task('build/zone-patch-electron.min.js', ['compile-esm'], function(cb) {
184-
return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.min.js', true, cb);
202+
return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.min.js', true, cb);
185203
});
186204

187205
gulp.task('build/zone-patch-user-media.js', ['compile-esm'], function(cb) {
188-
return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.js', false, cb);
206+
return generateScript(
207+
'./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.js', false, cb);
189208
});
190209

191210
gulp.task('build/zone-patch-user-media.min.js', ['compile-esm'], function(cb) {
192-
return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb);
211+
return generateScript(
212+
'./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb);
193213
});
194214

195215
gulp.task('build/zone-patch-socket-io.js', ['compile-esm'], function(cb) {
@@ -209,11 +229,11 @@ gulp.task('build/zone-patch-promise-testing.min.js', ['compile-esm'], function(c
209229
});
210230

211231
gulp.task('build/bluebird.js', ['compile-esm'], function(cb) {
212-
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb);
232+
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb);
213233
});
214234

215235
gulp.task('build/bluebird.min.js', ['compile-esm'], function(cb) {
216-
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.min.js', true, cb);
236+
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.min.js', true, cb);
217237
});
218238

219239
gulp.task('build/zone-patch-jsonp.js', ['compile-esm'], function(cb) {
@@ -241,11 +261,13 @@ gulp.task('build/mocha-patch.min.js', ['compile-esm'], function(cb) {
241261
});
242262

243263
gulp.task('build/long-stack-trace-zone.js', ['compile-esm'], function(cb) {
244-
return generateScript('./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.js', false, cb);
264+
return generateScript(
265+
'./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.js', false, cb);
245266
});
246267

247268
gulp.task('build/long-stack-trace-zone.min.js', ['compile-esm'], function(cb) {
248-
return generateScript('./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.min.js', true, cb);
269+
return generateScript(
270+
'./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.min.js', true, cb);
249271
});
250272

251273
gulp.task('build/proxy-zone.js', ['compile-esm'], function(cb) {
@@ -301,8 +323,7 @@ gulp.task('build/rxjs-fake-async.min.js', ['compile-esm'], function(cb) {
301323
});
302324

303325
gulp.task('build/closure.js', function() {
304-
return gulp.src('./lib/closure/zone_externs.js')
305-
.pipe(gulp.dest('./dist'));
326+
return gulp.src('./lib/closure/zone_externs.js').pipe(gulp.dest('./dist'));
306327
});
307328

308329
gulp.task('build', [
@@ -396,12 +417,12 @@ gulp.task('lint', () => {
396417
const tslintConfig = require('./tslint.json');
397418

398419
return gulp.src(['lib/**/*.ts', 'test/**/*.ts'])
399-
.pipe(tslint({
400-
tslint: require('tslint').default,
401-
configuration: tslintConfig,
402-
formatter: 'prose',
403-
}))
404-
.pipe(tslint.report({emitError: true}));
420+
.pipe(tslint({
421+
tslint: require('tslint').default,
422+
configuration: tslintConfig,
423+
formatter: 'prose',
424+
}))
425+
.pipe(tslint.report({emitError: true}));
405426
});
406427

407428
// clang-format entry points
@@ -415,51 +436,52 @@ gulp.task('format:enforce', () => {
415436
const format = require('gulp-clang-format');
416437
const clangFormat = require('clang-format');
417438
return gulp.src(srcsToFmt).pipe(
418-
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
439+
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
419440
});
420441

421442
// Format the source code with clang-format (see .clang-format)
422443
gulp.task('format', () => {
423444
const format = require('gulp-clang-format');
424445
const clangFormat = require('clang-format');
425-
return gulp.src(srcsToFmt, { base: '.' }).pipe(
426-
format.format('file', clangFormat)).pipe(gulp.dest('.'));
446+
return gulp.src(srcsToFmt, {base: '.'})
447+
.pipe(format.format('file', clangFormat))
448+
.pipe(gulp.dest('.'));
427449
});
428450

429451
// Update the changelog with the latest changes
430452
gulp.task('changelog', () => {
431453
const conventionalChangelog = require('gulp-conventional-changelog');
432454

433455
return gulp.src('CHANGELOG.md')
434-
.pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, {
435-
// Conventional Changelog Context
436-
// We have to manually set version number so it doesn't get prefixed with `v`
437-
// See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
438-
currentTag: require('./package.json').version
439-
}))
440-
.pipe(gulp.dest('./'));
456+
.pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, {
457+
// Conventional Changelog Context
458+
// We have to manually set version number so it doesn't get prefixed with `v`
459+
// See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
460+
currentTag: require('./package.json').version
461+
}))
462+
.pipe(gulp.dest('./'));
441463
});
442464

443465
// run promise aplus test
444466
gulp.task('promisetest', ['build/zone-node.js'], (cb) => {
445-
const promisesAplusTests = require('promises-aplus-tests');
446-
const adapter = require('./promise-adapter');
447-
promisesAplusTests(adapter, { reporter: "dot" }, function (err) {
448-
if (err) {
449-
cb(err);
450-
} else {
451-
cb();
452-
}
453-
});
467+
const promisesAplusTests = require('promises-aplus-tests');
468+
const adapter = require('./promise-adapter');
469+
promisesAplusTests(adapter, {reporter: 'dot'}, function(err) {
470+
if (err) {
471+
cb(err);
472+
} else {
473+
cb();
474+
}
475+
});
454476
});
455477

456478
// check dist file size limitation
457479
gulp.task('filesize', ['build'], (cb) => {
458-
const checker = require('./check-file-size');
459-
const result = checker(require('./file-size-limit.json'));
460-
if (result) {
461-
cb();
462-
} else {
463-
cb('check file size failed');
464-
}
480+
const checker = require('./check-file-size');
481+
const result = checker(require('./file-size-limit.json'));
482+
if (result) {
483+
cb();
484+
} else {
485+
cb('check file size failed');
486+
}
465487
});

0 commit comments

Comments
 (0)