Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗✨ Upgrade closure compiler to v20190709 #23417

Merged
merged 8 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions build-system/compile/closure-compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ exports.gulpClosureCompile = function(compilerOptions) {

if (compilerOptions.includes('SINGLE_FILE_COMPILATION=true')) {
// For single-pass compilation, use the default compiler.jar
// TODO(rsimha): Use the native compiler instead of compiler.jar once a fix
// is checked in for https://github.com/google/closure-compiler/issues/3041
closureCompiler.compiler.JAR_PATH = require.resolve(
'../../third_party/closure-compiler/compiler.jar'
'../../node_modules/google-closure-compiler-java/compiler.jar'
);
} else {
// On Mac OS and Linux, speed up compilation using nailgun.
Expand Down
16 changes: 13 additions & 3 deletions build-system/compile/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function compile(entryModuleFilenames, outputDir, outputFilename, options) {
'build-system/event-timing.extern.js',
'build-system/layout-jank.extern.js',
'build-system/performance-observer.extern.js',
'third_party/closure-compiler/externs/web_animations.js',
'third_party/web-animations-externs/web_animations.js',
'third_party/moment/moment.extern.js',
'third_party/react-externs/externs.js',
];
Expand Down Expand Up @@ -324,14 +324,24 @@ function compile(entryModuleFilenames, outputDir, outputFilename, options) {
compilerOptions.jscomp_error.push(
'conformanceViolations',
'checkTypes',
'accessControls',
'const',
'constantProperty',
'globalThis'
);
compilerOptions.jscomp_off.push('moduleLoad', 'unknownDefines');
compilerOptions.jscomp_off.push(
'accessControls',
'moduleLoad',
'unknownDefines'
);
compilerOptions.conformance_configs =
'build-system/conformance-config.textproto';
// TODO(cvializ, #23417): Remove these after fixing React.Component type errors.
compilerOptions.hide_warnings_for.push(
'extensions/amp-date-picker/0.1/date-picker-common.js',
'extensions/amp-date-picker/0.1/react-utils.js',
'extensions/amp-date-picker/0.1/single-date-picker.js',
'extensions/amp-date-picker/0.1/wrappers/maximum-nights.js'
);
} else {
compilerOptions.jscomp_warning.push('accessControls', 'moduleLoad');
compilerOptions.jscomp_off.push('unknownDefines');
Expand Down
20 changes: 6 additions & 14 deletions build-system/compile/single-pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,14 @@ exports.getFlags = function(config) {
language_out: config.language_out || 'ES5',
module_output_path_prefix: config.writeTo || 'out/',
module_resolution: 'NODE',
process_common_js_modules: true,
externs: config.externs,
define: config.define,
// Turn off warning for "Unknown @define" since we use define to pass
// args such as FORTESTING to our runner.
jscomp_off: ['unknownDefines'],
// checkVars: Demote "variable foo is undeclared" errors.
// moduleLoad: Demote "module not found" errors to ignore missing files
// in type declarations in the swg.js bundle.
jscomp_warning: ['checkVars', 'moduleLoad'],
jscomp_error: [
'checkTypes',
'accessControls',
'const',
'constantProperty',
'globalThis',
],
// See https://github.com/google/closure-compiler/wiki/Warnings#warnings-categories
// for a full list of closure's default error / warning levels.
jscomp_off: ['accessControls', 'unknownDefines'],
jscomp_warning: ['checkTypes', 'checkVars', 'moduleLoad'],
jscomp_error: ['const', 'constantProperty', 'globalThis'],
hide_warnings_for: config.hideWarningsFor,
};
if (argv.pretty_print) {
Expand Down
1 change: 1 addition & 0 deletions build-system/conformance-config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ requirement: {
error_message: 'History.p.state is broken in IE11. Please use the helper methods provided in src/history.js'
value: 'History.prototype.state'
whitelist: 'src/history.js'
whitelist: 'extensions/amp-date-picker/0.1/react-utils.js'
}

# Strings
Expand Down
86 changes: 1 addition & 85 deletions build-system/runner/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<property name="build.dir" value="${basedir}/build"/>
<property name="dist.dir" value="${basedir}/dist"/>
<property name="runner-jarfile" value="${build.dir}/${ant.project.name}.jar"/>
<property name="compiler.dir" value="${basedir}/../../third_party/closure-compiler"/>
<property name="compiler.dir" value="${basedir}/../../node_modules/google-closure-compiler-java"/>

<property name="classes.dir" value="${build.dir}/classes"/>
<property name="testClasses.dir" value="${build.dir}/test"/>
Expand Down Expand Up @@ -54,100 +54,16 @@
<classpath refid="srcclasspath.path"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
<!-- This copy is needed for tests -->
<copy file="${compiler.dir}/Messages.properties"
todir="${classes.dir}/com/google/javascript/rhino/"/>
<!-- This copy is needed for tests -->
<copy file="${compiler.dir}/ParserConfig.properties"
todir="${classes.dir}/com/google/javascript/jscomp/parsing"/>
</target>

<target name="clean" description="delete generated files">
<delete dir="${build.dir}"/>
</target>

<target name="test" depends="compile-tests">
<mkdir dir="build/testoutput"/>
<junit printsummary="on" fork="${test.fork}"
forkmode="once" showoutput="true"
dir="${basedir}"
failureproperty="junit.failure">
<classpath refid="allclasspath.path" />
<classpath>
<pathelement location="${build.dir}/test"/>
</classpath>
<batchtest todir="build/testoutput">
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<fileset dir="${build.dir}/test">
<include name="**/${test.class}.class"/>
</fileset>
</batchtest>
</junit>
<junitreport>
<fileset dir="build/testoutput" includes="*.xml"/>
<report todir="build/testoutput"/>
</junitreport>
<fail if="junit.failure" message="Unit tests failed. See build/testoutput/index.html"/>
</target>

<target name="compile-tests" depends="compile">
<mkdir dir="${testClasses.dir}"/>
<javac srcdir="${src.dir}"
destdir="${testClasses.dir}"
excludes=".git,**/debugger/**,.DS_Store"
debug="on"
deprecation="on"
includeantruntime="false"
encoding="utf-8">
<classpath refid="allclasspath.path"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
<javac srcdir="${test.dir}"
destdir="${testClasses.dir}"
excludes=".git,.DS_Store"
debug="on"
deprecation="on"
includeantruntime="false"
encoding="utf-8">
<classpath refid="allclasspath.path"/>
</javac>
</target>

<target name="one-test" depends="compile-tests">
<mkdir dir="build/testoutput"/>
<junit printsummary="on" fork="${test.fork}"
forkmode="once" showoutput="true"
dir="${basedir}"
failureproperty="junit.failure">
<classpath refid="allclasspath.path"/>
<classpath>
<pathelement location="${build.dir}/test"/>
</classpath>
<test todir="build/testoutput" name="${test.class}" methods="${test.method}">
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
</test>
</junit>
<junitreport>
<fileset dir="build/testoutput" includes="*.xml"/>
<report todir="build/testoutput"/>
</junitreport>
<fail if="junit.failure"
message="Unit tests failed. See build/testoutput/index.html"/>
</target>

<path id="srcclasspath.path">
<pathelement location="${classes.dir}"/>
<fileset dir="${compiler.dir}">
<include name="compiler.jar"/>
</fileset>
</path>

<path id="allclasspath.path">
<pathelement location="${classes.dir}"/>
<fileset dir="${compiler.dir}">
<include name="compiler-and-tests.jar"/>
</fileset>
</path>
</project>
Binary file modified build-system/runner/dist/runner.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected AmpCommandLineRunner(String[] args) {
options.setCollapsePropertiesLevel(CompilerOptions.PropertyCollapseLevel.ALL);
AmpPass ampPass = new AmpPass(getCompiler(), is_production_env, suffixTypes);
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, ampPass);
options.setDevirtualizePrototypeMethods(true);
options.setDevirtualizeMethods(true);
options.setExtractPrototypeMemberDeclarations(true);
options.setSmartNameRemoval(true);
options.optimizeCalls = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class NativeWebAnimationRunner extends AnimationRunner {
if (request.vars) {
setStyles(request.target, assertDoesNotContainDisplay(request.vars));
}
const player = request.target.animate(request.keyframes, request.timing);
const player = request.target.animate(
/** @type {!Array<Object>} */ (request.keyframes),
request.timing
);
player.pause();
return player;
});
Expand Down
10 changes: 5 additions & 5 deletions extensions/amp-date-picker/0.1/date-picker-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function withDatePickerCommon(WrappedComponent) {
const isInclusivelyAfterDay = reactDates['isInclusivelyAfterDay'];
const isInclusivelyBeforeDay = reactDates['isInclusivelyBeforeDay'];
const React = requireExternal('react');
const moment = requireExternal('moment');
const Moment = requireExternal('moment');

/**
* If `max` is null, the default minimum date is the current date.
Expand All @@ -40,7 +40,7 @@ export function withDatePickerCommon(WrappedComponent) {
* @return {?moment}
*/
function getDefaultMinDate(max) {
const today = moment();
const today = Moment();
if (max) {
return !isInclusivelyAfterDay(today, max) ? today : null;
} else {
Expand Down Expand Up @@ -68,8 +68,8 @@ export function withDatePickerCommon(WrappedComponent) {
* @return {boolean}
*/
function isOutsideRange(min, max, date) {
const maxInclusive = max ? moment(max) : null;
const minInclusive = min ? moment(min) : getDefaultMinDate(maxInclusive);
const maxInclusive = max ? Moment(max) : null;
const minInclusive = min ? Moment(min) : getDefaultMinDate(maxInclusive);
if (!maxInclusive && !minInclusive) {
return false;
} else if (!minInclusive) {
Expand Down Expand Up @@ -211,7 +211,7 @@ export function withDatePickerCommon(WrappedComponent) {

const initialDate =
initialVisibleMonth || date || startDate || endDate || undefined;
props['initialVisibleMonth'] = () => moment(initialDate);
props['initialVisibleMonth'] = () => Moment(initialDate);

return React.createElement(
WrappedComponent,
Expand Down
145 changes: 0 additions & 145 deletions third_party/closure-compiler/Allow-relative-path-reference-types.patch

This file was deleted.

Loading