Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/ngtsc/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class NgtscProgram implements api.Program {
if (fileName.endsWith('.d.ts')) {
data = sourceFiles.reduce(
(data, sf) => this.compilation !.transformedDtsFor(sf.fileName, data), data);
} else if (this.closureCompilerEnabled && fileName.endsWith('.ts')) {
} else if (this.closureCompilerEnabled && fileName.endsWith('.js')) {
data = nocollapseHack(data);
}
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
Expand Down
21 changes: 21 additions & 0 deletions packages/compiler-cli/test/ngtsc/ngtsc_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,27 @@ describe('ngtsc behavioral tests', () => {
expect(jsContents).toContain('Hello World');
});

it('should add @nocollapse to static fields when closure annotations are requested', () => {
env.tsconfig({
'annotateForClosureCompiler': true,
});
env.write('test.ts', `
import {Component} from '@angular/core';

@Component({
selector: 'test-cmp',
templateUrl: './dir/test.html',
})
export class TestCmp {}
`);
env.write('dir/test.html', '<p>Hello World</p>');

env.driveMain();

const jsContents = env.getContents('test.js');
expect(jsContents).toContain('/** @nocollapse */ TestCmp.ngComponentDef');
});

it('should compile Components with a templateUrl in a different rootDir', () => {
env.tsconfig({}, ['./extraRootDir']);
env.write('extraRootDir/test.html', '<p>Hello World</p>');
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/change_detection/change_detector_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export abstract class ChangeDetectorRef {
abstract reattach(): void;

/** @internal */
/** @nocollapse */
static __NG_ELEMENT_ID__: () => ChangeDetectorRef = () => SWITCH_CHANGE_DETECTOR_REF_FACTORY();
}

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/di/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export abstract class Injector {
});

/** @internal */
/** @nocollapse */
static __NG_ELEMENT_ID__: () => Injector = () => SWITCH_INJECTOR_FACTORY();
}

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/linker/element_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class ElementRef<T = any> {
constructor(nativeElement: T) { this.nativeElement = nativeElement; }

/** @internal */
/** @nocollapse */
static __NG_ELEMENT_ID__: () => ElementRef = () => SWITCH_ELEMENT_REF_FACTORY(ElementRef);
}

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/linker/template_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export abstract class TemplateRef<C> {
abstract createEmbeddedView(context: C): EmbeddedViewRef<C>;

/** @internal */
/** @nocollapse */
static __NG_ELEMENT_ID__:
() => TemplateRef<any>| null = () => SWITCH_TEMPLATE_REF_FACTORY(TemplateRef, ElementRef)
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/linker/view_container_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export abstract class ViewContainerRef {
abstract detach(index?: number): ViewRef|null;

/** @internal */
/** @nocollapse */
static __NG_ELEMENT_ID__:
() => ViewContainerRef = () => SWITCH_VIEW_CONTAINER_REF_FACTORY(ViewContainerRef, ElementRef)
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/render/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export abstract class Renderer2 {
callback: (event: any) => boolean | void): () => void;

/** @internal */
/** @nocollapse */
static __NG_ELEMENT_ID__: () => Renderer2 = () => SWITCH_RENDERER2_FACTORY();
}

Expand Down