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

tools(compiler): use closure compiler #1219

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion 3p/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@


// This list should not get longer without a very good reason.
import '../third_party/babel/custom-babel-helpers';
//import '../third_party/babel/custom-babel-helpers';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to instead do this as a preprocess step.

72 changes: 72 additions & 0 deletions build-system/tasks/compile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
var closureCompiler = require('gulp-closure-compiler');
var gulp = require('gulp');

gulp.task('compile', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments here from my PR.

/*eslint "google-camelcase/google-camelcase": 0*/
//return gulp.src(['{src,3p,ads,extensions,builtins}/**.js'])
return gulp.src([
'ads/**.js',
'build/css.js',
'src/**/*.js',
'builtins/**.js',
'third_party/caja/html-sanitizer.js',
'third_party/closure-library/sha384-generated.js',
'node_modules/document-register-element/build/document-register-element.max.js',
'node_modules/core-js/modules/es6.math.sign.js',
'node_modules/core-js/modules/$.sign.js',
'node_modules/core-js/modules/$.def.js',
'node_modules/core-js/modules/$.global.js',
'node_modules/core-js/modules/$.core.js',
'node_modules/core-js/modules/$.redef.js',
'node_modules/core-js/modules/$.hide.js',
'node_modules/core-js/modules/$.uid.js',
'node_modules/core-js/modules/$.property-desc.js',
'node_modules/core-js/modules/$.support-desc.js',
'node_modules/core-js/modules/$.fails.js',
'node_modules/core-js/modules/$.js',
'node_modules/core-js/modules/$.library.js',
'node_modules/core-js/modules/$.ctx.js',
'node_modules/core-js/modules/$.classof.js',
'node_modules/core-js/modules/$.is-object.js',
'node_modules/core-js/modules/$.an-object.js',
'node_modules/core-js/modules/$.a-function.js',
'node_modules/core-js/modules/$.cof.js',
'node_modules/core-js/modules/$.wks.js',
'node_modules/core-js/modules/$.strict-new.js',
'node_modules/core-js/modules/$.for-of.js',
'node_modules/core-js/modules/$.set-proto.js',
'node_modules/core-js/modules/$.same.js',
'node_modules/core-js/modules/$.species.js',
'node_modules/core-js/modules/$.microtask.js',
'node_modules/core-js/modules/$.iter-call.js',
'node_modules/core-js/modules/$.is-array-iter.js',
'node_modules/core-js/modules/$.to-length.js',
'node_modules/core-js/modules/core.get-iterator-method.js',
'node_modules/core-js/modules/$.task.js',
'node_modules/core-js/modules/$.shared.js',
'node_modules/core-js/modules/$.mix.js',
'node_modules/core-js/modules/$.tag.js',
'node_modules/core-js/modules/$.iterators.js',
'node_modules/core-js/modules/$.has.js',
'node_modules/core-js/modules/$.invoke.js',
'node_modules/core-js/modules/$.html.js',
'node_modules/core-js/modules/$.dom-create.js',
'node_modules/core-js/modules/$.to-integer.js',
'node_modules/core-js/modules/$.iter-detect.js',
'node_modules/core-js/modules/es6.promise.js',
'!node_modules/core-js/modules/library/**.js',
'!**_test.js'
]).pipe(closureCompiler({
compilerPath: 'node_modules/google-closure-compiler/compiler.jar',
fileName: 'build-cc.js',
compilerFlags: {
language_in: 'ECMASCRIPT6',
language_out: 'ECMASCRIPT5',
js_module_root: 'node_modules/',
common_js_entry_module: 'src/amp.js',
process_common_js_modules: null,
manage_closure_dependencies: null
}
}))
.pipe(gulp.dest('dist'));
});
1 change: 1 addition & 0 deletions build-system/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
require('./babel-helpers');
require('./changelog');
require('./clean');
require('./compile');
require('./lint');
require('./make-golden');
require('./presubmit-checks');
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
"eslint-plugin-google-camelcase": "0.0.2",
"finalhandler": "0.4.0",
"fs-extra": "0.26.0",
"google-closure-compiler": "20151216.0.0",
"gulp": "3.9.0",
"gulp-eslint": "1.1.0",
"gulp-closure-compiler": "0.3.1",
"gulp-exec": "2.1.2",
"gulp-file": "0.2.0",
"gulp-git": "1.5.0",
Expand Down
3 changes: 2 additions & 1 deletion src/amp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import {installStyles, makeBodyVisible} from './styles';
import {installErrorReporting} from './error';
import {stubElements} from './custom-element';
import {adopt} from './runtime';
import {cssText} from '../build/css.js';
import {cssText} from '../build/css';
import {action} from './action';
import {maybeValidate} from './validator-integration';


// We must under all circumstances call makeBodyVisible.
// It is much better to have AMP tags not rendered than having
// a completely blank page.
Expand Down
3 changes: 2 additions & 1 deletion src/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ const TEMPLATE_TAG_SUPPORTED = 'content' in document.createElement('template');
/**
* Registers an element. Upgrades it if has previously been stubbed.
* @param {!Window} win
* @param {string}
* @param {string} name
* @param {function(!Function)} toClass
* @export
*/
export function upgradeOrRegisterElement(win, name, toClass) {
if (!knownElements[name]) {
Expand Down
2 changes: 1 addition & 1 deletion src/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


import {getMode} from './mode';
import {exponentialBackoff} from './exponential-backoff.js';
import {exponentialBackoff} from './exponential-backoff';
import {makeBodyVisible} from './styles';

const globalExponentialBackoff = exponentialBackoff(1.5);
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@


import 'document-register-element/build/document-register-element.max';
import '../third_party/babel/custom-babel-helpers';
//import '../third_party/babel/custom-babel-helpers';
import './custom-core-js-shim';
5 changes: 1 addition & 4 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ export class Viewer {
* @param {*} data
* @param {boolean} awaitResponse
* @return {(!Promise<*>|undefined)}
* @package
* @export
*/
receiveMessage(eventType, data, awaitResponse) {
Expand Down Expand Up @@ -479,7 +478,6 @@ export class Viewer {
* Provides a message delivery mechanism by which AMP document can send
* messages to the viewer.
* @param {function(string, *, boolean):(!Promise<*>|undefined)} deliverer
* @package
* @export
*/
setMessageDeliverer(deliverer) {
Expand Down Expand Up @@ -532,11 +530,10 @@ export class Viewer {
/**
* Parses the viewer parameters as a string.
*
* Visible for testing only.
*
* @param {string} str
* @param {!Object<string, string>} allParams
* @private
* visibleForTesting
*/
export function parseParams_(str, allParams) {
const params = parseQueryString(str);
Expand Down
2 changes: 1 addition & 1 deletion src/viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import {Observable} from './observable';
import {assert} from './asserts.js';
import {assert} from './asserts';
import {getService} from './service';
import {layoutRectLtwh} from './layout-rect';
import {log} from './log';
Expand Down