feat(ivy): JIT renders the TODO app (#24138)
This commit builds out enough of the JIT compiler to render //packages/core/test/bundling/todo, and allows the tests to run in JIT mode. To play with the app, run: bazel run --define=compile=jit //packages/core/test/bundling/todo:prodserver PR Close #24138
This commit is contained in:

committed by
Victor Berchet

parent
24e5c5b425
commit
646b42a113
@ -44,7 +44,7 @@ jasmine_node_test(
|
||||
data = [
|
||||
":bundle",
|
||||
":bundle.js",
|
||||
":bundle.min.js",
|
||||
":bundle.min.js.br",
|
||||
":bundle.min_debug.js",
|
||||
],
|
||||
tags = [
|
||||
|
@ -2072,9 +2072,6 @@
|
||||
{
|
||||
"name": "__extends$7"
|
||||
},
|
||||
{
|
||||
"name": "__global"
|
||||
},
|
||||
{
|
||||
"name": "__read"
|
||||
},
|
||||
|
@ -27,6 +27,7 @@ ng_rollup_bundle(
|
||||
entry_point = "packages/core/test/bundling/todo/index.js",
|
||||
deps = [
|
||||
":todo",
|
||||
"//packages/common",
|
||||
"//packages/core",
|
||||
],
|
||||
)
|
||||
@ -50,6 +51,7 @@ jasmine_node_test(
|
||||
":bundle.min.js",
|
||||
":bundle.min_debug.js",
|
||||
],
|
||||
tags = ["ivy-jit"],
|
||||
deps = [":test_lib"],
|
||||
)
|
||||
|
||||
|
@ -119,9 +119,6 @@
|
||||
{
|
||||
"name": "__extends"
|
||||
},
|
||||
{
|
||||
"name": "__global"
|
||||
},
|
||||
{
|
||||
"name": "__read"
|
||||
},
|
||||
|
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import 'reflect-metadata';
|
||||
|
||||
import {CommonModule, NgForOf, NgIf} from '@angular/common';
|
||||
import {Component, Injectable, IterableDiffers, NgModule, defineInjector, ɵNgOnChangesFeature as NgOnChangesFeature, ɵdefineDirective as defineDirective, ɵdirectiveInject as directiveInject, ɵinjectTemplateRef as injectTemplateRef, ɵinjectViewContainerRef as injectViewContainerRef, ɵrenderComponent as renderComponent} from '@angular/core';
|
||||
|
||||
@ -145,35 +147,39 @@ export class ToDoAppComponent {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(misko): This hack is here because common is not compiled with Ivy flag turned on.
|
||||
(CommonModule as any).ngInjectorDef = defineInjector({factory: () => new CommonModule});
|
||||
// In JIT mode the @Directive decorators in //packages/common will compile the Ivy fields. When
|
||||
// running under --define=compile=legacy, //packages/common is not compiled with Ivy fields, so they
|
||||
// must be monkey-patched on.
|
||||
if (!(NgIf as any).ngDirectiveDef) {
|
||||
// TODO(misko): This hack is here because common is not compiled with Ivy flag turned on.
|
||||
(CommonModule as any).ngInjectorDef = defineInjector({factory: () => new CommonModule});
|
||||
|
||||
// TODO(misko): This hack is here because common is not compiled with Ivy flag turned on.
|
||||
(NgForOf as any).ngDirectiveDef = defineDirective({
|
||||
type: NgForOf,
|
||||
selectors: [['', 'ngFor', '', 'ngForOf', '']],
|
||||
factory: () => new NgForOf(
|
||||
injectViewContainerRef(), injectTemplateRef(), directiveInject(IterableDiffers)),
|
||||
features: [NgOnChangesFeature({
|
||||
ngForOf: 'ngForOf',
|
||||
ngForTrackBy: 'ngForTrackBy',
|
||||
ngForTemplate: 'ngForTemplate',
|
||||
})],
|
||||
inputs: {
|
||||
ngForOf: 'ngForOf',
|
||||
ngForTrackBy: 'ngForTrackBy',
|
||||
ngForTemplate: 'ngForTemplate',
|
||||
}
|
||||
});
|
||||
|
||||
// TODO(misko): This hack is here because common is not compiled with Ivy flag turned on.
|
||||
(NgIf as any).ngDirectiveDef = defineDirective({
|
||||
type: NgIf,
|
||||
selectors: [['', 'ngIf', '']],
|
||||
factory: () => new NgIf(injectViewContainerRef(), injectTemplateRef()),
|
||||
inputs: {ngIf: 'ngIf', ngIfThen: 'ngIfThen', ngIfElse: 'ngIfElse'}
|
||||
});
|
||||
// TODO(misko): This hack is here because common is not compiled with Ivy flag turned on.
|
||||
(NgForOf as any).ngDirectiveDef = defineDirective({
|
||||
type: NgForOf,
|
||||
selectors: [['', 'ngFor', '', 'ngForOf', '']],
|
||||
factory: () => new NgForOf(
|
||||
injectViewContainerRef(), injectTemplateRef(), directiveInject(IterableDiffers)),
|
||||
features: [NgOnChangesFeature({
|
||||
ngForOf: 'ngForOf',
|
||||
ngForTrackBy: 'ngForTrackBy',
|
||||
ngForTemplate: 'ngForTemplate',
|
||||
})],
|
||||
inputs: {
|
||||
ngForOf: 'ngForOf',
|
||||
ngForTrackBy: 'ngForTrackBy',
|
||||
ngForTemplate: 'ngForTemplate',
|
||||
}
|
||||
});
|
||||
|
||||
// TODO(misko): This hack is here because common is not compiled with Ivy flag turned on.
|
||||
(NgIf as any).ngDirectiveDef = defineDirective({
|
||||
type: NgIf,
|
||||
selectors: [['', 'ngIf', '']],
|
||||
factory: () => new NgIf(injectViewContainerRef(), injectTemplateRef()),
|
||||
inputs: {ngIf: 'ngIf', ngIfThen: 'ngIfThen', ngIfElse: 'ngIfElse'}
|
||||
});
|
||||
}
|
||||
|
||||
@NgModule({declarations: [ToDoAppComponent, ToDoAppComponent], imports: [CommonModule]})
|
||||
export class ToDoAppModule {
|
||||
|
Reference in New Issue
Block a user