diff --git a/package.json b/package.json index c37cd6f6a..214d484ff 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,10 @@ "build:blocks": "gulp buildBlocks", "build:compressed": "gulp buildCompressed", "build:core": "gulp buildCore", - "build:debug": "gulp buildCompressed --verbose --strict", + "build:debug": "gulp buildCompressed --verbose --debug", "build:debug:log": "npm run build:debug > build-debug.log 2>&1 && tail -3 build-debug.log", + "build:strict": "gulp buildCompressed --verbose --strict", + "build:strict:log": "npm run build:strict > build-debug.log 2>&1 && tail -3 build-debug.log", "build:generators": "gulp buildGenerators", "build:langfiles": "gulp buildLangfiles", "build:uncompressed": "gulp buildUncompressed", diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index 72173ffa5..a5a96a407 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -106,8 +106,11 @@ var JSCOMP_ERROR = [ * @param {boolean=} opt_verbose Optional option for verbose logging * @param {boolean=} opt_warnings_as_error Optional option for treating warnings * as errors. + * @param {boolean=} opt_strict_typechecker Optional option for enabling strict + * type checking. */ -function compile(compilerOptions, opt_verbose, opt_warnings_as_error) { +function compile(compilerOptions, opt_verbose, opt_warnings_as_error, + opt_strict_typechecker) { const options = {}; options.compilation_level = 'SIMPLE_OPTIMIZATIONS'; options.warning_level = opt_verbose ? 'VERBOSE' : 'DEFAULT'; @@ -115,8 +118,11 @@ function compile(compilerOptions, opt_verbose, opt_warnings_as_error) { options.language_out = 'ECMASCRIPT5_STRICT'; options.rewrite_polyfills = false; options.hide_warnings_for = 'node_modules'; - if (opt_warnings_as_error) { + if (opt_warnings_as_error || opt_strict_typechecker) { options.jscomp_error = JSCOMP_ERROR; + if (opt_strict_typechecker) { + options.jscomp_error.push('strictCheckTypes'); + } } const platform = ['native', 'java', 'javascript']; @@ -203,7 +209,7 @@ function buildCompressed() { language_in: argv.closureLibrary ? 'ECMASCRIPT_2015' : 'ECMASCRIPT5_STRICT', output_wrapper: outputWrapperUMD('Blockly', []) - }, argv.verbose, argv.strict)) + }, argv.verbose, argv.debug, argv.strict)) .pipe(gulp.sourcemaps.mapSources(function (sourcePath, file) { return sourcePath.replace(/-/g, '/'); })) @@ -231,7 +237,7 @@ function buildBlocks() { amd: './blockly_compressed.js', cjs: './blockly_compressed.js' }]) - }, argv.verbose, argv.strict)) + }, argv.verbose, argv.debug, argv.strict)) .pipe(gulp.sourcemaps.write('.', { includeContent: false, sourceRoot: './' @@ -257,7 +263,7 @@ function buildGenerator(language, namespace) { amd: './blockly_compressed.js', cjs: './blockly_compressed.js' }]) - }, argv.verbose, argv.strict)) + }, argv.verbose, argv.debug, argv.strict)) .pipe(gulp.sourcemaps.write('.', { includeContent: false, sourceRoot: './'