Skip to content

Commit

Permalink
refactor: remove old compiler options (angular#14891)
Browse files Browse the repository at this point in the history
DEPRECATION:
- `CompilerOptions.debug` has no effect any more, as the compiler
  always produces the same code independent of debug mode.
  • Loading branch information
tbosch authored and chuckjaz committed Mar 7, 2017
1 parent 07122f0 commit 1cff125
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 41 deletions.
1 change: 0 additions & 1 deletion modules/@angular/compiler-cli/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class CodeGenerator {
transContent = readFileSync(transFile, 'utf8');
}
const {compiler: aotCompiler} = compiler.createAotCompiler(ngCompilerHost, {
debug: options.debug === true,
translations: transContent,
i18nFormat: cliOptions.i18nFormat,
locale: cliOptions.locale,
Expand Down
2 changes: 0 additions & 2 deletions modules/@angular/compiler/src/aot/compiler_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ export function createAotCompiler(compilerHost: AotCompilerHost, options: AotCom
new HtmlParser(), translations, options.i18nFormat, MissingTranslationStrategy.Warning,
console);
const config = new CompilerConfig({
genDebugInfo: options.debug === true,
defaultEncapsulation: ViewEncapsulation.Emulated,
logBindingUpdate: false,
useJit: false,
enableLegacyTemplate: options.enableLegacyTemplate !== false,
});
Expand Down
1 change: 0 additions & 1 deletion modules/@angular/compiler/src/aot/compiler_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

export interface AotCompilerOptions {
debug?: boolean;
locale?: string;
i18nFormat?: string;
translations?: string;
Expand Down
18 changes: 2 additions & 16 deletions modules/@angular/compiler/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,17 @@ export class CompilerConfig {
public useJit: boolean;
public missingTranslation: MissingTranslationStrategy;

private _genDebugInfo: boolean;
private _logBindingUpdate: boolean;

constructor(
{defaultEncapsulation = ViewEncapsulation.Emulated, genDebugInfo, logBindingUpdate,
useJit = true, missingTranslation, enableLegacyTemplate}: {
{defaultEncapsulation = ViewEncapsulation.Emulated, useJit = true, missingTranslation,
enableLegacyTemplate}: {
defaultEncapsulation?: ViewEncapsulation,
genDebugInfo?: boolean,
logBindingUpdate?: boolean,
useJit?: boolean,
missingTranslation?: MissingTranslationStrategy,
enableLegacyTemplate?: boolean,
} = {}) {
this.defaultEncapsulation = defaultEncapsulation;
this._genDebugInfo = genDebugInfo;
this._logBindingUpdate = logBindingUpdate;
this.useJit = useJit;
this.missingTranslation = missingTranslation;
this.enableLegacyTemplate = enableLegacyTemplate !== false;
}

get genDebugInfo(): boolean {
return this._genDebugInfo === void 0 ? isDevMode() : this._genDebugInfo;
}
get logBindingUpdate(): boolean {
return this._logBindingUpdate === void 0 ? isDevMode() : this._logBindingUpdate;
}
}
8 changes: 2 additions & 6 deletions modules/@angular/compiler/src/i18n/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,8 @@ export class Extractor {
const staticReflector = new StaticReflector(staticSymbolResolver);
StaticAndDynamicReflectionCapabilities.install(staticReflector);

const config = new CompilerConfig({
genDebugInfo: false,
defaultEncapsulation: ViewEncapsulation.Emulated,
logBindingUpdate: false,
useJit: false
});
const config =
new CompilerConfig({defaultEncapsulation: ViewEncapsulation.Emulated, useJit: false});

const normalizer = new DirectiveNormalizer(
{get: (url: string) => host.loadResource(url)}, urlResolver, htmlParser, config);
Expand Down
5 changes: 0 additions & 5 deletions modules/@angular/compiler/src/jit/compiler_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,12 @@ export class JitCompilerFactory implements CompilerFactory {
provide: CompilerConfig,
useFactory: () => {
return new CompilerConfig({
// let explicit values from the compiler options overwrite options
// from the app providers. E.g. important for the testing platform.
genDebugInfo: opts.useDebug,
// let explicit values from the compiler options overwrite options
// from the app providers
useJit: opts.useJit,
// let explicit values from the compiler options overwrite options
// from the app providers
defaultEncapsulation: opts.defaultEncapsulation,
logBindingUpdate: opts.useDebug,
missingTranslation: opts.missingTranslation,
enableLegacyTemplate: opts.enableLegacyTemplate,
});
Expand Down Expand Up @@ -150,7 +146,6 @@ export const platformCoreDynamic = createPlatformFactory(platformCore, 'coreDyna

function _mergeOptions(optionsArr: CompilerOptions[]): CompilerOptions {
return {
useDebug: _lastDefined(optionsArr.map(options => options.useDebug)),
useJit: _lastDefined(optionsArr.map(options => options.useJit)),
defaultEncapsulation: _lastDefined(optionsArr.map(options => options.defaultEncapsulation)),
providers: _mergeArrays(optionsArr.map(options => options.providers)),
Expand Down
3 changes: 3 additions & 0 deletions modules/@angular/core/src/linker/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export class Compiler {
* @experimental
*/
export type CompilerOptions = {
/**
* @deprecated since v4 this option has no effect anymore.
*/
useDebug?: boolean,
useJit?: boolean,
defaultEncapsulation?: ViewEncapsulation,
Expand Down
11 changes: 3 additions & 8 deletions modules/@angular/language-service/src/typescript_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,9 @@ export class TypeScriptServiceHost implements LanguageServiceHost {
const urlResolver = createOfflineCompileUrlResolver();
const htmlParser = new DummyHtmlParser();
// This tracks the CompileConfig in codegen.ts. Currently these options
// are hard-coded except for genDebugInfo which is not applicable as we
// never generate code.
const config = new CompilerConfig({
genDebugInfo: false,
defaultEncapsulation: ViewEncapsulation.Emulated,
logBindingUpdate: false,
useJit: false
});
// are hard-coded.
const config =
new CompilerConfig({defaultEncapsulation: ViewEncapsulation.Emulated, useJit: false});
const directiveNormalizer =
new DirectiveNormalizer(resourceLoader, urlResolver, htmlParser, config);

Expand Down
2 changes: 1 addition & 1 deletion tools/@angular/tsc-wrapped/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ interface Options extends ts.CompilerOptions {
// Print extra information while running the compiler
trace?: boolean;

// Whether to embed debug information in the compiled templates
/** @deprecated since v4 this option has no effect anymore. */
debug?: boolean;

// Whether to enable support for <template> and the template attribute (true by default)
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/core/typings/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export declare abstract class CompilerFactory {

/** @experimental */
export declare type CompilerOptions = {
useDebug?: boolean;
/** @deprecated */ useDebug?: boolean;
useJit?: boolean;
defaultEncapsulation?: ViewEncapsulation;
providers?: any[];
Expand Down

0 comments on commit 1cff125

Please sign in to comment.