Angular Build Optimizer contains Angular optimizations applicable to Java\+Script code as a Type\+Script transform pipeline.\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md908}{}\doxysection{Available optimizations}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md908}
Transformations applied depend on file content\+:


\begin{DoxyItemize}
\item \href{\#class-fold}{\texttt{ Class fold}}, \href{\#scrub-file}{\texttt{ Scrub file}} and \href{\#prefix-functions}{\texttt{ Prefix functions}}\+: applied to Angular apps and libraries.
\item \href{\#import-tslib}{\texttt{ Import tslib}}\+: applied when Type\+Script helpers are found.
\end{DoxyItemize}

Some of these optimizations add {\ttfamily /$\ast$@\+\_\+\+\_\+\+PURE\+\_\+\+\_\+$\ast$/} comments. These are used by JS optimization tools to identify pure functions that can potentially be dropped.\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md909}{}\doxysubsection{Class fold}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md909}
Static properties are folded into ES5 classes\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{// input}
\DoxyCodeLine{var Clazz = (function () \{ function Clazz() \{ \} return Clazz; \}());}
\DoxyCodeLine{Clazz.prop = 1;}
\DoxyCodeLine{}
\DoxyCodeLine{// output}
\DoxyCodeLine{var Clazz = (function () \{ function Clazz() \{ \} Clazz.prop = 1; return Clazz; \}()); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md910}{}\doxysubsection{Scrub file}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md910}
Angular decorators, property decorators and constructor parameters are removed, while leaving non-\/\+Angular ones intact.


\begin{DoxyCode}{0}
\DoxyCodeLine{// input}
\DoxyCodeLine{import \{ Injectable, Input, Component \} from '@angular/core';}
\DoxyCodeLine{import \{ NotInjectable, NotComponent, NotInput \} from 'another-\/lib';}
\DoxyCodeLine{var Clazz = (function () \{ function Clazz() \{ \} return Clazz; \}());}
\DoxyCodeLine{Clazz.decorators = [\{ type: Injectable \}, \{ type: NotInjectable \}];}
\DoxyCodeLine{Clazz.propDecorators = \{ 'ngIf': [\{ type: Input \}] \};}
\DoxyCodeLine{Clazz.ctorParameters = function () \{ return [\{type: Injector\}]; \};}
\DoxyCodeLine{var ComponentClazz = (function () \{}
\DoxyCodeLine{  function ComponentClazz() \{ \}}
\DoxyCodeLine{  \_\_decorate([}
\DoxyCodeLine{    Input(),}
\DoxyCodeLine{    \_\_metadata("{}design:type"{}, Object)}
\DoxyCodeLine{  ], Clazz.prototype, "{}selected"{}, void 0);}
\DoxyCodeLine{  \_\_decorate([}
\DoxyCodeLine{    NotInput(),}
\DoxyCodeLine{    \_\_metadata("{}design:type"{}, Object)}
\DoxyCodeLine{  ], Clazz.prototype, "{}notSelected"{}, void 0);}
\DoxyCodeLine{  ComponentClazz = \_\_decorate([}
\DoxyCodeLine{    NotComponent(),}
\DoxyCodeLine{    Component(\{}
\DoxyCodeLine{        selector: 'app-\/root',}
\DoxyCodeLine{        templateUrl: './app.component.html',}
\DoxyCodeLine{        styleUrls: ['./app.component.css']}
\DoxyCodeLine{    \})}
\DoxyCodeLine{  ], ComponentClazz);}
\DoxyCodeLine{  return ComponentClazz;}
\DoxyCodeLine{\}());}
\DoxyCodeLine{}
\DoxyCodeLine{// output}
\DoxyCodeLine{import \{ Injectable, Input, Component \} from '@angular/core';}
\DoxyCodeLine{import \{ NotInjectable, NotComponent \} from 'another-\/lib';}
\DoxyCodeLine{var Clazz = (function () \{ function Clazz() \{ \} return Clazz; \}());}
\DoxyCodeLine{Clazz.decorators = [\{ type: NotInjectable \}];}
\DoxyCodeLine{var ComponentClazz = (function () \{}
\DoxyCodeLine{  function ComponentClazz() \{ \}}
\DoxyCodeLine{  \_\_decorate([}
\DoxyCodeLine{    NotInput(),}
\DoxyCodeLine{    \_\_metadata("{}design:type"{}, Object)}
\DoxyCodeLine{  ], Clazz.prototype, "{}notSelected"{}, void 0);}
\DoxyCodeLine{  ComponentClazz = \_\_decorate([}
\DoxyCodeLine{    NotComponent()}
\DoxyCodeLine{  ], ComponentClazz);}
\DoxyCodeLine{  return ComponentClazz;}
\DoxyCodeLine{\}()); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md911}{}\doxysubsection{Prefix functions}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md911}
Adds {\ttfamily /$\ast$@\+\_\+\+\_\+\+PURE\+\_\+\+\_\+$\ast$/} comments to top level downleveled class declarations and instantiation.

Warning\+: this transform assumes the file is a pure module. It should not be used with unpure modules.


\begin{DoxyCode}{0}
\DoxyCodeLine{// input}
\DoxyCodeLine{var Clazz = (function () \{ function Clazz() \{ \} return Clazz; \}());}
\DoxyCodeLine{var newClazz = new Clazz();}
\DoxyCodeLine{var newClazzTwo = Clazz();}
\DoxyCodeLine{}
\DoxyCodeLine{// output}
\DoxyCodeLine{var Clazz = /*@\_\_PURE\_\_*/ (function () \{ function Clazz() \{ \} return Clazz; \}());}
\DoxyCodeLine{var newClazz = /*@\_\_PURE\_\_*/ new Clazz();}
\DoxyCodeLine{var newClazzTwo = /*@\_\_PURE\_\_*/ Clazz(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md912}{}\doxysubsection{Prefix Classes}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md912}
Adds {\ttfamily /$\ast$@\+\_\+\+\_\+\+PURE\+\_\+\+\_\+$\ast$/} to downleveled Type\+Script classes.


\begin{DoxyCode}{0}
\DoxyCodeLine{// input}
\DoxyCodeLine{var ReplayEvent = (function () \{}
\DoxyCodeLine{    function ReplayEvent(time, value) \{}
\DoxyCodeLine{        this.time = time;}
\DoxyCodeLine{        this.value = value;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    return ReplayEvent;}
\DoxyCodeLine{\}());}
\DoxyCodeLine{}
\DoxyCodeLine{// output}
\DoxyCodeLine{var ReplayEvent = /*@\_\_PURE\_\_*/ (function () \{}
\DoxyCodeLine{    function ReplayEvent(time, value) \{}
\DoxyCodeLine{        this.time = time;}
\DoxyCodeLine{        this.value = value;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    return ReplayEvent;}
\DoxyCodeLine{\}()); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md913}{}\doxysubsection{Import tslib}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md913}
Type\+Script helpers ({\ttfamily \+\_\+\+\_\+extends/\+\_\+\+\_\+decorate/\+\_\+\+\_\+metadata/\+\_\+\+\_\+param}) are replaced with {\ttfamily tslib} imports whenever found.


\begin{DoxyCode}{0}
\DoxyCodeLine{// input}
\DoxyCodeLine{var \_\_extends = (this \&\& this.\_\_extends) || function (d, b) \{}
\DoxyCodeLine{  for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];}
\DoxyCodeLine{  function \_\_() \{ this.constructor = d; \}}
\DoxyCodeLine{  d.prototype = b === null ? Object.create(b) : (\_\_.prototype = b.prototype, new \_\_());}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{// output}
\DoxyCodeLine{import \{ \_\_extends \} from "{}tslib"{}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md914}{}\doxysubsection{Wrap enums}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md914}
Wrap downleveled Type\+Script enums in a function, and adds {\ttfamily /$\ast$@\+\_\+\+\_\+\+PURE\+\_\+\+\_\+$\ast$/} comment.


\begin{DoxyCode}{0}
\DoxyCodeLine{// input}
\DoxyCodeLine{var ChangeDetectionStrategy;}
\DoxyCodeLine{(function (ChangeDetectionStrategy) \{}
\DoxyCodeLine{    ChangeDetectionStrategy[ChangeDetectionStrategy["{}OnPush"{}] = 0] = "{}OnPush"{};}
\DoxyCodeLine{    ChangeDetectionStrategy[ChangeDetectionStrategy["{}Default"{}] = 1] = "{}Default"{};}
\DoxyCodeLine{\})(ChangeDetectionStrategy || (ChangeDetectionStrategy = \{\}));}
\DoxyCodeLine{}
\DoxyCodeLine{// output}
\DoxyCodeLine{var ChangeDetectionStrategy = /*@\_\_PURE\_\_*/ (function () \{}
\DoxyCodeLine{  var ChangeDetectionStrategy = \{\};}
\DoxyCodeLine{  ChangeDetectionStrategy[ChangeDetectionStrategy["{}OnPush"{}] = 0] = "{}OnPush"{};}
\DoxyCodeLine{  ChangeDetectionStrategy[ChangeDetectionStrategy["{}Default"{}] = 1] = "{}Default"{};}
\DoxyCodeLine{  return ChangeDetectionStrategy;}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md915}{}\doxysection{Library Usage}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md915}

\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ buildOptimizer \} from '@angular-\/devkit/build-\/optimizer';}
\DoxyCodeLine{}
\DoxyCodeLine{const transpiledContent = buildOptimizer(\{ content: input \}).content; }

\end{DoxyCode}


Available options\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{export interface BuildOptimizerOptions \{}
\DoxyCodeLine{  content?: string;}
\DoxyCodeLine{  inputFilePath?: string;}
\DoxyCodeLine{  outputFilePath?: string;}
\DoxyCodeLine{  emitSourceMap?: boolean;}
\DoxyCodeLine{  strict?: boolean;}
\DoxyCodeLine{  isSideEffectFree?: boolean;}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md916}{}\doxysection{Webpack loader usage\+:}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md916}

\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ BuildOptimizerWebpackPlugin \} from '@angular-\/devkit/build-\/optimizer';}
\DoxyCodeLine{}
\DoxyCodeLine{module.exports = \{}
\DoxyCodeLine{  plugins: [}
\DoxyCodeLine{    new BuildOptimizerWebpackPlugin(),}
\DoxyCodeLine{  ]}
\DoxyCodeLine{  module: \{}
\DoxyCodeLine{    rules: [}
\DoxyCodeLine{      \{}
\DoxyCodeLine{        test: /\(\backslash\).js\$/,}
\DoxyCodeLine{        loader: '@angular-\/devkit/build-\/optimizer/webpack-\/loader',}
\DoxyCodeLine{        options: \{}
\DoxyCodeLine{          sourceMap: false}
\DoxyCodeLine{        \}}
\DoxyCodeLine{      \}}
\DoxyCodeLine{    ]}
\DoxyCodeLine{  \}}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md917}{}\doxysection{CLI usage}\label{md_sfcode_node_modules__angular_devkit_build_optimizer_README_autotoc_md917}

\begin{DoxyCode}{0}
\DoxyCodeLine{build-\/optimizer input.js}
\DoxyCodeLine{build-\/optimizer input.js output.js }

\end{DoxyCode}
 