Commit Graph

100 Commits

Author SHA1 Message Date
Marc Laval 445b9a5627 feat(ivy): support ViewContainerRef.createComponent() (#24997)
PR Close #24997
2018-07-24 08:23:23 -07:00
Matias Niemelä 169e9dd2c8 feat(ivy): bridge compile instructions to include sanitization helpers (#24938)
PR Close #24938
2018-07-23 08:49:52 -07:00
Vikram Subramanian 6b859daea4 fix(core): stop reusing provider definitions across NgModuleRef instances (#25022)
Fixes #25018.

Instantiating a NgModuleRef from NgModuleFactory reuses the NgModuleDefinition if it is already present. However the NgModuleDefinition has a providers array which modified when tree shakable providers are instantiated. This corrupts the provider definitions the next time the same factory is used to create a new NgModuleRef - Two provider definitions can end up with the same index anf the injector could potentially return a completely wrong object for a provider token.

This scenario is more likely on the server where the same NgModuleFactory is reused across requests.

The fix clones the cached NgModuleDefinition so that any tree shakable providers added later do not affect the cached copy.

PR Close #25022
2018-07-23 08:13:29 -07:00
Alex Rickabaugh ed1db40322 fix(ivy): use 'typeof' and 'never' for type metadata (#24862)
Previously ngtsc would use a tuple of class types for listing metadata
in .d.ts files. For example, an @NgModule's declarations might be
represented with the type:

[NgIf, NgForOf, NgClass]

If the module had no declarations, an empty tuple [] would be produced.

This has two problems.

1. If the class type has generic type parameters, TypeScript will
complain that they're not provided.

2. The empty tuple type is not actually legal.

This commit addresses both problems.

1. Class types are now represented using the `typeof` operator, so the
above declarations would be represented as:

[typeof NgIf, typeof NgForOf, typeof NgClass].

Since typeof operates on a value, it doesn't require generic type
arguments.

2. Instead of an empty tuple, `never` is used to indicate no metadata.

PR Close #24862
2018-07-20 11:48:36 -07:00
Matias Niemelä ba3eb8b654 feat(ivy): properly apply class="", [class], [class.foo] and [attr.class] bindings (#24822)
PR Close #24822
2018-07-17 16:33:25 -04:00
Pawel Kozlowski 0399c6972a refactor(ivy): remove content query creation from directive factories (#24811)
PR Close #24811
2018-07-12 16:32:33 -04:00
Kara Erickson 3a19f70d1c refactor(ivy): replace pNextOrParent with TNode props (#24752)
PR Close #24752
2018-07-10 11:12:27 -07:00
Greg Magolan 1e74ea9e60 build(bazel): update to rule_nodejs 0.10.0 (#24759)
PR Close #24759
2018-07-06 10:17:36 -07:00
Ben Lesh 9803cb011e feat(ivy): Add InheritanceDefinitionFeature to support directive inheritance (#24570)
- Adds InheritanceDefinitionFeature to ivy
- Ensures that lifecycle hooks are inherited from super classes whether they are defined as directives or not
- Directives cannot inherit from Components
- Components can inherit from Directives or Components
- Ensures that Inputs, Outputs, and Host Bindings are inherited
- Ensures that super class Features are run

PR Close #24570
2018-06-29 06:42:40 -07:00
Alex Rickabaugh 01e7ff682c test(ivy): todo app only includes reflect-metadata in JIT mode (#24677)
Previously the todo app imported reflect-metadata, since it is a dependency
of JIT and the todo app tests run in both JIT and AOT modes. However, the
code doesn't get tree-shaken away in AOT mode.

This change adds a target //packages/core/test/bundling/util:reflect_metadata
which, depending on whether the compile flag is in JIT or AOT mode, either
includes reflect-metadata or is a no-op.

Not including reflect-metadata gets the compressed todo bundle down to 12.5 kB.

PR Close #24677
2018-06-28 17:51:42 -04:00
Alex Rickabaugh 34c42836cf 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
2018-06-28 17:51:42 -04:00
Alex Rickabaugh 50d4a4fe5c fix(compiler): fix a few non-tree-shakeable code patterns (#24677)
This change makes @angular/compiler more tree-shakeable by changing
an enum to a const enum and by getting rid of a top-level map that
the tree-shaker was seeing as a reference which caused r3_identifiers
to be retained.

This drops a few hundred bytes of JS from tree-shaken ngtsc compiled
apps.

PR Close #24677
2018-06-28 17:51:42 -04:00
Alex Rickabaugh 2ecaa40e64 build(ivy): run latest build-optimizer on ngtsc compiled code (#24677)
Previously the repo was depending on an old version of build optimizer.
This change updates to the latest (an RC release in the CLI package).

Additionally, this changes the behavior of ng_rollup_bundle to apply
the optimizer to ngtsc compiled code, and configures it to treat the
@angular/compiler package as side-effect-free.

This results in a substantial size reduction of ngtsc compiled code.

PR Close #24677
2018-06-28 17:51:42 -04:00
Kara Erickson fe8fcc834c refactor(ivy): remove dynamicParent from LNode (#24678)
PR Close #24678
2018-06-27 14:14:46 -07:00
Marc Laval f229449c67 refactor(ivy): insert embedded views immediately (#24629)
PR Close #24629
2018-06-25 07:58:33 -07:00
Pawel Kozlowski 1e139d4339 refactor(ivy): rename, limit usage of global vars (#24604)
PR Close #24604
2018-06-25 07:57:52 -07:00
Rado Kirov c95437f15d build(bazel): Turning on strictPropertyInitialization for Angular. (#24572)
All errors for existing fields have been detected and suppressed with a
`!` assertion.

Issue/24571 is tracking proper clean up of those instances.

One-line change required in ivy/compilation.ts, because it appears that
the new syntax causes tsickle emitted node to no longer track their
original sourceFiles.

PR Close #24572
2018-06-25 07:57:13 -07:00
Pawel Kozlowski 3e1a3b2e32 fix(ivy): support queries for views inserted in lifecycle hooks (#24587)
Closes #23707

PR Close #24587
2018-06-20 16:51:14 -07:00
Alex Rickabaugh 27bc7dcb43 feat(ivy): ngtsc compiles @Component, @Directive, @NgModule (#24427)
This change supports compilation of components, directives, and modules
within ngtsc. Support is not complete, but is enough to compile and test
//packages/core/test/bundling/todo in full AOT mode. Code size benefits
are not yet achieved as //packages/core itself does not get compiled, and
some decorators (e.g. @Input) are not stripped, leading to unwanted code
being retained by the tree-shaker. This will be improved in future commits.

PR Close #24427
2018-06-14 14:36:45 -07:00
Marc Laval e3c54e4465 refactor(ivy): use comment nodes to mark view containers (#24346)
PR Close #24346
2018-06-13 11:23:21 -07:00
Alex Eagle c2b5ebfa24 build: update buildifier to latest (#24296)
this matches the version in ngcontainer:0.3.1

PR Close #24296
2018-06-12 11:42:35 -07:00
Kara Erickson 29eb24b142 refactor(ivy): combine LView with data (#24382)
PR Close #24382
2018-06-08 21:41:01 -07:00
Ben Lesh 8c1ac28275 feat(ivy): now supports SVG and MathML elements (#24377)
- Adds support for ivy creating SVG and MathML elements properly using
createElementNS

PR Close #24377
2018-06-08 15:27:35 -07:00
Jason Aden e3759f7a73 feat(ivy): add support of ApplicationRef.bootstrapModuleFactory (#23811)
PR Close #23811
2018-06-07 16:15:26 -04:00
Victor Berchet 7de2ba0e22 Revert "feat(ivy): add namespace instructions for SVG and others (#23899)"
This reverts commit 81e4b2a4bf.
2018-06-06 13:38:21 -07:00
Victor Berchet c151f9cdc8 Revert "refactor(ivy): rename setNS, setHtmlNS and friends to namespace, namespaceHTML, etc (#23899)"
This reverts commit 0d06c866c6.
2018-06-06 13:38:17 -07:00
Victor Berchet d96ae123b2 Revert "feat(ivy): SVG now handled by ivy compiler (#23899)"
This reverts commit 1007d1ad27.
2018-06-06 13:38:10 -07:00
Ben Lesh 1007d1ad27 feat(ivy): SVG now handled by ivy compiler (#23899)
PR Close #23899
2018-06-06 10:22:28 -07:00
Ben Lesh 0d06c866c6 refactor(ivy): rename setNS, setHtmlNS and friends to namespace, namespaceHTML, etc (#23899)
- Renames functions
- Adds documentation

PR Close #23899
2018-06-06 10:22:27 -07:00
Ben Lesh 81e4b2a4bf feat(ivy): add namespace instructions for SVG and others (#23899)
PR Close #23899
2018-06-06 10:22:27 -07:00
Victor Berchet c494d3cf60
Revert "feat(ivy): add support of ApplicationRef.bootstrapModuleFactory (#23811)"
This reverts commit 22b58a717a.
This commit causes a breakage in g3.
2018-06-05 22:11:47 -07:00
Jason Aden 22b58a717a feat(ivy): add support of ApplicationRef.bootstrapModuleFactory (#23811)
PR Close #23811
2018-06-05 20:10:25 -07:00
Kara Erickson 86b13ccf80 refactor(ivy): move static parts of LView.cleanup to TView (#24301)
PR Close #24301
2018-06-05 18:30:28 -07:00
Marc Laval b750919ce0 feat(ivy): implement ViewContainerRef.remove (#24221)
PR Close #24221
2018-06-05 13:33:40 -07:00
Miško Hevery 08a18b82de refactor(common): Remove ngOnChanges from NgForOf (#23378)
`NgForOf` used to implement `OnChanges` and than use
`ngOnChanges` callback to detect when `ngForOf` binding
changed to update the differ. We now do the checking
manually which puts less pressure on the runtime to do
the bookkeeping and should result in minor perf improvement.

PR Close #23378
2018-06-04 13:24:43 -07:00
Alan Agius f69ac670ee feat(compiler-cli): update `tsickle` to `0.29.x` (#24233)
PR Close #24233
2018-06-01 08:35:14 -07:00
Kara Erickson 7e3f8f77a9 refactor(ivy): replace LView.child with TView.childIndex lookup (#24211)
PR Close #24211
2018-05-31 12:10:49 -07:00
Victor Berchet accda00190 test(platform-server): update the symbol lists (#24209)
PR Close #24209
2018-05-30 15:51:17 -07:00
Alex Rickabaugh 646b42a113 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
2018-05-30 11:25:57 -07:00
Marc Laval 42a7295203 refactor(ivy): remove dynamicViewCount from LContainer (#23963)
PR Close #23963
2018-05-30 11:24:53 -07:00
Kara Erickson e53179ef8c refactor(ivy): move parent from LNode to TNode (#24189)
PR Close #24189
2018-05-30 01:42:20 -04:00
Alex Rickabaugh 1eafd04eb3 build(ivy): support alternate compilation modes to enable Ivy testing (#24056)
Bazel has a restriction that a single output (eg. a compiled version of
//packages/common) can only be produced by a single rule. This precludes
the Angular repo from having multiple rules that build the same code. And
the complexity of having a single rule produce multiple outputs (eg. an
ngc-compiled version of //packages/common and an Ivy-enabled version) is
too high.

Additionally, the Angular repo has lots of existing tests which could be
executed as-is under Ivy. Such testing is very valuable, and it would be
nice to share not only the code, but the dependency graph / build config
as well.

Thus, this change introduces a --define flag 'compile' with three potential
values. When --define=compile=X is set, the entire build system runs in a
particular mode - the behavior of all existing targets is controlled by
the flag. This allows us to reuse our entire build structure for testing
in a variety of different manners. The flag has three possible settings:

* legacy (the default): the traditional View Engine (ngc) build
* local: runs the prototype ngtsc compiler, which does not rely on global
  analysis
* jit: runs ngtsc in a mode which executes tsickle, but excludes the
  Angular related transforms, which approximates the behavior of plain
  tsc. This allows the main packages such as common to be tested with
  the JIT compiler.

Additionally, the ivy_ng_module() rule still exists and runs ngc in a mode
where Ivy-compiled output is produced from global analysis information, as
a stopgap while ngtsc is being developed.

PR Close #24056
2018-05-29 18:02:29 -04:00
Victor Berchet 729c797890 fix(ivy): `pipeBindV` takes an array of values (#24039)
PR Close #24039
2018-05-25 13:46:50 -04:00
Victor Berchet 188ff848d2 fix(ivy): `pureFunctionV` takes an array of values (#24039)
PR Close #24039
2018-05-25 13:46:50 -04:00
Kara Erickson 609e6b9787 refactor(ivy): move child from LNode to TNode (#24113)
PR Close #24113
2018-05-25 13:41:00 -04:00
Alex Rickabaugh 919f42fea1 feat(ivy): first steps towards JIT compilation (#23833)
This commit adds a mechanism by which the @angular/core annotations
for @Component, @Injectable, and @NgModule become decorators which,
when executed at runtime, trigger just-in-time compilation of their
associated types. The activation of these decorators is configured
by the ivy_switch mechanism, ensuring that the Ivy JIT engine does
not get included in Angular bundles unless specifically requested.

PR Close #23833
2018-05-21 19:13:50 -04:00
Kara Erickson 6e7d071c6b fix(ivy): move next property to TNode (#23869)
PR Close #23869
2018-05-21 16:09:12 -04:00
Matias Niemelä 816bc8af17 feat(ivy): support injectable sanitization service (#23809)
PR Close #23809
2018-05-11 16:43:43 -04:00
Igor Minar 5b96078624 Revert "refactor(core): tree-shake application_module providers (#23477)"
This reverts commit eb031c6ff1.

The change is breaking targets in g3 see cl/194336387.
2018-04-26 14:08:13 -07:00
Marc Laval 1a44a0b4a8 feat(ivy): support lifecycle hooks of ViewContainerRef (#23396)
PR Close #23396
2018-04-25 19:02:00 -07:00