From 9c720796e50b5bffd26ec8c69dc247d6122fde25 Mon Sep 17 00:00:00 2001 From: Sam Thorogood Date: Fri, 9 Mar 2018 09:38:58 +1100 Subject: [PATCH] add externs to remove disabled warning --- build.js | 8 ++++---- src/externs.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/externs.js diff --git a/build.js b/build.js index 9f87283..12f95af 100644 --- a/build.js +++ b/build.js @@ -20,19 +20,19 @@ const closureCompiler = new ClosureCompiler({ js: './src/*.js', entry_point: './src/index.js', js_output_file: './proxy.min.js', - language_in: 'ECMASCRIPT6', + language_in: 'ECMASCRIPT6_STRICT', language_out: 'ECMASCRIPT5', compilation_level: 'ADVANCED_OPTIMIZATIONS', dependency_mode: 'STRICT', + warning_level: 'VERBOSE', process_common_js_modules: true, output_wrapper: '(function(){%output%})()', // this prevents closure compiler from polluting the global scope - jscomp_off: 'undefinedVars', // `global` and `process` are not defined... }); const compilerProcess = closureCompiler.run((code, stdout, stderr) => { if (stderr) { - console.error('err!', stdErr); + console.error('err!', stderr); return; } - console.log('done!'); + console.log('done!', stdout); }); diff --git a/src/externs.js b/src/externs.js new file mode 100644 index 0000000..6953584 --- /dev/null +++ b/src/externs.js @@ -0,0 +1,30 @@ +/* + * Copyright 2018 Google Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +/** + * @externs + * @fileoverview Externs so that Closure doesn't complain about environment checks. + */ + +/** + * @type {Object} + */ +var process; + +/** + * @type {Object} + */ +var global;