test(ivy): move hello_world and todo fully to ngtsc (#24677)

ngtsc is sufficiently capable now that it can compile hello_world
and todo and achieve equivalent results to ngc in ivy (global) mode.

Bundle sizes:
hello_world - 3.0 kB
todo        - 14.7 kB

PR Close #24677
This commit is contained in:
Alex Rickabaugh 2018-06-20 16:02:10 -07:00 committed by Miško Hevery
parent 50d4a4fe5c
commit 34c42836cf
6 changed files with 210 additions and 41 deletions

View File

@ -1,14 +1,15 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ivy_ng_module", "ts_library")
load("//tools:defaults.bzl", "ng_module", "ts_library")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("//packages/bazel/src:ng_rollup_bundle.bzl", "ng_rollup_bundle")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
load("//tools/http-server:http_server.bzl", "http_server")
ivy_ng_module(
ng_module(
name = "hello_world",
srcs = ["index.ts"],
tags = ["ivy-only"],
deps = [
"//packages/core",
],
@ -23,6 +24,7 @@ ng_rollup_bundle(
# has an "external" directory for external dependencies.
# This should probably start with "angular/" and let the rule deal with it.
entry_point = "packages/core/test/bundling/hello_world/index.js",
tags = ["ivy-only"],
deps = [
":hello_world",
"//packages/core",
@ -50,6 +52,7 @@ jasmine_node_test(
tags = [
"ivy-jit",
"ivy-local",
"ivy-only",
],
deps = [":test_lib"],
)
@ -58,6 +61,10 @@ js_expected_symbol_test(
name = "symbol_test",
src = ":bundle.min_debug.js",
golden = ":bundle.golden_symbols.json",
tags = [
"ivy-local",
"ivy-only",
],
)
http_server(

View File

@ -14,11 +14,14 @@
{
"name": "CONTEXT"
},
{
"name": "ChangeDetectionStrategy"
},
{
"name": "DIRECTIVES"
},
{
"name": "EMPTY$2"
"name": "EMPTY$1"
},
{
"name": "EMPTY_RENDERER_TYPE_ID"
@ -35,15 +38,9 @@
{
"name": "HOST_NODE"
},
{
"name": "HelloWorld"
},
{
"name": "INJECTOR$1"
},
{
"name": "INeedToExistEvenThoughIAmNotNeeded"
},
{
"name": "NEXT"
},
@ -74,6 +71,9 @@
{
"name": "VIEWS"
},
{
"name": "ViewEncapsulation$1"
},
{
"name": "_CLEAN_PROMISE"
},
@ -128,9 +128,6 @@
{
"name": "defineComponent"
},
{
"name": "defineInjector"
},
{
"name": "detectChangesInternal"
},
@ -194,6 +191,9 @@
{
"name": "locateHostElement"
},
{
"name": "namespaceHTML"
},
{
"name": "refreshChildComponents"
},
@ -222,7 +222,7 @@
"name": "setUpAttributes"
},
{
"name": "stringify$1"
"name": "stringify$2"
},
{
"name": "text"

View File

@ -6,16 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, NgModule, ɵrenderComponent as renderComponent} from '@angular/core';
import {Component, ɵrenderComponent as renderComponent} from '@angular/core';
@Component({selector: 'hello-world', template: 'Hello World!'})
export class HelloWorld {
class HelloWorld {
}
// TODO(misko): Forgetting to export HelloWorld and not having NgModule fails silently.
@NgModule({declarations: [HelloWorld]})
export class INeedToExistEvenThoughIAmNotNeeded {
}
// TODO(misko): Package should not be required to make this work.
renderComponent(HelloWorld);

View File

@ -1,15 +1,16 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ivy_ng_module", "ts_library")
load("//tools:defaults.bzl", "ng_module", "ts_library")
load("//tools/http-server:http_server.bzl", "http_server")
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
load("//packages/bazel/src:ng_rollup_bundle.bzl", "ng_rollup_bundle")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
ivy_ng_module(
ng_module(
name = "todo",
srcs = ["index.ts"],
tags = ["ivy-only"],
deps = [
"//packages/common",
"//packages/core",
@ -25,6 +26,7 @@ ng_rollup_bundle(
# has an "external" directory for external dependencies.
# This should probably start with "angular/" and let the rule deal with it.
entry_point = "packages/core/test/bundling/todo/index.js",
tags = ["ivy-only"],
deps = [
":todo",
"//packages/common",
@ -63,6 +65,10 @@ js_expected_symbol_test(
name = "symbol_test",
src = ":bundle.min_debug.js",
golden = ":bundle.golden_symbols.json",
tags = [
"ivy-local",
"ivy-only",
],
)
genrule(

View File

@ -9,7 +9,7 @@
"name": "BLOOM_SIZE"
},
{
"name": "CIRCULAR$2"
"name": "CIRCULAR$1"
},
{
"name": "CLEANUP"
@ -24,17 +24,29 @@
"name": "CONTEXT"
},
{
"name": "CommonModule"
"name": "ChangeDetectionStrategy"
},
{
"name": "DIRECTIVES"
},
{
"name": "EMPTY$2"
"name": "DefaultIterableDiffer"
},
{
"name": "DefaultIterableDifferFactory"
},
{
"name": "EMPTY$1"
},
{
"name": "EMPTY_RENDERER_TYPE_ID"
},
{
"name": "ElementRef"
},
{
"name": "EmbeddedViewRef"
},
{
"name": "FLAGS"
},
@ -50,6 +62,12 @@
{
"name": "INJECTOR$1"
},
{
"name": "IterableChangeRecord_"
},
{
"name": "IterableDiffers"
},
{
"name": "NEXT"
},
@ -77,6 +95,12 @@
{
"name": "NgIfContext"
},
{
"name": "Optional"
},
{
"name": "PARAMETERS"
},
{
"name": "PARENT"
},
@ -98,6 +122,9 @@
{
"name": "SANITIZER"
},
{
"name": "SkipSelf"
},
{
"name": "TAIL"
},
@ -105,10 +132,7 @@
"name": "TVIEW"
},
{
"name": "ToDoAppComponent"
},
{
"name": "ToDoAppModule"
"name": "TemplateRef"
},
{
"name": "Todo"
@ -122,12 +146,39 @@
{
"name": "VIEWS"
},
{
"name": "ViewContainerRef"
},
{
"name": "ViewEncapsulation$1"
},
{
"name": "_CLEAN_PROMISE"
},
{
"name": "_DuplicateItemRecordList"
},
{
"name": "_DuplicateMap"
},
{
"name": "_ROOT_DIRECTIVE_INDICES"
},
{
"name": "__extends"
},
{
"name": "__read"
},
{
"name": "__self"
},
{
"name": "__spread"
},
{
"name": "__window"
},
{
"name": "_c0"
},
@ -191,12 +242,21 @@
{
"name": "_getComponentHostLElementNode"
},
{
"name": "_global"
},
{
"name": "_renderCompCount"
},
{
"name": "_symbolIterator"
},
{
"name": "addComponentLogic"
},
{
"name": "addRemoveViewFromContainer"
},
{
"name": "addToViewTree"
},
@ -233,9 +293,15 @@
{
"name": "canInsertNativeNode"
},
{
"name": "checkNoChanges"
},
{
"name": "checkNoChangesMode"
},
{
"name": "cleanUpView"
},
{
"name": "componentRefresh"
},
@ -245,6 +311,9 @@
{
"name": "createDirectivesAndLocals"
},
{
"name": "createEmbeddedViewNode"
},
{
"name": "createLContainer"
},
@ -258,7 +327,7 @@
"name": "createLViewData"
},
{
"name": "createOutput"
"name": "createOutput$1"
},
{
"name": "createRootContext"
@ -278,11 +347,23 @@
{
"name": "defineComponent"
},
{
"name": "defineDirective"
},
{
"name": "defineInjectable"
},
{
"name": "defineInjector"
"name": "destroyLView"
},
{
"name": "destroyViewTree"
},
{
"name": "detachView"
},
{
"name": "detectChanges"
},
{
"name": "detectChangesInternal"
@ -320,6 +401,18 @@
{
"name": "executeInitHooks"
},
{
"name": "executeNodeAction"
},
{
"name": "executeOnDestroys"
},
{
"name": "executePipeOnDestroys"
},
{
"name": "extendStatics"
},
{
"name": "extractDirectiveDef"
},
@ -356,6 +449,18 @@
{
"name": "getLViewChild"
},
{
"name": "getNextLNode"
},
{
"name": "getNextLNodeWithProjection"
},
{
"name": "getOrCreateContainerRef"
},
{
"name": "getOrCreateElementRef"
},
{
"name": "getOrCreateInjectable"
},
@ -368,21 +473,39 @@
{
"name": "getOrCreateTView"
},
{
"name": "getOrCreateTemplateRef"
},
{
"name": "getParentLNode"
},
{
"name": "getParentState"
},
{
"name": "getPreviousIndex"
},
{
"name": "getPreviousOrParentNode"
},
{
"name": "getRenderFlags"
},
{
"name": "getRenderer"
},
{
"name": "getRootView"
},
{
"name": "getSymbolIterator"
},
{
"name": "getTViewCleanup"
},
{
"name": "getTypeNameForDebugging"
},
{
"name": "getTypeNameForDebugging$1"
},
@ -398,6 +521,15 @@
{
"name": "inject"
},
{
"name": "injectTemplateRef"
},
{
"name": "injectViewContainerRef"
},
{
"name": "insertView"
},
{
"name": "instantiateDirectivesDirectly"
},
@ -416,6 +548,12 @@
{
"name": "isDifferent"
},
{
"name": "isJsObject"
},
{
"name": "isListLikeIterable"
},
{
"name": "isNodeMatchingSelector"
},
@ -428,6 +566,9 @@
{
"name": "isProceduralRenderer"
},
{
"name": "iterateListLike"
},
{
"name": "leaveView"
},
@ -443,6 +584,15 @@
{
"name": "locateHostElement"
},
{
"name": "looseIdentical"
},
{
"name": "makeMetadataCtor"
},
{
"name": "makeParamDecorator"
},
{
"name": "markDirtyIfOnPush"
},
@ -452,6 +602,9 @@
{
"name": "namespaceHTML"
},
{
"name": "notImplemented"
},
{
"name": "queueComponentIndexForCheck"
},
@ -482,6 +635,12 @@
{
"name": "refreshView"
},
{
"name": "removeListeners"
},
{
"name": "removeView"
},
{
"name": "renderComponent"
},
@ -537,10 +696,10 @@
"name": "storeCleanupWithContext"
},
{
"name": "stringify"
"name": "stringify$1"
},
{
"name": "stringify$1"
"name": "stringify$2"
},
{
"name": "text"
@ -560,19 +719,22 @@
{
"name": "tickRootContext"
},
{
"name": "trackByIdentity"
},
{
"name": "updateViewQuery"
},
{
"name": "viewAttached"
},
{
"name": "walkLNodeTree"
},
{
"name": "wrapListenerWithDirtyAndDefault"
},
{
"name": "wrapListenerWithDirtyLogic"
},
{
"name": "ɵ0"
}
]

View File

@ -11,7 +11,7 @@ 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';
export class Todo {
class Todo {
editing: boolean;
// TODO(issue/24571): remove '!'.
@ -26,7 +26,7 @@ export class Todo {
}
@Injectable({providedIn: 'root'})
export class TodoStore {
class TodoStore {
todos: Array<Todo> = [
new Todo('Demonstrate Components'),
new Todo('Demonstrate Structural Directives', true),
@ -109,7 +109,7 @@ export class TodoStore {
// TODO(misko): switch over to OnPush
// changeDetection: ChangeDetectionStrategy.OnPush
})
export class ToDoAppComponent {
class ToDoAppComponent {
newTodoText = '';
constructor(public todoStore: TodoStore) {}
@ -149,7 +149,7 @@ export class ToDoAppComponent {
}
@NgModule({declarations: [ToDoAppComponent], imports: [CommonModule]})
export class ToDoAppModule {
class ToDoAppModule {
}
// TODO(misko): create cleaner way to publish component into global location for tests.