diff --git a/aio/content/guide/aot-compiler.md b/aio/content/guide/aot-compiler.md index 4ee81ab438..c55dc24fd4 100644 --- a/aio/content/guide/aot-compiler.md +++ b/aio/content/guide/aot-compiler.md @@ -92,7 +92,7 @@ You can control your app compilation by providing template compiler options in t }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, - "preserveWhitespaces": false, + "preserveWhitespaces": true, ... } } @@ -234,9 +234,7 @@ done manually. ### *preserveWhitespaces* This option tells the compiler whether to remove blank text nodes from compiled templates. -This option is `true` by default. - -*Note*: It is recommended to set this explicitly to `false` as it emits smaller template factory modules and might be set to `false` by default in the future. +As of v6, this option is `false` by default, which results in smaller emitted template factory modules. ### *allowEmptyCodegenFiles* diff --git a/packages/bazel/src/ng_module.bzl b/packages/bazel/src/ng_module.bzl index 7f2c33b327..5041dccc49 100644 --- a/packages/bazel/src/ng_module.bzl +++ b/packages/bazel/src/ng_module.bzl @@ -91,8 +91,7 @@ def _ngc_tsconfig(ctx, files, srcs, **kwargs): "enableSummariesForJit": True, "fullTemplateTypeCheck": ctx.attr.type_check, # FIXME: wrong place to de-dupe - "expectedOut": depset([o.path for o in expected_outs]).to_list(), - "preserveWhitespaces": False, + "expectedOut": depset([o.path for o in expected_outs]).to_list() } }) diff --git a/packages/compiler-cli/src/transformers/api.ts b/packages/compiler-cli/src/transformers/api.ts index 6679592f0d..b428f8fe0f 100644 --- a/packages/compiler-cli/src/transformers/api.ts +++ b/packages/compiler-cli/src/transformers/api.ts @@ -148,8 +148,8 @@ export interface CompilerOptions extends ts.CompilerOptions { // How to handle missing messages i18nInMissingTranslations?: 'error'|'warning'|'ignore'; - // Whether to remove blank text nodes from compiled templates. It is `true` by default - // in Angular 5 and will be re-visited in Angular 6. + // Whether to remove blank text nodes from compiled templates. It is `false` by default starting + // from Angular 6. preserveWhitespaces?: boolean; /** generate all possible generated files */ diff --git a/packages/compiler/src/config.ts b/packages/compiler/src/config.ts index 0826e3c1ab..eb0e7cddc7 100644 --- a/packages/compiler/src/config.ts +++ b/packages/compiler/src/config.ts @@ -46,6 +46,6 @@ export class CompilerConfig { } export function preserveWhitespacesDefault( - preserveWhitespacesOption: boolean | null, defaultSetting = true): boolean { + preserveWhitespacesOption: boolean | null, defaultSetting = false): boolean { return preserveWhitespacesOption === null ? defaultSetting : preserveWhitespacesOption; } diff --git a/packages/compiler/test/config_spec.ts b/packages/compiler/test/config_spec.ts index 6d164afc63..459e80cf60 100644 --- a/packages/compiler/test/config_spec.ts +++ b/packages/compiler/test/config_spec.ts @@ -7,7 +7,7 @@ */ import {MissingTranslationStrategy} from '@angular/core'; -import {CompilerConfig} from '../src/config'; +import {CompilerConfig, preserveWhitespacesDefault} from '../src/config'; { describe('compiler config', () => { @@ -16,4 +16,13 @@ import {CompilerConfig} from '../src/config'; expect(config.missingTranslation).toEqual(MissingTranslationStrategy.Error); }); }); + + describe('preserveWhitespacesDefault', () => { + it('should return the default `false` setting when no preserveWhitespacesOption are provided', + () => { expect(preserveWhitespacesDefault(null)).toEqual(false); }); + it('should return the preserveWhitespacesOption when provided as a parameter', () => { + expect(preserveWhitespacesDefault(true)).toEqual(true); + expect(preserveWhitespacesDefault(false)).toEqual(false); + }); + }); } diff --git a/packages/core/src/metadata/directives.ts b/packages/core/src/metadata/directives.ts index 25571fcb54..d503ad72be 100644 --- a/packages/core/src/metadata/directives.ts +++ b/packages/core/src/metadata/directives.ts @@ -693,13 +693,13 @@ export interface Component extends Directive { * - text nodes are left as-is inside HTML tags where whitespaces are significant (ex. `
`, * `