Closure Compiler Changelog

What's new in Closure Compiler 20240317

Mar 19, 2024
  • Add --variable_map_input_file and --property_map_input_file options to the OSS command-line runner.
  • fix infinite recursion in certain template type checks
  • Moved the warning/error on use of string continuations to be a linter-only check.
  • Error on unrecognized Closure .base method calls instead of silently ignoring them, which would previously lead to property renaming bugs.
  • Rename removeDeadCode to removeUnreachableCode. remove_dead_code is replaced by remove_unreachable_code.
  • "dead code" is extremely ambiguous where as "unreachable" is more often used when talking about CFG guided code removals.
  • Add externs for maps api v3.56
  • Define --browser_featureset_year 2024 based on Chromium 120, Firefox 121, and Safari 17.2. For the first time, all major browsers have surpassed Closure Compiler's support for emitting JS, so users opting into BFY 2024 may see more modern JS in their binaries over time as support for emitting additional JS language features lands in Closure Compiler. And as always, userland code can also use goog.FEATURESET_YEAR to produce binaries specialized for modern browsers.
  • For more info on newly supported features, see: https://caniuse.com/?compare=chrome+108,safari+16.2,firefox+108,chrome+120,safari+17.2,firefox+121&compareCats=all
  • Notable features newly supported in 2024 browsers include: Offscreen Canvas, AVIF images, the loading attribute, Import Maps, CSS Subgrid, LCH and Lab color values, and tons of CSS features.
  • Merge #4134 by ecrider: Add missing AbortSignal static methods.
  • In addition, this also changes AbortSignal from @interface to @constructor, and add the missing property implementation (addEventListener, removeEventListener, dispatchEvent) as it was not required before as an interface.
  • Allow $ in @template names
  • Fix inlining bug treating assignments in chunks as unconditionally loaded
  • Added externs and polyfills for Array.findLast, Array.findLastIndex, and TypedArray variants (https://github.com/tc39/proposal-array-find-from-last)
  • Preserve unions of different ReadonlyArray types instead of using raw type
  • Detect toggle usage via goog.module.get.
  • Fix transpilation of block-scoped vars in loop bodies to no longer leak data from one iteration into the TDZ of the next iteration
  • Fix MakeDeclaredNamesUnique so that it does not generate conflicting names
  • Allow unused void operator without a suspicious code warning
  • Files annotated with @nocoverage will not be instrumented for code coverage.
  • Speed up escaping JavaScript.
  • Generate one conformance report for each chunk.
  • Allow subclasses to broaden visibility of overridden methods
  • Support tested assignments of classes (e.g. let Foo = Foo_1 = class Foo{}). This is newly emitted by TypeScript 5.2 for decorated classes, which reference a static property of itself.
  • Fix enclosing @ngInject detection for TypeScript 5.2 emit for decorated classes.
  • Fix case where goog.forwardDeclare conformance error message would omitted the goog.forwardDeclared type name and just print "NoResolvedType" instead.
  • Fixed bug where optimizations would, in rare cases, copy static properties between unrelated classes. This is unlikely to be a breaking change since those properties should later be dead-code eliminated, and any accidental references should cause a missing property error.
  • don't crash when emitting member function defs whose names refer to collapsed properties

New in Closure Compiler 20231112 (Nov 13, 2023)

  • Files annotated with @nocoverage will not be instrumented for code coverage.
  • Speed up escaping JavaScript.
  • Generate one conformance report for each chunk.
  • Allow subclasses to broaden visibility of overridden methods
  • Support tested assignments of classes (e.g. let Foo = Foo_1 = class Foo{}). This is newly emitted by TypeScript 5.2 for decorated classes, which reference a static property of itself.
  • Fix enclosing @ngInject detection for TypeScript 5.2 emit for decorated classes.
  • Fix case where goog.forwardDeclare conformance error message would omitted the goog.forwardDeclared type name and just print "NoResolvedType" instead.
  • Fixed bug where optimizations would, in rare cases, copy static properties between unrelated classes. This is unlikely to be a breaking change since those properties should later be dead-code eliminated, and any accidental references should cause a missing property error.
  • don't crash when emitting member function defs whose names refer to collapsed properties

New in Closure Compiler 20230802 (Aug 4, 2023)

  • RemoveUnusedCode will now generate an "unremovable.log" file when debug logging is enabled. It contains a line for each non-removed variable stating why it could not be removed.
  • Improve constant inference in BanElementSetAttribute
  • Removed support for referencing goog.module exports or local variables by the compiler-mangled name in JSDoc, e.g. @type {!module$exports$foo}. Use goog.require/goog.requireType instead.
  • Add support for the @pureOrBreakMyCode jsdoc annotation in the RemoveUnusedCode pass to help it decide if side effects can be removed.
  • Update the latestEcmaScript in JSCompiler config to return ES2021
  • Respect constantness indicated by @const when checking setAttribuite violations.
  • Add ReplaceToggles pass, which replaces calls to goog.toggle(num) with a direct lookup on the goog.TOGGLES_ bitset.

New in Closure Compiler 20230502 (May 5, 2023)

  • Add externs for maps api v3.53
  • Improve pathological edge case in InlineSimpleMethods performance

New in Closure Compiler 20230411 (Apr 13, 2023)

  • Made performance improvement that also slightly improves property disambiguation (i.e. type-based property renaming). This is generally expected to be a safe change, but in some edge cases could break code that has incorrect type annotations.
  • Fixed bug in polyfill isolation that sometimes caused polyfill of Reflect.construct to be used on ES6+ compatible browsers
  • Fix inlining goog.reflect.objectProperty
  • InlineAndCollapseProperties does a better job of inlining destructuring patterns, which can improve code sizes when targeting ES2015+ output.
  • Fix a bug in CoalesceVariableNames pass where we generate incorrect code with usePseudoNames=true
  • Remove the setCssRenamingMap/getCssRenamingMap APIs from Compiler/AbstractCompiler (but leave the ones in CompilerOptions where they make more sense).
  • Add a new compiler option to force let/const transpilation
  • Never suppress unrecognized type errors for goog.provide/goog.module namespaces. Previously, if running the compiler in a mode that sorts or prunes unused dependencies, all goog.module & goog.provide namespaces are "forward declared", so the compiler won't report unrecognized type errors for those namespaces.

New in Closure Compiler 20230228 (Mar 2, 2023)

  • Deleted CodingConvention::isInlinableFunction. The standard way of preventing inlining for a function is now the @noinline annotation in JSDoc.
  • Don't register types mismatch if actual type satisfies any of required union's alternates
  • Add externs for maps api v3.52
  • A for-of loop transpiled down to ES5 should throw a TypeError if the object to be iterated has neither a Symbol.iterator property nor a length property.
  • Allow @nosideeffects in function jsdoc outside of externs, and use it as a signal in PureFunctionIdentifier to treat the function as pure.
  • Prevent mutations to ReadonlyArrays.
  • Correct the name of SourceBuffer mode property from externs.
  • Fix behavior of Array.prototype.flat() and Array.prototype.flatMap() for sparse arrays.

New in Closure Compiler 20230206 (Feb 10, 2023)

  • Correct the name of SourceBuffer mode property from externs.
  • Fix behavior of Array.prototype.flat() and Array.prototype.flatMap() for sparse arrays.
  • Avoid using regex parser unless bundling or pruning unused inputs. This is expected to be a small speedup and not a breaking change.
  • Define --browser_featureset_year 2023 based on Chromium 108, Firefox 108 (jinx!), and Safari 16.2. Due to a missing feature in Safari, this will still emit ES2021, but userland code can still switch off of an expectation of more recent browsers.
  • For more info on newly supported features, see: https://caniuse.com/?compare=chrome+96,safari+15,firefox+95,chrome+108,safari+16.2,firefox+108&compareCats=all
  • Removed multiple deprecated compiler options: setInlineFunctions(boolean) was replaced by setInlineFunctions(Reach), setMoveFunctionDeclarations was replaced by setRewriteGlobalDeclarationsForTryCatchWrapping, and setCssRenamingWhitelist was replaced by setCssRenamingSkiplist
  • Speed up bundle generation by only relying on the regex-based fast parse. This is not expected to be a behavioral change.

New in Closure Compiler 20230103 (Jan 5, 2023)

  • Avoid checking weak sources when running CheckConformance to avoid false positives when sources are pulled in only for type references.
  • Report parse error on illegal LHS of += and similar operators
  • Rename Rhino Node isQuotedString and setQuotedString methods to better indicate the methods are for checking quoted property keys, not string literals with quotes. isQuotedString -> isQuotedStringKey and setQuotedString -> setQuotedStringKey.
  • Normalize arrow functions when transpiling classes with forced class transpilation Unnormalized arrows are not handled in ES6ExtractClasses pass and typically get normalized when the pass runs. But with forced class transpilation turned on, the normalization is skipped causing JSCompiler to crash.
  • Removes an old compiler feature preferNewLineAtEndOfFile that would cause the code printer to output additional whitespace between files when printing. There are no more use cases for this feature that was added to workaround an issue in source map composition in an old serving system.
  • Add debug logging annotation to observe inferred types.
  • Allow @suppress JSDoc on every statement, as opposed to only declarations/assignments.
  • Make IteratorIterable and IIterableResult covariant.
  • Add externs for maps api v3.51
  • Makes ReadonlyArray covariant.
  • Fixes value type inference on for-of over unions.
  • Handle default parameter assigned to class in ES6 class transpilation.
  • Corrects type inference for subscript access on unions.
  • Add conformance check for BANNED_STRING_REGEX.
  • Add typings on ReadonlyArray for ES6 Array methods.
  • Fixed bug present if using --language_out=ECMASCRIPT_2015 or higher and the "rename prefix namespace" functionality. Previously, functions declared in blocks in the global hoist scope were accidentally hoisted into the global scope. Now they are correctly treated as block-scoped.

New in Closure Compiler 20221102 (Nov 3, 2022)

  • Improve the compiler's license tracking so that input files with licensed code that end up unused after optimizations don't force the retention of the license texts.
  • Moved the com.google.javascript.jscomp.parsing.parser.util.format package to the more central location of com.google.javascript.jscomp.base.format
  • Java API change: deleted two of the five JSError.make variants that take explicit CheckLevels and override CheckLevel of the associated DiagnosticType.
  • Treat 'codebase' and 'data' as security sensitive attributes in the conformance checks
  • Remove "runtime type check" support.
  • This feature of the compiler has long been under used and under maintained. At this time we believe our efforts would be better spent elsewhere.
  • Deleted unused class com.google.javascript.rhino.SimpleErrorReporter
  • We now avoid creating an unshaded deploy jar that contains copies of dependencies instead of using dependencies from Maven.
  • Compiler_uberjar_deploy.jar has replaced compiler_unshaded_deploy.jar
  • Issue: https://github.com/google/closure-compiler/issues/3896
  • PR: https://github.com/google/closure-compiler/pull/3935
  • In conformance, treat setAttributeNS with a null namespace the same as setAttribute.
  • Allow @suppress {dangerousUnrecognizedTypeError} in JS code to suppress JSC_UNRECOGNIZED_TYPE_ERRORs.
  • Simplify logic in InlineSimpleMethods to fix compiler crash

New in Closure Compiler 20221004 (Oct 18, 2022)

  • Lint warnings about usage of var can now be suppressed with @suppress {lintVarDeclarations}
  • Allow dead-code elimination of (void 0)?.() in ES2022 output mode
  • Fixed bug where invalid super property and this references within the arguments of a super(...) constructor call were not reported
  • Added a compiler flag --assume_no_prototype_method_enumeration, which is mapped to CompilerOptions.crossChunkCodeMotionNoStubMethods, which controls CrossChunkMethodMotion#noStubFunctions. When it is set to true, it will allow the compiler to move a prototype method declaration into a deeper chunk without creating stub functions in a parent chunk.
  • Fixed bug where references to local variables named exports in a goog.module (e.g. function f(exports) {}) could be mangled.

New in Closure Compiler 20221005 (Oct 9, 2022)

  • Lint warnings about usage of var can now be suppressed with @suppress {lintVarDeclarations}
  • Allow dead-code elimination of (void 0)?.() in ES2022 output mode
  • Fixed bug where invalid super property and this references within the arguments of a super(...) constructor call were not reported
  • Added a compiler flag --assume_no_prototype_method_enumeration, which is mapped to CompilerOptions.crossChunkCodeMotionNoStubMethods, which controls CrossChunkMethodMotion#noStubFunctions. When it is set to true, it will allow the compiler to move a prototype method declaration into a deeper chunk without creating stub functions in a parent chunk.
  • Fixed bug where references to local variables named exports in a goog.module (e.g. function f(exports) {}) could be mangled.

New in Closure Compiler 20221005 (Oct 8, 2022)

  • Lint warnings about usage of var can now be suppressed with @suppress {lintVarDeclarations}
  • Allow dead-code elimination of (void 0)?.() in ES2022 output mode
  • Fixed bug where invalid super property and this references within the arguments of a super(...) constructor call were not reported
  • Added a compiler flag --assume_no_prototype_method_enumeration, which is mapped to CompilerOptions.crossChunkCodeMotionNoStubMethods, which controls CrossChunkMethodMotion#noStubFunctions. When it is set to true, it will allow the compiler to move a prototype method declaration into a deeper chunk without creating stub functions in a parent chunk.
  • Fixed bug where references to local variables named exports in a goog.module (e.g. function f(exports) {}) could be mangled.

New in Closure Compiler 20220905 (Sep 8, 2022)

  • Move CFG management out of NodeTraversal and into common callback base class (NodeTraversal.AbstractCfgCallback).
  • Add externs for maps api v3.50.
  • Modifications to make the missing property and property creations checks on union stricter. A property must be known on all members of a union (excluding null or undefined). Previously, existance on any member of the union was sufficient.
  • Fix incorrect optimization that inlines super.x() to super.x

New in Closure Compiler 20220803 (Aug 12, 2022)

  • Corrected a bug that could cause the source map info for a qualified name reference to point to the location of the qname's definition instead of the location of the reference itself.
  • Define a new DiagnosticType ILLEGAL_PROPERTY_CREATION_ON_UNION_TYPE that can be suppressed using strictMissingProperties.
  • Modify Closure Compiler open source build to pull in org.jspecify to add @Nullable annotations.
  • Remove support for @hidden as a part of message translation.
  • Always gather source map information for stages 1 and 2.
  • It doesn't make sense to specify the output source map location for the early stage invocations of a multi-stage build, but leaving it unspecified caused the compiler to lose type information that should have been gathered in those stages.

New in Closure Compiler 20220719 (Jul 22, 2022)

  • Make more property-based dead code elimination back off on reflective accesses of a property name, like goog.reflect.objectProperty('m', c).
  • Update GOOG_PROVIDE_REQUIRE_PATTERN and its usage to support multi-lines declarations
  • Make 2-lines module declarations recognizable by JsFileRegexParser.
  • Fix bug where types shadowing goog.module imports were not resolved
  • Fixed bug where function arguments with side effects were sometimes deleted
  • Improved dead-code elimination for special case of new class {}
  • When performing a partial (stage 1 or stage 2) compilation, the compiler compiler exits with a 0 status only when no errors are reported. The exit status contains the number of errors reported up to a maximum of 127.
  • This was always the intended behavior, and is consistent with single-stage compilation. A recent change accidentally caused it to exit with 0 for partial compilations regardless of any errors reported.
  • Added extern and polyfill for Object.hasOwn. Confirmed the TS declarations exist in the standard .d.ts files.
  • Updates to allow use of the 'd' flag for regular expressions and the indices values it creates. Currently, input and output language level need to be ES_NEXT to avoid an error message from the compiler for using this feature.
  • CLOSURE_DEFINES values may now be specified with separate invididual property assignments, rather than requiring them to be in a single object literal (though it must still be in the top-level/global scope). Duplicate keys produce an error.
  • Add extern definition for Object.hasOwn(object,property) method.
  • Added BanSettingAttributes conformance check
  • Added recognition, validation, and error of the new /d flag for RegExps as part of ES_2022.
  • Enable support for the Error constructor {cause: err} argument and Error.prototype.cause feature added in ES2022. NOTE: This behavior is not polyfilled. We only ensure that the compiler will not complain about the argument.
  • Rework pass config to aways run VarCheck pass after VariableReferenceCheck pass. This may cause more errors to surface in single-file transpilation mode.

New in Closure Compiler 20220601 (Jun 3, 2022)

  • Correct useless label optimization when a label is nested within a label. Fixes github issue #3946.
  • Compilation error on duplicate module and provide names.
  • Fix crash with label'd do/while blocks.
  • Support @provideAlreadyProvided during typechecking. Here we are doing a couple of things:
  • avoid creating a default namespace object type when a goog.provide is annotated with @provideAlreadyProvided.
  • add some logic find the type of the implicitly assigned namespace by looking up the object from the parent namespace object. The second is valid as @provideAlreadyProvided is only useful if the parent namespace is assigned a value that contains the child namespace.
  • Add externs for maps api v3.49.
  • Add a flag --emit_async_functions_with_zonejs to relax the restriction on disallowing --language_out=ES_2017 together with Zone.js
  • Fix cases of incorrect constant folding for the coalesce operator ??
  • Move "public class fields" feature down from ES_NEXT to UNSTABLE. Since ES_NEXT is supposed to be for features that are fully supported, and transpilation of public fields is not yet fully implemented, by our accounting it should only be considered UNSTABLE and not yet ES_NEXT. We do intend to add support for transpilation and will move the feature back to ES_NEXT when we do.
  • Fix false positive "missing @const annotation" lint when using destructuring assigns.
  • Fix potential misoptimization of variables/properties in a logical assignment. Some compiler passes failed to realize that such assignments could evaluate to a mutable value and so would delete code incorrect.
  • Set --angular_pass to true by default.
  • Refactor pass building so that there is a central way to check conditions for the pass. This is step toward making it easier to configure modes for the passes (transpile only, renaming only, etc).
  • Made typechecker change to fix edge cases where @implements {I<SomeType>} was treated as @implements {I<?}
  • Fix handling of tagged template literals side-effect detection to consider contained expressions.
  • Improves performance and memory usage of ControlFlowAnalysis.
  • Fix an issue when where source text could be retained in memory throughout the compilation process.
  • Fix an issue when resolving non-trivial unions when complex types, where the check for existence of template types would be n^2.

New in Closure Compiler 20220502 (May 5, 2022)

  • Allow specification of example text and original code text for message placeholders in goog.getMsg().
  • Enabled "unnecessary escape" lint warnings in untagged template literals
  • Add a new rule to OptimizeParameters to trim trailing undefined parameters from calls where the callee doesn't use rest parameters or access the arguments object. Should save code size in most applications since inlining functions that pass through optional params tends to create this pattern.
  • Remove references to goog.mixin now that it has been removed.
  • Loosen the constraints on goog.module.get so that only assignments to global variables are banned.
  • Add support for @provideAlreadyProvided
  • Make BanSetAttribute less restrictive by allowing certain "effectively constant" attribute names.
  • Only enable "unnecessary escape" warnings in the linter.
  • Support matching types imported from a JS boundle in conformance.
  • Fixed parser crash on multiline string literals with invalid escape sequences.
  • Modify for-await-of to only exist inside an async function.

New in Closure Compiler 20220405 (Apr 7, 2022)

  • Allow specification of example text and original code text for message placeholders in goog.getMsg().
  • Enabled "unnecessary escape" lint warnings in untagged template literals
  • Add a new rule to OptimizeParameters to trim trailing undefined parameters from calls where the callee doesn't use rest parameters or access the arguments object. Should save code size in most applications since inlining functions that pass through optional params tends to create this pattern.
  • Remove references to goog.mixin now that it has been removed.
  • Loosen the constraints on goog.module.get so that only assignments to global variables are banned.
  • Add support for @provideAlreadyProvided
  • Make BanSetAttribute less restrictive by allowing certain "effectively constant" attribute names.
  • Only enable "unnecessary escape" warnings in the linter.
  • Support matching types imported from a JS boundle in conformance.
  • Fixed parser crash on multiline string literals with invalid escape sequences.
  • Modify for-await-of to only exist inside an async function.

New in Closure Compiler 20220301 (Mar 3, 2022)

  • Remove GETPROP/GETELEM from NodeUtil.isSimpleOperator as getters/setters can have side-effects.
  • InlineObjectLiterals now identifies the right scope for statements with CASE nodes without user authored blocks.
  • Rename Closure Compiler debugger web UI checkbox names "PRESERVE_FULL_JSDOC_DESCRIPTIONS" and "PRESERVE_TYPE_ANNOTATIONS" to "PARSE_FULL_JSDOC_DESCRIPTIONS" and "PARSE_TYPE_ANNOTATIONS".
  • Fix optional chaining converting any following get property optional when removing brackets.
  • Add support for a new jsdoc annotation called @tstype. This can be used by .d.ts generation tools to specialize function type signatures. Currently this is uninterpreted by the compiler.
  • Add externs for maps api v3.48
  • Break down destructured node to simple var node in @typeSummary/.i.js files.
  • Ban setting inline event handlers with setAttribute.
  • Treat the first, not last, property definition's JSDoc as canonical for conformance and access controls checks.
  • Update BANNED_PROPERTY conformance check to cover object literals.
  • Added --isolate_polyfills flag to the open source command line runner.
  • Deleted deprecated method CompilerOptions.setBadRewriteProvidesInChecksOnlyThatWeWantToGetRidOf. This will only affect users of the Java API running with options.setChecksOnly(true)
  • Support BROWSER_FEATURESET_YEAR 2022.

New in Closure Compiler 20220202 (Feb 7, 2022)

  • Fix a compiler crash when trying to remove Object.defineProperties from within expressions (other than comma expressions). if conditions can be transformed into AND, OR, HOOK expressions and other expressions of arbitrary depth.
  • Support passing import.meta through to the output when using the --chunk_output_type=ES_MODULES option and an output language level of at least ES_2020. Be aware that the generated ES modules correspond to output chunks, which generally consist of multiple input files.
  • Renaming two Closure Templates annotations: @hassoydelcall is being renamed to @delcall, and @hassoydeltemplate -> @deltemplates. Support for the legacy names will be removed in a follow-up. This only affects code generated by the Closure Templates compiler, since these annotations are restricted.
  • Remove special support for v. This was necessary for IE8 and before but is no longer useful for later browsers. Reference: https://mathiasbynens.be/notes/javascript-escapes
  • Ignore base objects of empty types in BanSetAttribute conformance checks.
  • We've seen false positives related to this. In some terribly typed JS code, an object ends up being typed as an empty type (having as the bottom of object type lattice in most cases), which is considered to be a subtype of Element. Ignore objects with this type when checking whether an object is an Element.
  • Improved inference of function literals in some edge cases where they have no explicit JSDoc and are assigned to a lhs with a known type.
  • Remove RequireFileoverviewVisibility conformance rule definition.
  • Add additional data structure to speed up certain look up operations.
  • Remove JSChunk.addAfter API which is unused.
  • Replace JSChunk.getInput(idx) API by JSChunk.getFirst() since the only callsite in the codebase is accessing the first entry in the collection.
  • Fix crash when destructuring an object using a computed property name and default value.

New in Closure Compiler 20220104 (Jan 7, 2022)

  • Recognize "ns.Foo = Bar = class {}" as declaring a type "ns.Foo"
  • Calling compiler.restoreState() now verifies that compiler.init or compiler.initModules has already been called.
  • Improve the performance of sourcemap generation when embedding source text.
  • Remove GlobalVarReferenceMap which was part of now obsolete hotswap checking support.
  • Deleted methods from JSTypeRegistry that supported hotswap typechecking, as hotswap passes are no longer supported in the compiler.

New in Closure Compiler 20211006 (Oct 6, 2021)

  • Crash in Closure Compiler if languageOut is incompatible with ZoneJS. This only happens when the compiler detects ZoneJS as one of the inputs. This is because ZoneJS is incompatible with async functions (see https://github.com/angular/angular/issues/31730)
  • Added --assume_static_inheritance_is_not_used flag. It is on by default to be consistent with the previous behavior of the compiler. Setting it to false will make the compiler expect to see references to static methods via this in static methods or via subclass names and avoid changes that could break that.
  • Don't parse types in JSDoc @throws annotations anymore. Types become part of the textual description of the throws annotation.
  • Externs for Proxy are now included by default.
  • Fix output directory of --print_source_after_each_pass flag to be consistent with released notes.
  • Changed diagnostic type name for overriding final methods from JSC_CONSTANT_PROPERTY_REASSIGNED_VALUE to JSC_FINAL_PROPERTY_OVERRIDDEN. The canonical way of suppressing this error is now @suppress {visibility}. @suppress {const} and @suppress {constProperty} will still work until we finish cleaning up existing usages.
  • Deleted @deprecated setAliasAllStrings. Please use setAliasStringsMode(AliasStringsMode.ALL) to alias all repeated strings, which is the same behavior as setAliasAllStrings(true).
  • Added String.raw polyfill.
  • Update public method names in JSDocInfo to be consistent with other record* named methods
  • Add support for parsing and printing JSDoc text descriptions after @suppress annotation
  • Do not mark indirect calls to functions as useless code. Indirecting calls in the form (0, prefix.myFn)() prevents passing prefix as the this context object to myFn, which is useful. This fixes a dead code removal with TypeScript 4.4, which uses this pattern for functions imported from modules.

New in Closure Compiler 20210808 (Aug 11, 2021)

  • Add a FeatureSet corresponding to the ES2021 language version. Includes features in the ES2021 spec, e.g. logical assignment operators and numeric separators.
  • Fixed bug where builds with language_out ES2015+ did not see warning about rest parameter JSDoc missing the "..." variadic annotation.
  • Update Maps JS usage allowed externs to allow using the current weekly version (by explicit version number).
  • Ban files with nested goog.provides where a nested goog.provide is used as a @typedef. If you see a new JSC_TYPEDEF_CHILD_OF_PROVIDE error, the recommended fix is to delete the nested goog.provide (and optionally move to goog.module)
  • Fix to @const enforcement on @externs properties. A single assignment to the property in executable code now triggers an error.
  • Add an error for new proeprties in metadata: for Wiz views.
  • Fold String#replace when all the values are string literals. Add a few more unit tests to the String#replace folding
  • Remove the deprecated --module and --module_wrapper aliases for the --chunk and --chunk_wrapper flags.
  • Make JSC_POSSIBLE_INEXISTENT_PROPERTY error message explain what it actually means.
  • Symbol representing namespaces (declared by oog.provide or goog.module) are prefixed with ns$ in SymbolTable.
  • Add polyfills for Promise.any and AggregateError.
  • Switch @fileoverview parsing from "last one wins" to "first one wins". @suppress annotations are merged across all @fileoverviews in a file, including implicit ones (e.g. @externs).
  • Running in checksOnly mode no longer runs the pass that replaces goog.provide('a.b'); with var a = {}; a.b = {};. To temporarily revert this change, set options.setBadRewriteProvidesInChecksOnlyThatWeWantToGetRidOf(true).
  • Add polyfill and externs for String.prototype.replaceAll
  • Add externs for maps api v3.45
  • Added GamepadEvent to w3c_gamepad.js
  • Added constant folding support for Math.imul
  • Deleted deprecated CompilerOption setCheckGlobalNamesLevel and error group undefinedNames, as in --jscomp_{error,warning,off}=undefinedNames. These options were no-ops and are covered by other diagnostics. @suppress {undefinedNames} still parses but is a no-op.

New in Closure Compiler 20210601 (Jun 4, 2021)

  • Dropped RefasterJS from the closure-compiler GitHub repo, because it is unsupported. See https://github.com/google/closure-compiler/issues/3702
  • Avoid unnecessary polyfills when using browser FeatureSet year to select the output level.
  • Removed the remains of the "private by convention" wiring in the CodeConvention classes and associated lint checks.
  • Compiler option 'setBadRewriteModulesBeforeTypecheckingThatWeWantToGetRidOf' is now false by default. This may lead to new type errors. This change only affects users of the Java API, not the command line or NPM versions.
  • Deleted the BanExpose conformance rule. @expose is now a parse error so this conformance rule is unnecessary.
  • Removed support for deprecated JSDoc tag @expose. Instead either use @export to fix property renaming issues, or use @nocollapse to prevent problems with property flattening.

New in Closure Compiler 20210505 (May 14, 2021)

  • Deprecated the undefinedNames diagnostic group and removed the associated error. Undefined namespaces are still detected via enabling undefinedVars and missingProperties diagnostics.
  • Changes to the public command-line runner:
  • Remove long deprecated flags aliases
  • --module should be --chunk
  • --module_wrapper should be --chunk_wrapper
  • --module_output_path_prefix should be --chunk_output_path_prefix
  • --output_module_dependencies should be --output_chunk_dependencies
  • --common_js_module_path_prefix should be --js_module_root
  • --common_js_entry_module should be --entry_point
  • --closure_entry_point should be --entry_point
  • --module should be --chunk
  • --manage_closure_dependencies should be --dependency_mode=PRUNE_LEGACY
  • --only_closure_dependencies should be --dependency_mode=PRUNE
  • --polymer_pass should be --polymer_version=1
  • Remove long deprecated option --transform_amd_modules
  • Allow dynamic import expressions by default
  • Document the --json_streams flag
  • Enable optimal flags automatically when --chunk_output_type=ES_MODULES is specified
  • SourceMapConsumerV3: Add a field to OriginalMapping to indicate whether the mapping is exact, estimated, or of unknown precision.
  • Canonicalized destructuring import shorthand properties with the JSCompiler Linter.
  • Sped up serialization of AST and types in multistage builds. Not expected to be a behavioral change.
  • Added BanSetAttribute conformance check
  • For users of the Java API: deleted SourceFile.fromGenerated. Replace with either a reference to a file on disk or a preloaded string SourceFile.fromCode

New in Closure Compiler 20210406 (May 7, 2021)

  • Remove the ability to select specific strings to alias from the compiler API.
  • Enable trailing commas in arrow function parameter lists as allowed in the language spec: https://tc39.es/ecma262/#prod-CoverParenthesizedExpressionAndArrowParameterList
  • Add --dynamic_import_alias option which instructs the compiler to replace dynamic import expressions with a function call using the specified name. This allows dynamic import expressions to be externally polyfilled when the output language level does not natively support them.
  • Properly report a parse error for functions that have trailing commas after rest parameters.
  • In the AliasString pass remove support for skipping certain strings based on whether they match a supplied regex.
  • For AliasString pass, rather than using the source location of the file that aliased strings are added to, use instead the first original use location. This will prevent the first file of affected chucks from being artificially bloated when using source maps to determine "weight" of input source on the output.
  • The BanGlobalVars conformance rule now accepts specific variables names to allowlist via the value field.
  • Stricten validation of goog. module ids to match closure/base.js. Only ASCII, _, $, and 0-9 are now allowed.
  • Add linter warning for using extends keyword in @interface/@records definition.
  • Refactoring of compiler handling of goog.define: tooling using checksOnly will now see the original source's goog.define('name', 0); instead being rewritten to the default value 0
  • Implement decomposition of super.method() calls in ExpressionDecomposer. This fixed a compiler crash that could occur when inlining a function call into the arguments of a super.method() call.
  • Fixed enableMultistageCompilation() option in CompilerTestCase API to work again, and also run multistage compilation if enableNormalize() is on.
  • Fixes to optimizations of 'class side inhertiance', including small fixes to make optimizations both safer and more consistent

New in Closure Compiler 20200628 (Jul 7, 2020)

  • Simplified unused polyfill removal, with the result that more unnecessary polyfills may be present in the compiled output. This can happen when shares a name with an extern or structural type property.
  • Update AsyncGenerator type definition to have 3 template parameters instead of one. This brings it in line with TS and with the other Iterator types. Like those others, the 2 additional parameters aren't actually used yet.
  • --shadow_variables is now a no-op. The functionality scaled very poorly and proved to provide little meaningful value in practice.
  • Fix crash with new.target
  • Fix instanceof code removal bug
  • Add onChanged to Chrome extensions StorageArea
  • Rename WarningsGuard#Priority.SUPPRESS_BY_WHITELIST to SUPPRESS_BY_ALLOWLIST
  • Define TextEncoder.encodeInto API
  • Fixed com.google.javascript.refactoring.RefactoringUtils.isInClosurizedFile to recognize additional files declaring a goog.module as Closurized. Prior to this change, files that exported a class without requiring other imports may not have been recognized as Closurized.
  • Dropped 'duplicate requires' check from deps generator.
  • Addition of support for BigInt is in progress. With this release you may begin to see bigint mentioned in error messages. However, support for it isn't complete yet. We will announce when it is.
  • Declare HTMLVideoElement.requestVideoFrameCallback() and cancelVideoFrameCallback() See https://wicg.github.io/video-rvfc/

New in Closure Compiler 20200614 (Jun 17, 2020)

  • Fixed a bug causing OptimizeParameters to inline parameters for a case where the compiler couldn't actually see all calls to the function.
  • Avoid including polyfills for Promise and Symbol in ES_2015 output. They were previously getting unnecessarily included due to their use in transpilation of async functions.
  • Fixed bug triggered by re-freezing an object frozen before the JSCompiler WeakMap polyfill loaded
  • Polyfill isolation mode no longer supports inserting frozen/sealed/non-extensible objects into the Map, Set, WeakMap, or WeakSet polyfills.
  • Add externs for all remaining Web Crypto APIs specified at https://www.w3.org/TR/WebCryptoAPI/ that weren't already present.
  • Support transpilation of classes that extend native classes (e.g. Map). Previously only extension of Object and various Error classes were supported for ES6 classes being transpiled to ES5.
  • Changed the default error format to include multiple lines from the original source.
  • Fix invalid code generation when attempting to convert RegExp constructors whose patterns start with * to regex literals
  • Fixed OptimizeParameters to stop inlining yield and await expressions into other functions.
  • Added the NO_OP conformance rule, useful for removing conformance requirements from a codebase without breaking downstream builds that extend them.
  • Fix bug in AngularJS externs where templateUrl field was not indicated to be in the prototype of angular.$routeProvider.Params.
  • Add jasmine externs for setSpecProperty and setSuiteProperty, due in v3.6.
  • Add jasmine externs to jasmine namespace for Spec.getFullName, Env.configure, SpecResult, JasmineDoneInfo, jsApiReporter, HtmlReporter, QueryString, HtmlSpecFilter, and Timer.
  • Add definitions for DOMPoint to externs
  • Adds missing externs for HTMLTextAreaElement: maxLength, minLength, textLength.
  • Add externs for maps api v3.41
  • checkGlobalThisLevel compiler option has been removed. Use the globalThis diagnostic group instead to trigger the global this checks.
  • Added a suggested fix for the new more accurate missing require warnings.
  • Report syntax error for usage of yield or await in default parameter values. This has always been illegal JS syntax. If this change seems to break your project, then it was really already broken and you should fix your code.
  • Fixed crash caused by using @export without depending on base.js

New in Closure Compiler 20200517 (May 19, 2020)

  • Change the externs to the current shape of Trusted Types API.
  • Convert Symbol.iterator to a library polyfill
  • Omit weak files from the bundle output.
  • Make count optional in Atomics. {notify,wake}
  • Start polyfilling Symbol.iterator for TypedArrays when they are present.
  • Remove the legacy_js_project flag.
  • Convert Symbol.asyncIterator to a library polyfill
  • Transpile new.target -> this.constructor in ES6 constructors.
  • Skip the JSC_UNKNOWN_EXPR warning for unknown expressions used as standalone statements.
  • Fixed --isolate_polyfills bugs causing runtime exceptions in compiler library code

New in Closure Compiler 20200405 (May 5, 2020)

  • Conformance errors now print the conformance config file where the requirement was defined.
  • Remove extern definitions for obsolete static methods on Array that were only ever available on older versions of Mozilla products (such as FireFox and Rhino).
  • The "missing require" check no longer runs during lint.

New in Closure Compiler v20200315 (Apr 10, 2020)

  • Moved webassembly externs out of contrib.
  • Nullish coalesce operator (??) available with --language_in=ES_NEXT
  • Added a new suppression useOfGoogProvide to suppress the recently added lint error on goog.provide.
  • The "missing" and "extra" requires checks again run during lint/fixjs.
  • The "unknown class property" conformance check now recognizes ES6 classes. Previously a bug made it only apply to ES5 classes.
  • Fixed a bug that broke references to class static properties using the class's inner name. e.g.

New in Closure Compiler 20200224 (Feb 27, 2020)

  • Add externs for maps api v3.40
  • Avoid including polyfill for globalThis when input code doesn't use it.
  • Improved dead code elimination to realize exceptions thrown within try-catch blocks are side-effect free.
  • Fix optimization bug where functions using destructuring were sometimes incorrectly detected as side-effect-free and optimized away.
  • BANNED_PROPERTY (and related) conformance rules now apply to destructuring.
  • Extend "too many template parameters" warning to primitives like string
  • Drop support for modeling function hoisting in the typechecker. The typechecker expects all function references to be after the declaration. The only known behavioral change is that goog.module exports of ES5 classes that take advantage of function hoisting will no longer be typechecked. This change does not affect the runtime behavior.
  • Report an error for super used in a normal function even when it's nested in a class method.
  • Report an error for super() calls in arrow functions within constructors. The JS spec allows them as long as super() is called exactly once before any references to this or super.prop, but they make it very hard to determine statically whether super() is being called correctly. Code that is calling super() from an arrow function is unnecessarily complex and should be refactored.
  • Deleted the deprecated diagnostic group useOfGoogBase

New in Closure Compiler 20200112 (Jan 14, 2020)

  • CrossChunkMethodMotion no longer moves methods containing super. Referring to super in a non-method function is a syntax error.
  • Fixed crash when using for-of without externs
  • Added polyfill for globalThis.
  • Fixed bug where the ! operator did not always remove null/undefined on @typedefs
  • Added missing Symbol.iterator on return of String.prototype.matchAll().
  • String.prototype.matchAll() now throws error when non-global RegExp is passed in as parameter. Updated to match spec updated in Oct 2019 TC39 meeting.
  • Adds a warning for improperly formatted typeof annotations.
  • Implemented polyfill for String.prototype.matchAll(). Only available if you specify --lanauge_in=ES_NEXT.
  • Added globalThis to externs. Polyfill not yet available - coming soon.
  • Added String.prototype.matchAll() to externs. Polyfill not yet available - coming soon.
  • Referencing exports before assigning to exports is now an error in a goog.module.
  • Add externs for maps api v3.38 and v3.39
  • Remove the deprecated --dependency_mode STRICT and LOOSE, which are synonyms for PRUNE and PRUNE_LEGACY, respectively.
  • Fix the type for matchers.not in the Jasmine extern.
  • Fix a bug where semicolons would be moved into a template string literal.
  • Removed obsolete diagnostic group 'es3'. Setting --language_in to ES5 or greater is the replacement for this diagnostic group.
  • Remove obsolete diagnostic groups 'newCheckTypes', 'newCheckTypesCompatibility', and 'newCheckTypesExtraChecks'.
  • Remove obsolete diagnostic group 'ambiguousFunctionDecl'.
  • Deprecate and remove unuseful diagnotic group internetExplorerChecks. Setting the language_in to ECMASCRIPT5 or greater is the appropriate way to allow trailing commas in array or object literals.
  • Remove obsolete diagnostic group 'fileoverviewTags'
  • Fix an automatic semicolon insertion (ASI) bug with semicolons following newlines.

New in Closure Compiler 20200101 (Jan 4, 2020)

  • CrossChunkMethodMotion no longer moves methods containing super. Referring to super in a non-method function is a syntax error.
  • Fixed crash when using for-of without externs
  • Added polyfill for globalThis.
  • Fixed bug where the ! operator did not always remove null/undefined on @typedefs
  • Added missing Symbol.iterator on return of String.prototype.matchAll().
  • String.prototype.matchAll() now throws error when non-global RegExp is passed in as parameter. Updated to match spec updated in Oct 2019 TC39 meeting.
  • Adds a warning for improperly formatted typeof annotations.
  • Implemented polyfill for String.prototype.matchAll(). Only available if you specify --lanauge_in=ES_NEXT.
  • Added globalThis to externs. Polyfill not yet available - coming soon.
  • Added String.prototype.matchAll() to externs. Polyfill not yet available - coming soon.
  • Referencing exports before assigning to exports is now an error in a goog.module.
  • Add externs for maps api v3.38 and v3.39
  • Remove the deprecated --dependency_mode STRICT and LOOSE, which are synonyms for PRUNE and PRUNE_LEGACY, respectively.
  • Fix the type for matchers.not in the Jasmine extern.
  • Fix a bug where semicolons would be moved into a template string literal.
  • Removed obsolete diagnostic group 'es3'. Setting --language_in to ES5 or greater is the replacement for this diagnostic group.
  • Remove obsolete diagnostic groups 'newCheckTypes', 'newCheckTypesCompatibility', and 'newCheckTypesExtraChecks'.
  • Remove obsolete diagnostic group 'ambiguousFunctionDecl'.
  • Deprecate and remove unuseful diagnotic group internetExplorerChecks. Setting the language_in to ECMASCRIPT5 or greater is the appropriate way to allow trailing commas in array or object literals.
  • Remove obsolete diagnostic group 'fileoverviewTags'
  • Fix an automatic semicolon insertion (ASI) bug with semicolons following newlines.

New in Closure Compiler 20191027 (Nov 13, 2019)

  • Added externs for Jasmine 3.3.
  • Compiler enforces that goog.require is in the file scope, not within a function or conditional block.
  • Replace constant-inlined out-of-bounds array accesses with 'undefined' instead of reporting a warning
  • Fixed optimization bug on object destructuring declarations, which may cause a slight code size regression in some ES2015+ out targets.
  • In-browser transpiler is now build with J2CL rather than GWT.
  • Improved JSC_DUPLICATE_NAMESPACE error message to include the source of both the original provide and duplicate provide.
  • Remove support for duplicate sources in zip files.
  • Compiler now enforces that goog.module.declareLegacyNamespace() is immediately after the goog.module call.
  • Report undefined variable goog errors when using Closure dependency methods (goog.{provide,require,module,etc.}) without some definition of goog.
  • Removed "The template variable is unused" error to allow references to template variables from inline parameter declarations.
  • Added polyfill for Promise.allSettled (ES_2020 feature).
  • Referencing the exports namespace of a goog.module through this will no longer work compiled in exported functions. (Note: this pattern already causes a JSC_UNSAFE_THIS warning and breaks uncompiled when using destructuring requires)
  • Back off from strict missing property errors while checking property absence (if (x.y == null) will no longer give a strict error if x.y is missing).

New in Closure Compiler 20190709 (Aug 5, 2019)

  • Improved support for incremental compilation of Polymer Behaviors. Properties defined by behaviors are now accessible to the elements that apply them.
  • Type checker no longer autoboxes primitives when validating case expressions in a switch statement.

New in Closure Compiler 20190325 (Apr 17, 2019)

  • Iterable spread is now preserved for side-effects.
  • Some type references not explicitly annotated with ! are now considered nullable. Code should always explicitly specify nullability.
  • Fixed bug when dropping const-ness and JSDoc on names exported from goog.modules.
  • Improved type checking of ES module transitive imports / mutable exports.
  • export * from within ES modules is now supported.
  • --shadow_variables is now disabled by default. It does not scale well and provides little value in most cases.
  • Type checking performance improvement.
  • Added polyfills for trimStart/trimEnd.
  • Removed some rewriting of the input JS pre-typechecking. User-visible results include:
  • Names in error messages match the original JS better
  • The compiler is stricter about requiring namespaces to be const object literals.

New in Closure Compiler 20190301 (Mar 6, 2019)

  • No longer artificially require ES6 externs when transpiling down to ES5.
  • If type checking and transpilation are both on and standard externs are missing, it's possible to see some type warnings from internal runtime library code.
  • The --allow_method_call_decomposing flag has been removed as the functionality is always enabled.
  • Fixed a bug with printing of spaces in template literals.
  • Changed the API of Result.errors and Result.warnings from JSError[] to ImmutableList<JSError>.
  • Simplified the API for CodingConvention.AssertionFunctionSpec
  • Compiler will no longer skip passes that don't understand newer features in the source code that aren't being transpiled away. Instead it will halt with an error message.
  • ECMASCRIPT_2019 is now available for use as --language_in. See features added at http://go/gh/tc39/proposals/blob/master/finished-proposals.md
  • Default --language_in is now equivalent to ECMASCRIPT_2018.
  • ECMASCRIPT6, ECMASCRIPT_2016, and ECMASCRIPT_2017 are now fully supported for --language_out. JSCompiler team has confirmed that resulting output is no bigger than it would be for ECMASCRIPT5. Generally it is smaller.

New in Closure Compiler 20181028 (Nov 27, 2018)

  • Typechecking will now run for builds with --language_out=ECMASCRIPT_2015. Previously, typechecking was disabled for output level better than ES5.
  • Made name alias inlining more aggressive to fix some cases where property collapsing causes bad output
  • Change async transpilation to work around an MS Edge bug. https://github.com/google/closure-compiler/issues/3101
  • Fixed bug causing some properties aliasing global names to be set to null
  • Removed obsolete RemoveSuperMethods pass.
  • Improved type checking for destructured parameters and assignments.

New in Closure Compiler 20180716 (Aug 10, 2018)

  • Add a pom file for building a RefasterJs jar.
  • Type checker now knows that global let and const declarations do not add properties to the global object. To avoid a missing property error, you must use var foo if you want to later access window.foo.
  • Improvements to CommonJS rewriting support.
  • Improvements to the typechecking of several ES6 patterns, including rest/spread.
  • Forward references to types now preserve their type arguments.
  • The npm distribution now includes native binaries for MacOS and Linux. Native binaries offer faster compile times without requiring a JVM.

New in Closure Compiler 20180610 (Jun 22, 2018)

  • This release now contains the JS version of Closure Compiler inside the standard NPM package.
  • Consider @desc as @const
  • Remove special handling for @interface initialized to goog.abstractMethod
  • Fix inline type annotations of optional and var_args parameters.
  • Improve CommonJS UMD pattern detection.
  • Removed special handling for Error and subclasses: they will no longer be implicitly added if missing from (nonstandard) externs.
  • Typechecking and other checks now see untranspiled template literals, computed properties and object literal member functions.
  • Fixed bug where the compiler wasn't reporting duplicate destructured declarations.
  • Improved type inference for 'assign op's such as *=
  • Typechecking and other checks now see untranspiled for-of loops
  • Fixed incorrect code removal bug. The fix makes an optimization more conservative so may slightly increase code size.
  • Compiler preserves an input source map's sourcesContent in the output source map
  • Renamed code-splitting flags from "module" to "chunk". e.g. cross_module_code_motion -> cross_chunk_code_motion
  • Removed JSDoc parser support for "namespace types" (e.g. {jQuery.})
  • Overhauled type inference's data structures for tracking flow-sensitive types
  • Typechecking and other checks now see untranspiled let/const variables.
  • Fixed bug in for loop transpilation in generator functions
  • Fix scoping of catch variables during type inference.

New in Closure Compiler 20180506 (Jun 12, 2018)

  • Simplified transpilation of async functions for decreased code size
  • Fixed redeclared variable error for rest destructuring
  • Corrected handling of +0 and -0 in Map and Set polyfills
  • --new_type_inf is now a no-op flag. NTI has been turned down (consider strictCheckTypes as an alternative).
  • Removed the deprecated Text.prototype.replaceWholeText API
  • Fixed bug in code generator for arrow function bodies with object literals
  • Implemented string literal trim() folding
  • Updates to support for local (non-global) @typedef declarations
  • Updates to improved support for local (non-global) type declarations.
  • Modified handling of extern declarations such that a class' @implements are fulfilled implicitly rather than always requiring explicit redefinitions.
  • Improved type inference on callbacks without an explicit type declaration
  • Better error checking in generator functions. Type checking code now understands generators and sees them un-transpiled for all use cases.
  • Better error checking for let/const and for-of loops in --checksOnly mode only. Type checking code sees them as untranspiled.

New in Closure Compiler 20180402 (Apr 9, 2018)

  • Fixed flaky stack overflow problem in serialization code.
  • Corrected corner-case behavior of Array.prototype.includes polyfill.
  • Add a polyfill for Promise.prototype.finally.
  • Introduce "Global" as the type of the global object.
  • Compiler will now keep running compiler passes after hitting non-fatal errors (i.e. those that are not errors by default).
  • Misplaced @suppress warnings are now on by default.

New in Closure Compiler 20180204 (Feb 6, 2018)

  • Replace RemoveUnusedClassProperties and smartNameRemoval passes with new RemoveUnusedCode optimization pass.
  • Introduce "strictMissingProperties" that emits warnings when properties are referenced and can only be found on subtypes. These warnings can be suppressed with "missingProperties" or "strictMissingProperties" but are enabled with "strictMissingProperties".
  • Now allow @suppress JSDoc to be attached to any type of declaration (including let/const/class) instead of only functions/methods.
  • Add support for transpiling object rest and spread.
  • Removed obsolete optimization pass ChainCalls
  • Deleted the legacy option to optimize the property registry in OTI.
  • Block-scoped function declarations are now considered an ES6 feature and are treated as lexically scoped to the declaring block (per ES6 strict specification) and are no longer accessible elsewhere outside that block.
  • Fix polyfill bug where Math.hypot(0, 0) was returning NaN.
  • Add support for mutable exports and forbid duplicate exports in ES6 modules.
  • Misc bugfixes and improvements.

New in Closure Compiler 20180101 (Feb 6, 2018)

  • If you are using the inlineFunctions or inlineLocalFunctions boolean fields of the compiler options, you will have to migrate to the getter/setter methods setInlineFunctions(Reach) or getInlineFunctionsLevel() instead.
  • Experimental support for @noinline annotation. It will prevent inlining of symbols by the inlineVariables and inlineFunctions passes, but not other inlining passes.
  • Compiler.addToDebugLog is deprecated. If you have a custom pass that calls it, please switch to logging the information with a standard Java Logger.
  • Labeled function and class declarations are now a parse error. These are illegal in ES6 strict mode.
  • Made AggressiveInlineAliases more aggressive about inlining constructors to prevent decomposition from hiding references to static properties that CollapseProperties needs to replace.
  • Improved optimizations of modules in SIMPLE mode with wrapped output.
  • Fixed a bug that prevented property names defined in extern JSDoc from being recognized when type checking was disabled. This led to extern properties being renamed in some cases.
  • RemoveUnusedPrototypeProperties pass removed and its functionality merged into RemoveUnusedCode. This gives a performance boost by reducing redundant work.
  • ES6-output improvements:
  • RescopeGlobalSymbols now supported
  • ReplaceIdGenerators now supported
  • ClosureCodeRemoval now supported
  • CrossModuleMethodMotion now supported

New in Closure Compiler 20171203 (Dec 6, 2017)

  • Fixed a bug that broke the JavaScript (GWT) version of the compiler (closure-compiler-js). That project and its npm have now been updated.
  • Fixed a bug causing incorrect code removal.
  • Several improvements to handling of and interoperation between CommonJS and ES6 modules.
  • ES6-output improvements:
  • J2CL passes now supported
  • CrossModuleCodeMotion now supported
  • name(Un)MappedAnonymousFunctions now supported
  • OptimizeCalls now supported

New in Closure Compiler 20171112 (Nov 16, 2017)

  • For projects invoking the compiler from Java code: Removed Compiler method reportCodeChange. Code that was using this should switch to reportChangeToChangeScope or reportChangeToEnclosingScope.
  • Improvements to optimization passes related to OptimizeCalls.

New in Closure Compiler 20171023 (Nov 16, 2017)

  • When using the compiler to manage dependencies, made the dependency ordering match that of ES6 modules. In particular, this means that dependencies are processed depth first in the order of the imports in the file, starting from the entry points. For more details, see https://github.com/google/closure-compiler/pull/2641
  • "use types for optimizations" no longer triggers optimizations of comparisons with null and undefined.

New in Closure Compiler 20170910 (Sep 14, 2017)

  • Improvements to performance of optimization passes.
  • Improved support for goog.modules with object literal exports style (e.g. exports = {Foo, Bar})
  • Disallow 'is' property in a Polymer behavior.
  • Continuing improvements to experimental ES6 output mode.

New in Closure Compiler 20170806 (Sep 14, 2017)

  • Several improvements to optimization of output modes > ES5. Type checking and optimizations that depend on that don't work yet, though.
  • CrossModuleCodeMotion now moves all symbols to the current best possible module in a single run of the pass, greatly reducing execution time for this pass. It also does a much better job of selecting the best module, leading to significant transitive module size improvement.
  • ES6 static method inheritance improved where possible. ES6 classes are supposed to inherit static methods by prototype inheritance between the 2 constructor functions. This is now implemented for all browsers that can support it, falling back to copying properties on those that don't.
  • ECMASCRIPT_2017 is now the default language mode.
  • The .throw() method for a generator now works correctly when its argument is undefined. Previously it behaved as if .next() had been called. This also fixed a bug with async functions that caused promises rejected with undefined to be treated as if they were completed successfully.
  • The output language defaults to ES5 instead of to the input language.
  • Promoted a couple of useful diagnostics to their own diagnostic group:
  • jsdocMissingType: Uses of @param/@return without a type (was lint-only).
  • unnecessaryEscape: Backslashes in string literals that are ignored (was lint-only).
  • misplacedMsgAnnotation: Warnings about misplaced @desc/@hidden/@meaning JSDoc annotations (was only available as part of misplacedTypeAnnotation).

New in Closure Compiler 20170626 (Sep 14, 2017)

  • --language_out now allows ES2015 and higher. Passes which don't yet know how to handle ES2015 (including typechecking, and most optimization passes) will be skipped, so this is not recommended for production builds.
  • Several passes updated to work with ES2015+ code.
  • Read access to super class properties via super.someProperty is now allowed.
  • Fixed a bug that broke access to this within an async arrow function nested in another async function.
  • Changed the default ES6 module resolution mode to match that used in browsers.
  • Tools that call the compiler via its Java API and provide their own PassConfig may need to include a featureSet() method in each PassFactory.
  • CrossModuleCodeMotion now always picks the module with the smallest number of dependents when moving definitions. This will reduce the amount of code that must be loaded for some modules.
  • Now ES6 language mode defaults to strict mode. If you don't want strict mode checks, use the --strict_mode_input=false flag.
  • Allow --strict_mode_input flag to work in all language modes, including ES3.

New in Closure Compiler 20170521 (May 24, 2017)

  • Fixed a bug that caused the polyfill versions of Promise.all() and Promise.race() to be renamed when disambiguate properties was enabled.
  • Fixed a bug in CrossModuleCodeMotion that caused some global variable definitions to become pinned to a module, when they should be allowed to move.
  • Allow --emit_use_strict flag to work in all language modes, including ES3.
  • NTI: handle record/interface properties declared on THIS inside the constructor.
  • Make Reflect.construct polyfill compatible with ES3.
  • New BANNED_NAME_CALL conformance check

New in Closure Compiler 20170423 (May 24, 2017)

  • In RescopeGlobalSymbols, handle the case where a variable is defined both in the externs and in the source.
  • Symbol polyfill uses quoted properties to access members of $jscomp.global.
  • NTI: improve typing of .call/.apply on methods of generic classes.
  • Support compilation of programs with missing definitions.
  • Absolute path imports now resolve when combined with --js_module_root flags.

New in Closure Compiler 20170409 (Apr 26, 2017)

  • Added diagnostic group tooManyTypeParams to check for invalid templatized types such as Array<string, number>.
  • Use a size heuristic to stop the optimizations early when they are not making enough changes. Improves compile time by about 10%.
  • Added BanCreateDom conformance check.
  • Fixed a bug preventing definition of @record properties in the constructor when collapse properties is enabled.
  • Bugfix related to unions of unresolved types in the old type checker.
  • NTI: improve type checking of unannotated callbacks.
  • NTI: handle .call and .apply during @const inference.
  • The call to goog.module() must be the first statement in a goog.module. For instance, if you had goog.setTestOnly() before goog.module() the order must be reversed.
  • Check for temporal dead zone violation in for (let x of [x]);
  • Don't warn when an alias inside a goog.module is only used in type annotations.
  • Performance improvements to the new type inference and to InlineSimpleMethods.

New in Closure Compiler 20170218 (Feb 24, 2017)

  • --polymer_pass flag is deprecated in anticipation of Polymer 2 support. Use --polymer_version=1 instead.
  • Add a --module_resolution flag to specify which algorithm the compiler should use to lookup modules. The flag has 3 options:
  • LEGACY (default) - the same behavior the compiler has used historically. Users are recommended to begin migrating away from this behavior.
  • NODE - uses the node module resolution algorithm.
  • BROWSER - mimics the behavior of native module loading in browsers (browser support for this is close, but not yet generally available). The behavior of this mode will be adjusted to match the behavior of browsers as they release.

New in Closure Compiler 20170124 (Feb 24, 2017)

  • Improved optimization of modules with named exports.
  • Several small improvements to compile-time performance.
  • Add a check that super() is called before accessing this.
  • Make type-based optimizations safer about null/undefined.
  • Improved handling of parameterized object types in NTI (Object).
  • In NTI, allow any IArrayLike to be used with .apply function calls.

New in Closure Compiler 20161201 (Feb 24, 2017)

  • New type inference supports @abstract.
  • CommonJS modules now use the node module resolution algorithm and support using JSON files as module source.
  • Bugfixes in DisambiguateProperties for interface inheritance and implicit use of interfaces.

New in Closure Compiler 20161024 (Dec 5, 2016)

  • Polyfills for Promises.
  • Support for async/await by transpiling to generators.
  • Improvements to CommonJS module rewriting.
  • New flag for strict-mode output: --emit_use_strict.
  • Duplicate keys in an object literal are always an error, even if strict mode is not explicitly enabled.

New in Closure Compiler 20160911 (Oct 24, 2016)

  • Various compile time performance improvements to the optimization passes
  • Allow applying input source maps to the generated source map
  • Better support/fixes for @abstract classes and methods
  • Add externs for jQuery 1.12 & 2.2
  • Add Boolean.prototype.valueOf to externs
  • Externs for Google Maps API 3.26

New in Closure Compiler 20160822 (Aug 24, 2016)

  • [maven-release-plugin] copy for tag closure-compiler-parent-v20160822
  • …!isEmpty() yet peek() can return null.

New in Closure Compiler 20160713 (Jul 15, 2016)

  • Internal change to the way the AST is represented, which results in much faster compilation, especially for projects with large files.
  • The jar downloaded from dl.google.com now includes the version number in its filename (closure-compiler-v20160713.jar)

New in Closure Compiler 20160619 (Jun 23, 2016)

  • A class can have side effects if the expression in the []'s for a computed property has side effects.

New in Closure Compiler 20160315 (Mar 26, 2016)

  • Improved code removal of Object.defineProperties calls
  • Compiler support for goog.reflect.cache, which allows functions with internal caches to be considered side-effect free for optimizations.
  • Linter now finds missing/extra ES6 import statements.
  • The inferredConstCheck diagnostic group is a no-op. Use the com.google.javascript.jscomp.ConformanceRules$InferredConstCheck conformance check instead.
  • The new type inference handles IObject/IArrayLike.
  • Run FlowSensitiveInlineVariables before function inlining to improve code size.
  • Allow entry points that don't provide any symbols (like ES6 or CommonJS)
  • CommonJS module rewriting is now only triggered by the presensce of an export. Previously require calls also triggered a rewrite.
  • New lint checks:
  • Duplicate case statements in a switch
  • Check for the for (!x in obj) pattern, which is usually a mistake
  • Check for missing @return JSDoc

New in Closure Compiler 20160208 (Feb 9, 2016)

  • Improve the description of the RewritePolyfills class.

New in Closure Compiler 20151216 (Jan 28, 2016)

  • Allow input and output as JSON streams to support the gulp and grunt workflows.
  • Compiler web service and CommandLineRunner now default to transpiling from ES6-ES3 (instead of assuming input is ES3)
  • Pretty print record types in error messages to make it easier to find the source of type mismatches
  • HEURISTIC renaming has been removed
  • Don't warn if the root of a namespace is defined twice in the externs
  • Some optimization passes now understand Object.defineProperties

New in Closure Compiler 20151015 (Jan 28, 2016)

  • ECMAScript 6 is officially supported
  • CollapseProperties will now collapse in more cases, possibly resulting in fewer warnings and smaller code size
  • Destructuring is supported for goog.require()s in ES6 modules
  • struct is now supported for @interface and @record declarations in the "old" type inference (The NTI has this behavior by default). goog.defineClass @interfaces are @struct by default (like @constructor)
  • "unknown property" conformance check now checks @interface and @record types
  • Improved performance for parsing arrays, objects, and parenthesized expressions
  • Typechecking improvements affecting module code
  • Inline type annotations on function parameters with @type will now be respected

New in Closure Compiler 20150920 (Jan 28, 2016)

  • Better support for IArrayLike, which checks usages of []
  • Improved handling for arguments array
  • Support structural typing for interfaces with @record

New in Closure Compiler 20150901 (Jan 28, 2016)

  • Support for different externs sets via the --env flag
  • env=CUSTOM replaces the --use_only_custom_externs flag
  • Core language externs are always loaded - even for custom environments
  • Improved handling of type aliases, including types exported across modules
  • Use ES6 module ordering when in ES6 mode
  • Remove checkStructDictInheritance diagnostic group (it no longer did anything)

New in Closure Compiler 20150729 (Jan 28, 2016)

  • Aggressive variable checks are now on by default, and the setAggressiveVarCheck flag has become a no-op
  • Duplicate license comments will be omitted in the output
  • Stringifiable object keys check is on by default
  • Removed double-bar syntax (||) for declaring unions in type annotations
  • Removed --accept_const_keyword flag. Use --language_in=ES6_STRICT instead
  • jscomp_(warning|error|off) flags now accept the '*' char as a wildcard