forked from w3c/trusted-types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
144 lines (135 loc) · 3.61 KB
/
Gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* eslint-disable */
/**
* @license
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.
*
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*/
var gulp = require('gulp');
var sizereport = require('gulp-sizereport');
var closureCompiler = require('google-closure-compiler').gulp();
var sourcemaps = require('gulp-sourcemaps');
function compileSettings(entryPoint, fileName, languageOut) {
return Object.assign({}, flags, {
js_output_file: fileName,
language_out: languageOut,
entry_point: entryPoint,
});
}
var flags = {
dependency_mode: 'PRUNE',
isolation_mode: 'IIFE',
strict_mode_input: null,
compilation_level: 'ADVANCED',
language_in: 'ECMASCRIPT6_STRICT',
jscomp_warning: [],
jscomp_error: [
"accessControls",
"checkDebuggerStatement",
"checkPrototypalTypes",
"checkRegExp",
"checkTypes",
"checkVars",
"conformanceViolations",
"const",
"constantProperty",
"deprecated",
"deprecatedAnnotations",
"duplicate",
"duplicateMessage",
"es5Strict",
"externsValidation",
"functionParams",
"globalThis",
"invalidCasts",
"misplacedTypeAnnotation",
"missingOverride",
"missingPolyfill",
"missingProperties",
"missingProvide",
"missingRequire",
"missingReturn",
// "missingSourcesWarnings", // Implies reportUnknownTypes.
"moduleLoad",
"msgDescriptions",
"nonStandardJsDocs",
// "reportUnknownTypes", // Too many "could not determine the type of this expression" errors
"strictCheckTypes",
"strictMissingProperties",
"strictModuleDepCheck",
"strictPrimitiveOperators",
"suspiciousCode",
"tooManyTypeParams",
"typeInvalidation",
"undefinedVars",
"underscore",
"unknownDefines",
"unusedLocalVariables",
"unusedPrivateMembers",
"uselessCode",
"visibility",
],
use_types_for_optimization: null,
assume_function_wrapper: null,
};
gulp.task('es5.api', function() {
return gulp.src([
'./src/**/*.js',
], {base: './'})
.pipe(sourcemaps.init())
.pipe(closureCompiler(
compileSettings(
'./src/polyfill/api_only.js',
'trustedtypes.api_only.build.js',
'ECMASCRIPT5')))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/es5'));
});
gulp.task('es5.full', function() {
return gulp.src([
'./src/**/*.js',
], {base: './'})
.pipe(sourcemaps.init())
.pipe(closureCompiler(
compileSettings(
'src/polyfill/full.js',
'trustedtypes.build.js',
'ECMASCRIPT5')))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/es5'));
});
gulp.task('es6.api', function() {
return gulp.src([
'./src/**/*.js',
], {base: './'})
.pipe(sourcemaps.init())
.pipe(closureCompiler(
compileSettings(
'src/polyfill/api_only.js',
'trustedtypes.api_only.build.js',
'ECMASCRIPT_2017')))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/es6'));
});
gulp.task('es6.full', function() {
return gulp.src([
'./src/**/*.js',
], {base: './'})
.pipe(sourcemaps.init())
.pipe(closureCompiler(
compileSettings(
'src/polyfill/full.js',
'trustedtypes.build.js',
'ECMASCRIPT_2017')))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/es6'));
});
gulp.task('sizereport', function() {
return gulp.src('./dist/es*/*.js')
.pipe(sizereport({gzip: true}));
});
gulp.task('es5', gulp.parallel('es5.full', 'es5.api'));
gulp.task('es6', gulp.parallel('es6.full', 'es6.api'));
gulp.task('default', gulp.series('es5'));