feat(compiler): Added "strictMetadataEmit" option to ngc (#10951)
ngc can now validate metadata before emitting to verify it doesn't contain an error symbol that will result in a runtime error if it is used by the StaticReflector. To enable this add the section, "angularCompilerOptions": { "strictMetadataEmit": true } to the top level of the tsconfig.json file passed to ngc. Enabled metadata validation for packages that are intended to be used statically.
This commit is contained in:
@ -27,5 +27,5 @@ export {WORKER_UI_LOCATION_PROVIDERS} from './src/web_workers/ui/location_provid
|
||||
|
||||
export {NgProbeToken} from './src/dom/debug/ng_probe';
|
||||
export * from './src/worker_render';
|
||||
export * from './src/worker_app';
|
||||
export {platformWorkerApp, WorkerAppModule} from './src/worker_app';
|
||||
export * from './private_export';
|
@ -21,7 +21,12 @@ import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_w
|
||||
import {WebWorkerRootRenderer} from './web_workers/worker/renderer';
|
||||
import {WorkerDomAdapter} from './web_workers/worker/worker_adapter';
|
||||
|
||||
class PrintLogger {
|
||||
/**
|
||||
* Logger for web workers.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export class PrintLogger {
|
||||
log = print;
|
||||
logError = print;
|
||||
logGroup = print;
|
||||
@ -33,7 +38,12 @@ class PrintLogger {
|
||||
*/
|
||||
export const platformWorkerApp = createPlatformFactory(platformCore, 'workerApp');
|
||||
|
||||
function _exceptionHandler(): ExceptionHandler {
|
||||
/**
|
||||
* Exception handler factory function.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export function exceptionHandler(): ExceptionHandler {
|
||||
return new ExceptionHandler(new PrintLogger());
|
||||
}
|
||||
|
||||
@ -44,7 +54,12 @@ let _postMessage = {
|
||||
}
|
||||
};
|
||||
|
||||
function createMessageBus(zone: NgZone): MessageBus {
|
||||
/**
|
||||
* MessageBus factory function.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export function createMessageBus(zone: NgZone): MessageBus {
|
||||
let sink = new PostMessageBusSink(_postMessage);
|
||||
let source = new PostMessageBusSource();
|
||||
let bus = new PostMessageBus(sink, source);
|
||||
@ -52,7 +67,12 @@ function createMessageBus(zone: NgZone): MessageBus {
|
||||
return bus;
|
||||
}
|
||||
|
||||
function setupWebWorker(): void {
|
||||
/**
|
||||
* Application initializer for web workers.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
export function setupWebWorker(): void {
|
||||
WorkerDomAdapter.makeCurrent();
|
||||
}
|
||||
|
||||
@ -68,7 +88,7 @@ function setupWebWorker(): void {
|
||||
{provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
||||
WebWorkerRootRenderer, {provide: RootRenderer, useExisting: WebWorkerRootRenderer},
|
||||
{provide: ON_WEB_WORKER, useValue: true}, RenderStore,
|
||||
{provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
|
||||
{provide: ExceptionHandler, useFactory: exceptionHandler, deps: []},
|
||||
{provide: MessageBus, useFactory: createMessageBus, deps: [NgZone]},
|
||||
{provide: APP_INITIALIZER, useValue: setupWebWorker, multi: true}
|
||||
],
|
||||
|
@ -13,17 +13,13 @@ import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {AnimationDriver} from '../src/dom/animation_driver';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
||||
|
||||
import {BrowserDetection} from './browser_util';
|
||||
import {BrowserDetection, createNgZone} from './browser_util';
|
||||
|
||||
function initBrowserTests() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
BrowserDetection.setup();
|
||||
}
|
||||
|
||||
function createNgZone(): NgZone {
|
||||
return new NgZone({enableLongStackTrace: true});
|
||||
}
|
||||
|
||||
const _TEST_BROWSER_PLATFORM_PROVIDERS: Provider[] =
|
||||
[{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}];
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgZone} from '@angular/core';
|
||||
import {getDOM} from '../src/dom/dom_adapter';
|
||||
import {ListWrapper} from '../src/facade/collection';
|
||||
import {RegExp, StringWrapper, global, isPresent, isString} from '../src/facade/lang';
|
||||
@ -129,3 +130,7 @@ export function stringifyElement(el: any /** TODO #9100 */): string {
|
||||
}
|
||||
|
||||
export var browserDetection: BrowserDetection = new BrowserDetection(null);
|
||||
|
||||
export function createNgZone(): NgZone {
|
||||
return new NgZone({enableLongStackTrace: true});
|
||||
}
|
||||
|
@ -29,5 +29,8 @@
|
||||
"../../../node_modules/@types/jasmine/index.d.ts",
|
||||
"../../../node_modules/@types/protractor/index.d.ts",
|
||||
"../../../node_modules/zone.js/dist/zone.js.d.ts"
|
||||
]
|
||||
],
|
||||
"angularCompilerOptions": {
|
||||
"strictMetadataEmit": true
|
||||
}
|
||||
}
|
||||
|
@ -30,5 +30,8 @@
|
||||
"../../../node_modules/@types/jasmine/index.d.ts",
|
||||
"../../../node_modules/@types/protractor/index.d.ts",
|
||||
"../../../node_modules/zone.js/dist/zone.js.d.ts"
|
||||
]
|
||||
],
|
||||
"angularCompilerOptions": {
|
||||
"strictMetadataEmit": true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user