test(ivy): switch HelloWorld to ivy compiler (#22788)

PR Close #22788
This commit is contained in:
Misko Hevery
2018-03-14 21:32:09 -07:00
committed by Miško Hevery
parent bfe077ad64
commit fc50c77bd3
10 changed files with 135 additions and 26 deletions

View File

@ -1,11 +1,12 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_library", "ivy_ng_module")
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")
ts_library(
ivy_ng_module(
name = "hello_world",
srcs = ["index.ts"],
deps = [
@ -54,3 +55,13 @@ js_expected_symbol_test(
src = ":bundle.min_debug.js",
golden = ":bundle.golden_symbols.json",
)
ts_devserver(
name = "devserver",
static_files = [
":bundle.min_debug.js",
":bundle.min.js",
"index.html",
],
deps = [],
)

View File

@ -8,6 +8,12 @@
{
"name": "EMPTY_RENDERER_TYPE_ID"
},
{
"name": "HelloWorld"
},
{
"name": "INeedToExistEvenThoughtIAmNotNeeded"
},
{
"name": "NG_HOST_SYMBOL"
},
@ -68,6 +74,9 @@
{
"name": "defineComponent"
},
{
"name": "defineInjector"
},
{
"name": "detectChangesInternal"
},

View File

@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<title>Angular Hello World Example</title>
</head>
<body>
<!-- The Angular application will be bootstrapped into this element. -->
<hello-world></hello-world>
<!--
Script tag which bootstraps the application. Use `?debug` in URL to select
the debug version of the script.
There are two scripts sources: `bundle.min.js` and `bundle.min_debug.js` You can
switch between which bundle the browser loads to experiment with the application.
- `bundle.min.js`: Is what the site would serve to their users. It has gone
through rollup, build-optimizer, and uglify with tree shaking.
- `bundle.min_debug.js`: Is what the developer would like to see when debugging
the application. It has also done through full pipeline of rollup, build-optimizer,
and uglify, however special flags were passed to uglify to prevent inlining and
property renaming.
-->
<script>
document.write('<script src="' +
(document.location.search.endsWith('debug') ? '/bundle.min_debug.js' : '/bundle.min.js') +
'"></' + 'script>');
</script>
</body>
</html>

View File

@ -6,19 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ɵT as T, ɵdefineComponent as defineComponent, ɵrenderComponent as renderComponent} from '@angular/core';
import {Component, NgModule, ɵrenderComponent as renderComponent} from '@angular/core';
class HelloWorld {
static ngComponentDef = defineComponent({
type: HelloWorld,
tag: 'hello-world',
factory: () => new HelloWorld(),
template: function HelloWorldTemplate(ctx: HelloWorld, cm: boolean) {
if (cm) {
T(0, 'Hello World!');
}
}
});
@Component({selector: 'hello-world', template: 'Hello World!'})
export class HelloWorld {
}
// TODO(misko): Forgetting to export HelloWorld and not having NgModule fails silently.
@NgModule({declarations: [HelloWorld]})
export class INeedToExistEvenThoughtIAmNotNeeded {
}
// TODO(misko): Package should not be required to make this work.
renderComponent(HelloWorld);