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

Commit 431cfac

Browse files
committed
feat(rollup): use new rollup config to prevent warning
1 parent 42b9edb commit 431cfac

File tree

1 file changed

+94
-74
lines changed

1 file changed

+94
-74
lines changed

gulpfile.js

+94-74
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,22 +21,28 @@ function generateScript(inFile, outFile, minify, callback) {
2121
var parts = [
2222
gulp.src('./build-esm/lib/**/*.js')
2323
.pipe(rollup({
24-
entry: inFile,
24+
input: inFile,
2525
format: 'umd',
26-
onwarn: function (warning) {
26+
onwarn: function(warning) {
2727
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
2828
if (warning.code === 'THIS_IS_UNDEFINED') {
2929
return;
3030
}
3131
console.error(warning.message);
3232
},
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-
+ '*/',
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+
external: id => {
41+
if (/build-esm/.test(id)) {
42+
return false;
43+
}
44+
return /rxjs/.test(id);
45+
},
4046
globals: {
4147
'rxjs/Observable': 'Rx',
4248
'rxjs/Subscriber': 'Rx',
@@ -56,21 +62,22 @@ function generateScript(inFile, outFile, minify, callback) {
5662

5763
// returns the script path for the current platform
5864
function platformScriptPath(path) {
59-
return /^win/.test(os.platform()) ? `${path}.cmd` : path;
65+
return /^win/.test(os.platform()) ? `${path}.cmd` : path;
6066
}
6167

6268
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-
});
69+
spawn(path.normalize(platformScriptPath('./node_modules/.bin/tsc')), ['-p', config], {
70+
stdio: 'inherit'
71+
}).on('close', function(exitCode) {
72+
if (exitCode) {
73+
var err = new Error('TypeScript compiler failed');
74+
// The stack is not useful in this context.
75+
err.showStack = false;
76+
cb(err);
77+
} else {
78+
cb();
79+
}
80+
});
7481
}
7582

7683
// This is equivalent to `npm run tsc`.
@@ -91,7 +98,9 @@ gulp.task('compile-esm-node', function(cb) {
9198
});
9299

93100
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'));
101+
return gulp.src('./build-esm/lib/zone.d.ts')
102+
.pipe(rename('zone.js.d.ts'))
103+
.pipe(gulp.dest('./dist'));
95104
});
96105

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

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

131140
gulp.task('build/zone-error.js', ['compile-esm'], function(cb) {
@@ -137,59 +146,68 @@ gulp.task('build/zone-error.min.js', ['compile-esm'], function(cb) {
137146
});
138147

139148
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);
149+
return generateScript(
150+
'./lib/browser/webapis-media-query.ts', 'webapis-media-query.js', false, cb);
141151
});
142152

143153
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);
154+
return generateScript(
155+
'./lib/browser/webapis-media-query.ts', 'webapis-media-query.min.js', true, cb);
145156
});
146157

147158
gulp.task('build/webapis-notification.js', ['compile-esm'], function(cb) {
148-
return generateScript('./lib/browser/webapis-notification.ts', 'webapis-notification.js', false, cb);
159+
return generateScript(
160+
'./lib/browser/webapis-notification.ts', 'webapis-notification.js', false, cb);
149161
});
150162

151163
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);
164+
return generateScript(
165+
'./lib/browser/webapis-notification.ts', 'webapis-notification.min.js', true, cb);
153166
});
154167

155168
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);
169+
return generateScript(
170+
'./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.js', false, cb);
157171
});
158172

159173
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);
174+
return generateScript(
175+
'./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.min.js', true,
176+
cb);
161177
});
162178

163179
gulp.task('build/webapis-shadydom.js', ['compile-esm'], function(cb) {
164-
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb);
180+
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb);
165181
});
166182

167183
gulp.task('build/webapis-shadydom.min.js', ['compile-esm'], function(cb) {
168-
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.min.js', true, cb);
184+
return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.min.js', true, cb);
169185
});
170186

171187
gulp.task('build/zone-patch-cordova.js', ['compile-esm'], function(cb) {
172-
return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.js', false, cb);
188+
return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.js', false, cb);
173189
});
174190

175191
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);
192+
return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.min.js', true, cb);
177193
});
178194

179195
gulp.task('build/zone-patch-electron.js', ['compile-esm'], function(cb) {
180-
return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.js', false, cb);
196+
return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.js', false, cb);
181197
});
182198

183199
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);
200+
return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.min.js', true, cb);
185201
});
186202

187203
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);
204+
return generateScript(
205+
'./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.js', false, cb);
189206
});
190207

191208
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);
209+
return generateScript(
210+
'./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb);
193211
});
194212

195213
gulp.task('build/zone-patch-socket-io.js', ['compile-esm'], function(cb) {
@@ -201,11 +219,11 @@ gulp.task('build/zone-patch-socket-io.min.js', ['compile-esm'], function(cb) {
201219
});
202220

203221
gulp.task('build/bluebird.js', ['compile-esm'], function(cb) {
204-
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb);
222+
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb);
205223
});
206224

207225
gulp.task('build/bluebird.min.js', ['compile-esm'], function(cb) {
208-
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.min.js', true, cb);
226+
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.min.js', true, cb);
209227
});
210228

211229
gulp.task('build/jasmine-patch.js', ['compile-esm'], function(cb) {
@@ -225,11 +243,13 @@ gulp.task('build/mocha-patch.min.js', ['compile-esm'], function(cb) {
225243
});
226244

227245
gulp.task('build/long-stack-trace-zone.js', ['compile-esm'], function(cb) {
228-
return generateScript('./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.js', false, cb);
246+
return generateScript(
247+
'./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.js', false, cb);
229248
});
230249

231250
gulp.task('build/long-stack-trace-zone.min.js', ['compile-esm'], function(cb) {
232-
return generateScript('./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.min.js', true, cb);
251+
return generateScript(
252+
'./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.min.js', true, cb);
233253
});
234254

235255
gulp.task('build/proxy-zone.js', ['compile-esm'], function(cb) {
@@ -277,8 +297,7 @@ gulp.task('build/rxjs.min.js', ['compile-esm'], function(cb) {
277297
});
278298

279299
gulp.task('build/closure.js', function() {
280-
return gulp.src('./lib/closure/zone_externs.js')
281-
.pipe(gulp.dest('./dist'));
300+
return gulp.src('./lib/closure/zone_externs.js').pipe(gulp.dest('./dist'));
282301
});
283302

284303
gulp.task('build', [
@@ -366,12 +385,12 @@ gulp.task('lint', () => {
366385
const tslintConfig = require('./tslint.json');
367386

368387
return gulp.src(['lib/**/*.ts', 'test/**/*.ts'])
369-
.pipe(tslint({
370-
tslint: require('tslint').default,
371-
configuration: tslintConfig,
372-
formatter: 'prose',
373-
}))
374-
.pipe(tslint.report({emitError: true}));
388+
.pipe(tslint({
389+
tslint: require('tslint').default,
390+
configuration: tslintConfig,
391+
formatter: 'prose',
392+
}))
393+
.pipe(tslint.report({emitError: true}));
375394
});
376395

377396
// clang-format entry points
@@ -385,49 +404,50 @@ gulp.task('format:enforce', () => {
385404
const format = require('gulp-clang-format');
386405
const clangFormat = require('clang-format');
387406
return gulp.src(srcsToFmt).pipe(
388-
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
407+
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
389408
});
390409

391410
// Format the source code with clang-format (see .clang-format)
392411
gulp.task('format', () => {
393412
const format = require('gulp-clang-format');
394413
const clangFormat = require('clang-format');
395-
return gulp.src(srcsToFmt, { base: '.' }).pipe(
396-
format.format('file', clangFormat)).pipe(gulp.dest('.'));
414+
return gulp.src(srcsToFmt, {base: '.'})
415+
.pipe(format.format('file', clangFormat))
416+
.pipe(gulp.dest('.'));
397417
});
398418

399419
// Update the changelog with the latest changes
400420
gulp.task('changelog', () => {
401421
const conventionalChangelog = require('gulp-conventional-changelog');
402422

403423
return gulp.src('CHANGELOG.md')
404-
.pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, {
405-
// Conventional Changelog Context
406-
// We have to manually set version number so it doesn't get prefixed with `v`
407-
// See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
408-
currentTag: require('./package.json').version
409-
}))
410-
.pipe(gulp.dest('./'));
424+
.pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, {
425+
// Conventional Changelog Context
426+
// We have to manually set version number so it doesn't get prefixed with `v`
427+
// See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
428+
currentTag: require('./package.json').version
429+
}))
430+
.pipe(gulp.dest('./'));
411431
});
412432

413433
// run promise aplus test
414434
gulp.task('promisetest', ['build/zone-node.js'], (cb) => {
415-
const promisesAplusTests = require('promises-aplus-tests');
416-
const adapter = require('./promise-adapter');
417-
promisesAplusTests(adapter, { reporter: "dot" }, function (err) {
418-
if (err) {
419-
cb(err);
420-
}
421-
});
435+
const promisesAplusTests = require('promises-aplus-tests');
436+
const adapter = require('./promise-adapter');
437+
promisesAplusTests(adapter, {reporter: 'dot'}, function(err) {
438+
if (err) {
439+
cb(err);
440+
}
441+
});
422442
});
423443

424444
// check dist file size limitation
425445
gulp.task('filesize', ['build'], (cb) => {
426-
const checker = require('./check-file-size');
427-
const result = checker(require('./file-size-limit.json'));
428-
if (result) {
429-
cb();
430-
} else {
431-
cb('check file size failed');
432-
}
446+
const checker = require('./check-file-size');
447+
const result = checker(require('./file-size-limit.json'));
448+
if (result) {
449+
cb();
450+
} else {
451+
cb('check file size failed');
452+
}
433453
});

0 commit comments

Comments
 (0)