Commit Graph

477 Commits

Author SHA1 Message Date
Victor Berchet 4662878a1f refactor(compiler): refactor template binding parsing (#23460)
A long time ago Angular used to support both those attribute notations:
- `*attr='binding'`
- `template=`attr: binding`

Because the last notation has been dropped we can refactor the binding parsing.
Source maps will benefit from that as no `attr:` prefix is added artificialy any
more.

PR Close #23460
2018-04-20 16:07:55 -07:00
Alex Rickabaugh ca776c59dd fix(compiler): handle undefined annotation metadata (#23349)
In certain cases seen in production, simplify() can returned
undefined when simplifying decorator metadata. This has proven tricky
to reproduce in an isolated test, but the fix is simple and low-risk:
don't attempt to spread an undefined set of annotations in the first
place.

PR Close #23349
2018-04-19 18:57:22 -07:00
Victor Berchet 9757347e71 feat(ivy): add an IVY local the compiler which avoids analyzeModule (#23441)
closes #23289

Based on a spike by @chukjaz

PR Close #23441
2018-04-19 16:32:09 -07:00
Victor Berchet a19e018439 refactor(ivy): remove the backpatch compiler (#23441)
PR Close #23441
2018-04-19 16:32:09 -07:00
Victor Berchet 6ff164be0e refactor(compiler): misc minor (#23441)
PR Close #23441
2018-04-19 16:32:09 -07:00
Victor Berchet 84f024309a refactor(ivy): misc cleanup (#23441)
PR Close #23441
2018-04-19 16:32:09 -07:00
Victor Berchet c6b206ee4b feat(compiler): support `// ...` and `// TODO` in mock compiler expectations (#23441)
PR Close #23441
2018-04-19 16:32:09 -07:00
Victor Berchet 1d1e75ee2b Revert "fix(compiler): Pretty print object instead of [Object object] (#22689)" (#23442)
This reverts commit 8555a3a3cd.

Reverted because of https://github.com/angular/angular/issues/23440

PR Close #23442
2018-04-19 14:51:58 -07:00
Kara Erickson 7f612fc828 fix(ivy): generate bind calls for property bindings (#23403)
PR Close #23403
2018-04-17 13:44:48 -07:00
Victor Berchet 80e483ceac fix(ivy): add unparsed selectors to the `projectionDef` instruction (#23375)
PR Close #23375
2018-04-13 21:46:19 -07:00
Victor Berchet ac683d7abb refactor(ivy): cleanup of the view compiler (#23375)
PR Close #23375
2018-04-13 21:46:19 -07:00
Misko Hevery da31db757b feat(ivy): support injection even if no injector present (#23345)
- Remove default injection value from `inject` / `directiveInject` since
  it is not possible to set using annotations.
- Module `Injector` is stored on `LView` instead of `LInjector` data
  structure because it can change only at `LView` level. (More efficient)
- Add `ngInjectableDef` to `IterableDiffers` so that existing tests can
  pass as well as enable `IterableDiffers` to be injectable without
  `Injector`

PR Close #23345
2018-04-13 14:29:52 -07:00
Misko Hevery 6f213a74f2 feat(ivy): support generation of flags for directive injection (#23345)
This change changes:
- compiler uses `directiveInject` instead of `inject` for `Directive`s
- unifies the flags in `di` as well as `render3`
- changes the signature of `directiveInject` to match `inject` In prep for #23330
- compiler now generates flags for injection.

Compiler portion of #23342
Prep for #23330

PR Close #23345
2018-04-13 14:29:52 -07:00
Victor Berchet 6e73300ff1 refactor(ivy): cleanup directives & pipes import (#23369)
PR Close #23369
2018-04-13 13:15:26 -07:00
Kara Erickson 0d516f1658 fix(ivy): update compiler to generate separate creation mode and update mode blocks (#23292)
PR Close #23292
2018-04-11 15:30:39 -07:00
Pete Bacon Darwin 4b96a58c5a docs: remove all deprecated `@stable` jsdoc tags (#23210)
These are no longer needed as stable docs are computed as those that
do not have `@experimental` or `@deprecated` tags.

PR Close #23210
2018-04-10 21:49:32 -07:00
Keen Yee Liau 8555a3a3cd fix(compiler): Pretty print object instead of [Object object] (#22689)
The 'stringify' function prints an object as [Object object] which
is not very helpful in many cases, especially in a diagnostics
message. This commit changes the behavior to pretty print an object.

PR Close #22689
2018-04-10 13:15:18 -07:00
Miško Hevery 3fb4e190a8 fix(ivy): correctly bind to component context (#23168)
When compiling templates the compiler would often bind to
closest context rather than the component context.

The only time one should be binding to the cont component is
in explicit cases where the inner template declares local variable.

PR Close #23168
2018-04-10 13:14:20 -07:00
Miško Hevery 50ab8d8ad4 build: create a more focused build file for packages/compiler/render3 (#23168)
PR Close #23168
2018-04-10 13:14:20 -07:00
Miško Hevery f544635014 feat(ivy): Bind to right context in nested template statmentes (#23168)
Given
```
<div *ngFor=”…” (click)=“doSomething()”>
```

Before `doSomething` would execute on the inner template context, which
is incorrect. The correct behavior is to execute on the top level context
of the component.

PR Close #23168
2018-04-10 13:14:20 -07:00
Miško Hevery c059670792 feat(ivy): Add `outputs` support for `defineDirective` / `defineComponent` (#23168)
PR Close #23168
2018-04-10 13:14:20 -07:00
Alex Rickabaugh 195193b9be docs(compiler): update ngtsc/ngcc design doc with more details (#23174)
PR Close #23174
2018-04-06 14:35:15 -07:00
Alex Rickabaugh 550433a128 feat(compiler-cli): lower loadChildren fields to allow dynamic module paths (#23088)
Computing the value of loadChildren does not work externally, as the CLI
needs to be able to detect the paths referenced to properly set up
codesplitting. However, internally, different approaches to codesplitting
require hashed module IDs, and the computation of those hashes involves
something like:

{path: '...', loadChildren: hashFn('module')}

ngc should lower loadChildren into an exported constant in that case.

This will never break externally, because loadChildren is always a
string externally, and a string won't get lowered.

PR Close #23088
2018-04-04 08:20:21 -07:00
Miško Hevery 60065935be refactor(ivy): align compiler with runtime (#22921)
Remove `containerRefreshStart` and `containerRefreshEnd` instruction
from the output.

Generate directives as a list in `componentDef` rather than inline into
instructions. This is consistent in making selector resolution runtime
so that translation of templates can follow locality.

PR Close #22921
2018-04-02 15:49:48 -07:00
Miško Hevery 5266ffe04a feat(ivy): add `(event)="handle"` syntax support to compiler (#22921)
PR Close #22921
2018-04-02 15:49:48 -07:00
Kara Erickson 85d3b591b6 refactor(ivy): generate pipe names instead of defs (#23104)
PR Close #23104
2018-04-02 09:42:44 -07:00
Alex Rickabaugh d6bf71ae95
docs(compiler): initial outline of Ivy Compiler Architecture design doc (#22916) 2018-03-30 15:43:34 -07:00
Kara Erickson 9cd446565c refactor(compiler): generate flat css selectors (#23074)
PR Close #23074
2018-03-30 15:27:50 -07:00
Alex Eagle 15278784fc release(bazel): change publish-next script to publish bazel artifacts (#23097)
PR Close #23097
2018-03-30 14:03:05 -07:00
Victor Berchet 28058b784b fix(compiler): fix support for html-like text in translatable attributes (#23053)
PR Close #23053
2018-03-29 08:58:27 -07:00
Chuck Jazdzewski 4e004f3783 ci(compiler-cli): run compiler-cli tests in bazel (#22997)
PR Close #22997
2018-03-28 10:02:53 -07:00
Alex Rickabaugh bd024c02e2 feat(compiler): lower @NgModule ids if needed (#23031)
This change allows the id of an NgModule to be dynamically computed if
needed.

PR Close #23031
2018-03-28 09:15:16 -07:00
Alex Rickabaugh 884bf0ef09 fix: consistently rewrite Injector to INJECTOR (#23008)
In Ivy mode we rewrite references to Injector to INJECTOR in ngInjectableDef, to fix tree-shaking.

This changes the rewrite to happen always, even in non-Ivy mode, and makes Angular understand
INJECTOR across the board at runtime.

PR Close #23008
2018-03-28 09:14:32 -07:00
Veres Lajos 0ebdb3d12f style: typo fix amendments (#22975)
PR Close #22975
2018-03-27 14:51:53 -04:00
Veres Lajos de90314304 style: typos fixed - https://github.com/vlajos/misspell-fixer (#22975)
PR Close #22975
2018-03-27 14:51:53 -04:00
Kara Erickson 910a16a1ff refactor(ivy): remove directive references from template (#22986)
PR Close #22986
2018-03-26 22:33:23 -04:00
Victor Berchet 65f296a676 test(compiler): assert translation names pattern (#22960)
PR Close #22960
2018-03-23 15:06:06 -04:00
Victor Berchet bcaa07b0ac refactor(compiler): move handling of translations to the ConstantPool (#22942)
PR Close #22942
2018-03-23 13:12:58 -04:00
Victor Berchet d98e9e7c7f fix(compiler): take quoting into account when determining if object literals can be shared (#22942)
PR Close #22942
2018-03-23 13:12:58 -04:00
Victor Berchet 5ab9d4d437 test(compiler): allow asserting matching identifier names (#22835)
PR Close #22835
2018-03-22 21:24:19 -04:00
Victor Berchet 129bb1800b refactor(compiler): refactor code matching helpers for compliance spec (#22835)
PR Close #22835
2018-03-22 21:24:19 -04:00
Chuck Jazdzewski 8ca26a9ebb ci(compiler): run compiler tests in bazel (#22900)
PR Close #22900
2018-03-22 19:22:14 -04:00
Olivier Combe 204ba9d413 feat(compiler): add basic support for in ivy/i18n code generation (#22654)
PR Close #22654
2018-03-22 19:01:51 -04:00
Igor Minar 7d095b96cd fix: correct several esm2015 entry-points in package.jsons (#22892)
PR Close #22892
2018-03-20 13:30:08 -07:00
Alex Eagle 689f351092 build: expose flatModuleOutFile option on ng_module (#22814)
This lets projects like Material change ng_package "bundle index" files to non-conflicting paths

Currently packages like @angular/core ship with the generated metadata
in a path like 'core.js' which overwrites one of the inputs.

Angular material puts the generated file in a path like 'index.js'

Either way these files generated by ng_module rules have the potential
to collide with inputs given by the user, which results in an error.

Instead, give users the freedom to choose a different non-conflicting name.

Also this refactors the ng_package rule, removing the redundant
secondary_entry_points attribute.

Instead, we assume that any ng_module in the deps with a module_name
attribute is a secondary entry point.

PR Close #22814
2018-03-20 13:28:57 -07:00
Igor Minar b43f8bc7d3 feat(core): upgrade rxjs to 6.0.0-alpha.4 (#22573)
PR Close #22573
2018-03-19 21:51:51 -07:00
Rado Kirov 5c387a7f3c fix(compiler): do not emit line/char in ngsummary files. (#22840)
Having ngsummaries emit line/char numbers causes white space change to
retrigger upstream recompilations.

PR Close #22840
2018-03-19 16:01:41 -07:00
Igor Minar ce63dc6f95 feat: update the package output of build.sh to APF v6 (#22808)
PR Close #22808
2018-03-18 09:33:51 -07:00
Alex Rickabaugh 6ef9f2278f feat(ivy): @NgModule -> ngInjectorDef compilation (#22458)
This adds compilation of @NgModule providers and imports into
ngInjectorDef statements in generated code. All @NgModule annotations
will be compiled and the @NgModule decorators removed from the
resultant js output.

All @Injectables will also be compiled in Ivy mode, and the decorator
removed.

PR Close #22458
2018-03-16 12:57:11 -07:00
Andrew Seguin 87f60bccfd feat(elements): injector create (#22413)
PR Close #22413
2018-03-16 12:39:07 -07:00
Alex Eagle f9247e4b2e build: enable importHelpers in tsconfig (#22812)
This is the primary tsconfig file used for Bazel builds.
Previously, we enabled this option only for releases.

PR Close #22812
2018-03-15 21:16:03 -07:00
Igor Minar 44de10e2db feat: mark angular packages as side-effect free (#22785)
This flag is picked up by webpack v4 and used for more agressive optimizations.

Our code is already side-effect free, because that's what we needed for build-optimizer to work.

PR Close #22785
2018-03-15 14:52:40 -07:00
Victor Berchet 0ebd577db4 refactor(compiler): Drop support for the deprecated `<template>`. Use `<ng-template>` instead (#22783)
BREAKING CHANGE:

The `<template>` tag was deprecated in Angular v4 to avoid collisions (i.e. when
using Web Components).

This commit removes support for `<template>`. `<ng-template>` should be used
instead.

BEFORE:

    <!-- html template -->
    <template>some template content</template>

    # tsconfig.json
    {
      # ...
      "angularCompilerOptions": {
        # ...
        # This option is no more supported and will have no effect
        "enableLegacyTemplate": [true|false]
      }
    }

AFTER:

    <!-- html template -->
    <ng-template>some template content</ng-template>

PR Close #22783
2018-03-15 14:52:22 -07:00
Olivier Combe 3b167be069 feat(compiler): support for singleline, multiline & jsdoc comments (#22715)
PR Close #22715
2018-03-15 14:48:53 -07:00
Alex Eagle 88b3198c80 feat(bazel): change ng_package rule to APF v6 (#22782)
Angular Package Format v6 stops bundling files in the esm5 and esm2015
directories, now that Webpack 4 can tree-shake per-file.

Adds some missing files like package.json to make packages closer to
what we publish today.

Refactor ng_package to be a type of npm_package and re-use the packaging
action from that rule.

PR Close #22782
2018-03-15 11:38:31 -07:00
Miško Hevery a0a01f1e1e refactor(ivy): rename class/style to make space for new instruction (#22719)
Rename:
- `elementClass` (short: `k`) => `elementClassNamed` (short: `kn`)
- `elementStyle` (short: `s`) => `elementStyleNamed` (short: `sn`)

Currently `[class.name]` is `elementClass(0, ‘name’, value)`. We would
like to introduce new binding `[class]` which needs a new instruction
ideally `elementClass(0, value)`. Doing the rename creates space
to create such an instruction in subsequent change.

PR Close #22719
2018-03-14 12:59:52 -07:00
WilliamKoza 4ac606b419 docs(compiler): fix spelling errors (#22704)
PR Close #22704
2018-03-13 21:45:13 -07:00
Alex Rickabaugh db56836425 feat: tree-shakeable providers API updates (#22655)
Rename @Injectable({scope -> providedIn}).

Instead of {providedIn: APP_ROOT_SCOPE}, accept {providedIn: 'root'}.
Also, {providedIn: null} implies the injectable should not be added
to any scope.

PR Close #22655
2018-03-13 09:28:05 -07:00
Chuck Jazdzewski 8449eb8d62 build: upgrade to TypeScript 2.7 (#22669)
Fixes: #21571

PR Close #22669
2018-03-12 09:27:23 -07:00
Alex Eagle 1e6cc42a01 test: migrate remaining public-api tests to Bazel (#22639)
We now create npm packages to cover all the public api assertions in tools/public_api_guard.
We no longer depend on ts-api-guardian from npm - it is now stale since the repository was archived.
There is no longer a gulp task to enforce or accept the public API, this is in CircleCI as part of running all bazel test targets.

PR Close #22639
2018-03-09 09:11:40 -08:00
Chuck Jazdzewski b0b9ca3386 feat(ivy): produce Renderer2 back-patching and factories. (#22506)
Produces back-patch as described in the #22235 and referenced in #22480.

This just contains the compiler implementations and the corresponding unit
tests. Connecting the dots as described in #22480 will be in a follow on
change.

PR Close #22506
2018-03-08 22:39:07 -08:00
Igor Minar 489fec1299 feat: update tslib to 1.9.0 (#22667)
BREAKING CHANGE: after this change, npm and yarn will issue incompatible peerDependencies warning

We don't expect this to actually break an application, but the application/library package.json
will need to be updated to provide tslib 1.9.0 or higher.

PR Close #22667
2018-03-08 16:42:34 -08:00
Chuck Jazdzewski 73c203fda9 feat(ivy): support host attribute and property bindings (#22334)
PR Close #22334
2018-03-08 10:57:30 -08:00
Suguru Inatomi f86d8ae0fd docs(compiler): fix a line about ivy library (#22579)
PR Close #22579
2018-03-05 21:25:43 -08:00
Chuck Jazdzewski 0451fd93df feat(ivy): support generating view and content queries (#22330)
PR Close #22330
2018-03-01 13:06:47 -08:00
Chuck Jazdzewski 49f074f61d feat(ivy): support array and object literals in binding expressions (#22336)
PR Close #22336
2018-03-01 13:02:58 -08:00
Alex Rickabaugh dd534471ec fix(compiler): allow tree-shakeable injectables to depend on string tokens (#22376)
Previously the injectable compiler assumed all tree-shakeable injectables
would have dependencies that were injectables or InjectionTokens. However
old code still uses string tokens (e.g. NgUpgrade and '$injector'). Using
such tokens would cause the injectable compiler to crash.

Now, the injectable compiler can properly generate a dependency on such a
string token.

PR Close #22376
2018-03-01 08:15:13 -08:00
Chuck Jazdzewski 8bb2f5c71d docs(compiler): ivy separate compilation design document (#22480)
PR Close #22480
2018-03-01 08:14:35 -08:00
Hans Larsen 288851c41e release: add ng update package group metadata to angular (#22482)
"ng update" supports having multiple packages as part of a group which should be updated together, meaning that e.g. calling "ng update @angular/core" would be equivalent to updating all packages of the group (that are part of the package.json already).

In order to support the grouping feature, the package.json of the version the user is updating to needs to include an "ng-update" key that points to this metadata.

The entire specification for the update workflow can be found here: 2e8b12a4ef/docs/specifications/update.md

PR Close #22482
2018-02-28 14:57:53 -08:00
Chuck Jazdzewski 99909bbf2c feat(ivy): generate pipe references and definitions (#22034)
PR Close #22034
2018-02-20 13:58:03 -08:00
Victor Berchet 5a14e2238f refactor(ivy): split the `memory` instruction into `store` and `load` (#22268)
PR Close #22268
2018-02-18 18:48:41 -08:00
Oussama Ben Brahim f1a063298e feat(core): set preserveWhitespaces to false by default (#22046)
Fixes #22027

PR Close #22046
2018-02-16 09:06:14 -08:00
Alex Rickabaugh f755db78dc fix(core): require factory to be provided for shakeable InjectionToken (#22207)
InjectionToken can be created with an ngInjectableDef, and previously
this allowed the full expressiveness of @Injectable. However, this
requires a runtime reflection system in order to generate factories
from expressed provider declarations.

Instead, this change requires scoped InjectionTokens to provide the
factory directly (likely using inject() for the arguments), bypassing
the need for a reflection system.

Fixes #22205

PR Close #22207
2018-02-15 16:16:16 -08:00
Victor Berchet 5dd2b5135d refactor(ivy): rename `bindX()` functions to `interpolationX()` (#22229)
rationale: remove the confusion with `bind()` and `bind0()`

PR Close #22229
2018-02-15 14:20:53 -08:00
Trotyl 72f8abd7b3 fix(compiler): make unary plus operator consistent to JavaScript (#22154)
fixes #22089

PR Close #22154
2018-02-13 13:04:30 -08:00
Alex Rickabaugh 235a235fab feat: change @Injectable() to support tree-shakeable tokens (#22005)
This commit bundles 3 important changes, with the goal of enabling tree-shaking
of services which are never injected. Ordinarily, this tree-shaking is prevented
by the existence of a hard dependency on the service by the module in which it
is declared.

Firstly, @Injectable() is modified to accept a 'scope' parameter, which points
to an @NgModule(). This reverses the dependency edge, permitting the module to
not depend on the service which it "provides".

Secondly, the runtime is modified to understand the new relationship created
above. When a module receives a request to inject a token, and cannot find that
token in its list of providers, it will then look at the token for a special
ngInjectableDef field which indicates which module the token is scoped to. If
that module happens to be in the injector, it will behave as if the token
itself was in the injector to begin with.

Thirdly, the compiler is modified to read the @Injectable() metadata and to
generate the special ngInjectableDef field as part of TS compilation, using the
PartialModules system.

Additionally, this commit adds several unit and integration tests of various
flavors to test this change.

PR Close #22005
2018-02-12 14:34:59 -08:00
Alex Rickabaugh 2d5e7d1b52 feat(compiler): mark @NgModules in provider lists for identification at runtime (#22005)
All of the providers in a module get compiled into a module definition in the
factory file. Some of these providers are for the actual module types, as those
are available for injection in Angular. For tree-shakeable tokens, the runtime
needs to be able to distinguish which modules are present in an injector.

This change adds a NodeFlag which tags those module providers for later
identification.

PR Close #22005
2018-02-12 14:34:59 -08:00
Chuck Jazdzewski aa456edafc refactor(ivy): validate that identifier identity in emitted output (#21877)
Modifies validation syntax to generate back references to ensure
that identifiers are used consistently.

Introduced … to allow validating constant definition and usage.

PR Close #21877
2018-02-09 13:06:10 -08:00
Chuck Jazdzewski f816666ede fix(ivy): generate lifecycle pattern (#21865)
Implement the lifecycle pattern defined in #21793

PR Close #21865
2018-02-02 07:50:31 -08:00
Chuck Jazdzewski 3cc1d76ee7 fix(ivy): generate correct interpolations (#21946)
Ivy compile would generate the an incorrect interpolation if there
were more than 8 interpolations in a text block.

Fixes: #21927

PR Close #21946
2018-02-02 07:49:13 -08:00
Chuck Jazdzewski eb8ddd2983 feat(compiler-cli): reflect static methods added to classes in metadata (#21926)
PR Close #21926
2018-02-01 08:30:58 -08:00
Chuck Jazdzewski 06d6c76192 fix(ivy): compiler should emit new refresh pattern (#21862)
Change compiler to reflect changes made in #21650

PR Close #21862
2018-01-31 10:19:57 -08:00
Chuck Jazdzewski 18174e5564 feat(ivy): support ng-content projection in the ivy compiler (#21764)
PR Close #21764
2018-01-29 11:35:32 -08:00
Misko Hevery 5bd93b1f0f build: fix broken build (#21835)
PR Close #21835
2018-01-27 14:19:29 -08:00
Chuck Jazdzewski 5778bb820a fix(ivy): fix issues found producing "Hello, World" example (#21790)
PR Close #21790
2018-01-27 10:50:13 -08:00
Chuck Jazdzewski 87754ad5ec fix(ivy): emit type `type` fields (#21789)
PR Close #21789
2018-01-27 10:49:54 -08:00
Chuck Jazdzewski bbb8f386f1 feat(ivy): implement template variables (#21760)
PR Close #21760
2018-01-25 22:19:20 -08:00
Kara Erickson 33b338120c refactor(ivy): move onDestroys out of cleanup (#21650)
PR Close #21650
2018-01-24 22:14:33 -08:00
Kara Erickson 811679a583 refactor(ivy): remove unnecessary Comp.r function (#21650)
PR Close #21650
2018-01-24 22:14:33 -08:00
Zhicheng Wang 5f681f9745 fix(compiler): Don't strip `/*# sourceURL ... */` (#16088)
Currently, `shimCssText` only keep `/*# sourceMappingUrl ... */` comments and strip `/*# sourceURL ... */` comments. So, Chrome can't find the source maps for component style(that's created in new `style` tags)

PR Close #16088
2018-01-24 12:35:30 -08:00
Victor Berchet cb5090cdc8 fix(compiler): fix ICU select messages to use male/female/other (#21713)
related to #21694

PR Close #21713
2018-01-23 16:32:23 -08:00
Chuck Jazdzewski 8baff1858b fix(ivy): add names to function expressions (#21714)
PR Close #21714
2018-01-23 13:33:48 -08:00
Chuck Jazdzewski dd8679037e fix(compiler-cli): do not fold errors past calls in the collector (#21708)
Folding errors passed calls prevented the static reflector from
begin able to ignore errors in annotations it doesn't know as
the call to the unknown annotation was elided from the metadata.

Fixes: #21273

PR Close #21708
2018-01-23 13:33:25 -08:00
Chuck Jazdzewski c65634215b feat(ivy): update specification to include template variables (#21677)
PR Close #21677
2018-01-23 13:32:57 -08:00
Chuck Jazdzewski 86d9612230 feat(ivy): update compiler to specification (#21657)
PR Close #21657
2018-01-20 09:28:44 -08:00
Alex Eagle a1492a73ce build: Remove angular_src nested workspace (#21096)
PR Close #21096
2018-01-19 10:17:37 -08:00
Chuck Jazdzewski 64d16dee02 feat(compiler): implement "enableIvy" compiler option (#21427)
The "enableIvy" compiler option is the initial implementation
of the Render3 (or Ivy) code generation. This commit enables
generation generating "Hello, World" (example in the test)
but not much else. It is currenly only useful for internal Ivy
testing as Ivy is in development.

PR Close #21427
2018-01-18 18:22:44 -06:00
Olivier Combe f74130c9f7 fix(compiler): add support for marker tags in xliff serializers (#21250)
The Xliff serializer now supports the tags `seg-source` and `mrk`, while the Xliff2 serializer now supports `mrk`.
Fixes #21078
PR Close #21250
2018-01-17 17:02:09 -08:00
Chuck Jazdzewski e64b1e99c2 fix(compiler): make `.ngsummary.json` files idempotent (#21448)
Fixes: #21432

PR Close #21448
2018-01-10 16:20:53 -08:00
Chuck Jazdzewski e3e2fc0c3b fix(compiler): cache external reference resolution (#21359)
Cache reference resolution for external references as finding
the declaration of a symbol is expensive and does not change
for a program once created.

This resolves a signficant performance regression in the langauge
service.

PR Close #21359
2018-01-10 12:33:52 -08:00
Alex Eagle c4f02e21dd build: move repeated tsconfig attributes to a macro (#20964)
This helps ensure we use the same tsconfig.json file for all compilations.
Next steps are to make it the same tsconfig.json file used by the editor

PR Close #20964
2018-01-10 12:30:19 -08:00
Victor Noel 3e47ea27f5 fix(language-service): ignore null metadatas (#20557)
There can be null metadatas in certain cases, for example with locales.

Fixes #20260

PR Close #20557
2018-01-02 10:29:44 -06:00
Chuck Jazdzewski 83d207d0a7 build: upgrade to TypeScript 2.6 (#21144)
Fixes #20653

PR Close #21144
2017-12-22 20:15:47 -08:00
Miško Hevery ae97920fe2 build: move _testing_init into tools; limit web_test concurrency (#21053)
PR Close #21053
2017-12-22 13:10:51 -08:00
Misko Hevery 3d50fd7cac build: add bazel test rules for remainder of packages (#21053)
PR Close #21053
2017-12-22 13:10:51 -08:00
Misko Hevery cc1058f6e1 build: add bazel test rules for more packages (#21053)
PR Close #21053
2017-12-22 13:10:51 -08:00
Misko Hevery 47e251a80a build: remove `main()` from specs (#21053)
PR Close #21053
2017-12-22 13:10:51 -08:00
Misko Hevery 47bcb5bc35 build(core): add bazel test targets for core (#21053)
- Add tests target for `test`, `test_node_only` and `test_web` in `core` package.
- Created a `_testing_init` pseudo package where bootstrap code for tests is kept.
- Moved `source_map_util` from `test` to `testing` so to prevent circular dependency.
- Removed `visibility:public` for testing `BUILD` packages.

PR Close #21053
2017-12-22 13:10:51 -08:00
Chuck Jazdzewski 33c0ee3441 fix(compiler): report an error for recursive module references
Modules that directly or indirectly export or imported themselves
reports an error instead of generating a stack fault.

Fixes: #19979
2017-12-20 10:54:45 -08:00
Chuck Jazdzewski 82bcd83566 feat(compiler): allow ngIf to use the ngIf expression directly as a guard
Allows a directive to use the expression passed directly to a property
as a guard instead of filtering the type through a type expression.

This more accurately matches the intent of the ngIf usage of its template
enabling better type inference.

Moved NgIf to using this type of guard instead of a function guard.

Closes: #20967
2017-12-18 12:09:21 -08:00
Trotyl 05ff6c09ca fix(compiler): make tsx file aot compatible
fixes #20555
2017-12-15 07:53:46 -08:00
Chuck Jazdzewski d91ff17adc fix(compiler): generate the correct imports for summary type-check
Summaries should be ignored when importing the types used in a
type-check block.
2017-12-15 07:53:11 -08:00
Chuck Jazdzewski 634d33f5dd fix(compiler): support referencing enums in namespaces (#20947)
Due to an overly agressive assert the compiler would generate
an internal error when referencing an enum declared in
namspace.

Fixes #18170

PR Close #20947
2017-12-12 11:55:55 -08:00
Chuck Jazdzewski 70cd124ede feat(compiler): add a pseudo $any() function to disable type checking (#20876)
`$any()` can now be used in a binding expression to disable type
checking for the rest of the expression. This similar to `as any` in
TypeScript and allows expression that work at runtime but do not
type-check.

PR Close #20876
2017-12-11 14:34:38 -08:00
Chuck Jazdzewski e7d9cb3e4c feat(compiler): narrow types of expressions used in *ngIf (#20702)
Structural directives can now specify a type guard that describes
what types can be inferred for an input expression inside the
directive's template.

NgIf was modified to declare an input guard on ngIf.

After this change, `fullTemplateTypeCheck` will infer that
usage of `ngIf` expression inside it's template is truthy.

For example, if a component has a property `person?: Person`
and a template of `<div *ngIf="person"> {{person.name}} </div>`
the compiler will no longer report that `person` might be null or
undefined.

The template compiler will generate code similar to,

```
  if (NgIf.ngIfTypeGuard(instance.person)) {
    instance.person.name
  }
```

to validate the template's use of the interpolation expression.
Calling the type guard in this fashion allows TypeScript to infer
that `person` is non-null.

Fixes: #19756?

PR Close #20702
2017-12-08 10:24:26 -08:00
Alex Eagle ef534c0cc1 build: upgrade bazel rules to latest (#20768)
Add enough BUILD files to make it possible to
`bazel build packages/core/test`

Also re-format BUILD.bazel files with Buildifier.
Add a CI lint check that they stay formatted.

PR Close #20768
2017-12-07 11:27:50 -08:00
Chuck Jazdzewski 8bb42df47e fix(compiler): correctly detect when to serialze summary metadata (#20668)
The change to improve error messages broke the summary serialization
of summaries.

PR Close #20668
2017-11-28 16:43:35 -06:00
Chuck Jazdzewski 8ecda94899 feat(compiler-cli): improve error messages produced during structural errors (#20459)
The errors produced when error were encountered while interpreting the
content of a directive was often incomprehencible. With this change
these kind of error messages should be easier to understand and diagnose.

PR Close #20459
2017-11-27 16:59:57 -06:00
Chuck Jazdzewski 4ed04392d3 fix(compiler): support event bindings in `fullTemplateTypeCheck` (#20490)
The type-check block now disables type checking event access instead
of generating a reference to an undefined variable.

PR Close #20490
2017-11-20 18:39:42 -06:00
Chuck Jazdzewski 68b53c07fd fix(compiler): emit correct type-check-blocks with TemplateRef's (#20463)
The type-check block generated with `"fullTemplateTypeCheck"` was
invalid if the it contained a template ref as would be generated
using the `else` micro-syntax of `NgIf`.

Fixes: #19485

PR Close #20463
2017-11-16 16:19:54 -06:00
Chuck Jazdzewski c33a57666b fix(compiler): recognize @NgModule with a redundant @Injectable (#20320)
The compiler now, again, recognizes `@NgModule()` decorators on
classes with a redundant `@Injectable()` decorator.

Fixes: #19544

PR Close #20320
2017-11-10 11:51:52 -08:00
Chuck Jazdzewski 3257fcdcee fix(compiler): show explanatory text in template errors (#20313)
Fixes: #20076

PR Close #20313
2017-11-09 15:46:30 -08:00
Victor Berchet 9bcd7097d0 test(compiler): do not use `a` as a content selector
As it might trigger false positive in the RegExp from `_makeScopeMatcher`

closes #20256
2017-11-08 15:52:21 -08:00
Victor Berchet c32f5fd393 fix(compiler): fix corner cases in shadow CSS
`cmp:host {}` and `cmp:host some-other-selector {}` were not handled
consistently.

Note those should not match anything but are made equivalent to respectively
`:host(cmp)` and `:host(cmp) some-other-selector` to avoid breaking legacy apps.
2017-11-08 15:20:19 -08:00
Victor Berchet 6e8e3bd248 refactor(core): misc changes and integrate review feedback on #19996
closes #20224
2017-11-06 14:13:02 -08:00
Tobias Bosch 05d96dc507 feat(core): allow to pass in aot summaries also to `TestBed.configureTestingModule`
Also adds caching for summaries.

Closes #19817.
2017-11-06 14:12:30 -08:00
Chuck Jazdzewski bf22f2df88 fix(compiler): report a reasonable error with invalid metadata (#20062)
The compiler would throw an internal exception if an import using
the `ngModule` syntax and the module as not a resolvable symbol.

Fixes: #20049
2017-11-06 10:01:27 -08:00
Olivier Combe 26f82995f6 fix(compiler): don't overwrite missingTranslation's value in JIT (#19952) 2017-11-03 11:08:39 -07:00
Hans Larsen b6abcb2500 refactor: make all rollup config ES5 compatible (#20028)
So they can be required by other Node scripts.

PR Close #20028
2017-10-30 23:09:17 -04:00
Tobias Bosch 420852e2f5 fix(compiler): reexport less symbols in `.ngfactory.ts` files (#19884)
* don't reexport symbols that the user already reexported
* never reexport symbols that are part of arguments of non simple function calls

Fixes #19883

PR Close #19884
2017-10-30 20:11:29 -04:00
Tobias Bosch 957be960d2 fix(compiler): recover from structural errors in watch mode (#19953)
This also changes the compiler so that we throw less often
on structural changes and produce a meaningful state
in the `ng.Program` in case of errors.

Related to #19951

PR Close #19953
2017-10-26 18:43:00 -04:00
Tobias Bosch 18e9d86a3b fix(compiler): translate emit diagnostics with `noEmitOnError: true`. (#19953)
This prevents errors reported against `.ngfactory.ts` files show up
as the result of running `ngc`.

Closes #19935
PR Close #19953
2017-10-26 18:42:59 -04:00
Tobias Bosch a869aeecd2 fix(compiler): don’t store invalid state when using `listLazyRoutes` (#19953)
Previously, `listLazyRoute` would store invalid information in a compiler
internal cache, which lead to incorrect paths that were used during emit.
This commit fixes this.

PR Close #19953
2017-10-26 18:42:59 -04:00
Chuck Jazdzewski 7bfeac746e fix(compiler-cli): only use error collector when needed. (#19912)
The error collector changes behavior of the metadata resolver
in ways that haven't been fully hardened. This changes limits
its use to the lazy route detection and the language service.

Issue: #19906

PR Close #19912
2017-10-24 17:06:41 -04:00
Tobias Bosch 8d45fefc31 refactor(compiler): remove old ngtools api and add listLazyRoutes to new api (#19836)
Usages of `NgTools_InternalApi_NG_2` from `@angular/compiler-cli` will now
throw an error.

Adds `listLazyRoutes` to `@angular/compiler-cli/ngtools2.ts` for getting
the lazy routes of a `ng.Program`.
PR Close #19836
2017-10-23 18:46:04 -04:00
Chuck Jazdzewski 25cbc98979 fix(compiler-cli): do not add references to files outside of `rootDir` (#19770)
References to resources (such as .css files) that are generated into
the `outDir` directory outside of `rootDir` would cause a spurious
compiler error about not being able to find a files that ends in
'.ngstyle.ts'.

Also fixed a minor issue in compiler error reporting

Fixes: #19765, #19767

PR Close #19770
2017-10-18 11:18:50 -07:00
Chuck Jazdzewski 60bdcd6f5f fix(compiler): generate correct imports for type check blocks (#19582)
Fixes: #19485

PR Close #19582
2017-10-17 10:37:55 -07:00
Tobias Bosch 653a211743 Revert "Revert "Revert "perf(compiler): skip type check and emit in bazel in some cases. (#19646)"""
This reverts commit 6b7cead0c5.
2017-10-12 16:09:49 -07:00
Chuck Jazdzewski 6b7cead0c5 Revert "Revert "perf(compiler): skip type check and emit in bazel in some cases. (#19646)""
This reverts commit 94a925a1b0.
2017-10-12 10:32:21 -07:00
Chuck Jazdzewski 94a925a1b0 Revert "perf(compiler): skip type check and emit in bazel in some cases. (#19646)"
This reverts commit a22121d65d.
2017-10-12 10:26:53 -07:00
Tobias Bosch a22121d65d perf(compiler): skip type check and emit in bazel in some cases. (#19646)
If no user files changed:
- only type check the changed generated files

Never emit non changed generated files
- we still calculate them, but don’t send them through
  TypeScript to emit them but cache the written files instead.
PR Close #19646
2017-10-11 15:54:02 -07:00
Tobias Bosch 01f711281c fix(compiler): don’t use `ng://` in AOT source maps, and never point to the original source file
This is important to not confuse users nor downstream tools that
consume our source maps. For generated content for which we don’t
have an original source file, we use the generated file now.

Fixes #19538
2017-10-04 16:20:55 -07:00
Tobias Bosch 5b5108363d refactor(compiler): remove stale metadata classes for animations
These are no longer needed as animations are a purely
runtime concept.
2017-10-04 16:20:55 -07:00
Vikram Subramanian fbc9537952 perf(compiler): fix perf issue in loading aot summaries in jit compiler
The current `flattenSummaries` function re-process the same NgModule
summary even if it has been processed before. Certain modules like
CommonModule are repeated multiple times in the module tree and it is
expanded out every time.

This was making unit tests using AOT summaries really slow. This will
also slow down JIT bootstrap applications that load AOT summaries for
component libraries.

The fix is to remember which summaries were seen before and not to
process them again.
2017-10-04 15:04:23 -07:00
Victor Berchet 0833b59aab refactor(core): add a checkIndex to the compiler view nodes
Each node now has two index: nodeIndex and checkIndex.

nodeIndex is the index in both the view definition and the view data.
checkIndex is the index in in the update function (update directives and update
renderer).

While nodeIndex and checkIndex have the same value for now, having both of them
will allow changing the structure of view definition after compilation (ie for
runtime translations).
2017-10-04 14:55:54 -07:00
Chuck Jazdzewski f3f4c3d835 fix(compiler): disallow references for select and index evaluation
Also fixes an issue where enum values of 0 or '``' where not treated
correctly.

Fixes: #18170
2017-10-04 14:54:39 -07:00
Tobias Bosch 745b59f49c perf(compiler): only emit changed files for incremental compilation
For now, we always create all generated files, but diff them
before we pass them to TypeScript.

For the user files, we compare the programs and only emit changed
TypeScript files.

This also adds more diagnostic messages if the `—diagnostics` flag
is passed to the command line.
2017-10-02 08:24:50 -07:00
Tobias Bosch b0868915ae perf(compiler): don’t emit summaries for jit by default
This re-adds the flag `enableSummariesForJit` to the compiler options
that already existed in Angular 4.
2017-10-02 08:24:50 -07:00
Tobias Bosch ec2be5dccb fix(compiler): allow to use flat modules and summaries
The combination of flat modules, flat module redirects and summaries
lead to errors before.
2017-09-28 14:20:20 -07:00
Chuck Jazdzewski ff5b050a92 fix(compiler): correctly map error message locations (#19424) 2017-09-28 10:53:04 -07:00
Chuck Jazdzewski b3db3f80ba fix(compiler): do not consider a reference with members as a reference (#19454)
Fixes: #18170
2017-09-28 10:52:52 -07:00
Chuck Jazdzewski c1b029a413 fix(language-service): do not report errors for `OpaqueToken` (#19427)
`OpaqueToken` was removed from angular but the language-service
should not report errors when it is used for older versions of
angular.
2017-09-28 09:30:34 -07:00
Alex Eagle 82e49230ff build: Give names to the AMD modules nested in Angular UMD distro (#19425) 2017-09-28 09:29:22 -07:00
Chuck Jazdzewski dfb8d21ef4 feat(compiler): enabled strict checking of parameters to an `@Injectable` (#19412)
Added the compiler options `strictInjectionParameters` that defaults
to `false`. If enabled the compiler will report errors for parameters
of an `@Injectable` that cannot be determined instead of generating a
warning.

This is planned to be switched to default to `true` for Angular 6.0.
2017-09-26 13:40:47 -07:00
Chuck Jazdzewski a75040d0a1 refactor(compiler): bump metadata version to 4 (#19338)
Also adds auto upgrade from lower version based
on the .d.ts file (e.g. from version 3 to 4).

This is needed as we are now also capturing type aliases
in metadata files (and we rely on this),
see 6e3498ca8e.
2017-09-26 13:31:59 -07:00
Chuck Jazdzewski f57b7df4d7 fix(compiler): remove deprecated `Compiler.ngGetContentSelectors()` (#19347)
BREAKING CHANGE:

The method `ngGetConentSelectors()`, deprecated in Angular 4.0, has been
removed.

Use `ComponentFactory.ngContentSelectors` instead.
2017-09-26 10:18:10 -07:00
Tobias Bosch e31a76ce24 fix(compiler): allow to use lowering with `export *`.
Previously, we generated incorrect code when a file
had lowerings and also exported another file via `export *`
that also had lowerings in it.
2017-09-25 13:36:00 -07:00
Tobias Bosch a8a9660112 fix(compiler): various squashed fixes for the new ngc
introduce the option `allowEmptyCodegenFiles` to generate all generated files,
even if they are empty.
- also provides the original source files from which the file was generated
  in the write file callback
- needed e.g. for G3 when copying over pinto mod names from the original component
  to all generated files

use `importAs` from flat modules when writing summaries
- i.e. prevents incorrect entries like @angular/common/common in the .ngsummary.json files.

change interaction between ng and ts to prevent race conditions
- before Angular would rely on TS to first read the file for which we generate files,
  and then the generated files. However, this can break easily when we reuse an old program.

don’t generate files for sources that are outside of `rootDir`
(see #19337)
2017-09-25 13:36:00 -07:00
Pawel Kozlowski 13613d4acb fix(compiler): skip &nbsp; when trimming / removing whitespaces (#19310)
Fixes #19304
2017-09-25 13:33:31 -07:00
Alex Eagle 9ad4b3bd31 build: update to latest @bazel/typescript (#19277)
Switches devmode output of an ng_module to UMD
2017-09-25 12:40:22 -07:00
Olivier Combe 0f5c70d563 build: update npm dependencies (#19328)
PR Close #19328
2017-09-22 13:20:52 -07:00
Chuck Jazdzewski f96142cd7c build: remove references to `tsc-wrapped` (#19298)
With this commit `ngc` is used instead of `tsc-wrapped` for
collecting metadata and tsickle rewriting and `tsc-wrapped`
is removed from the repository.

`@angular/tsc-wrapped@5` is now deprecated and is no longer
used, updated, or maintained as part as of Angular 5.x.x.

`@angular/tsc-wrapped@4` is still maintained and required by
Angular 4.x.x and will be maintained as long as 4.x.x is in
LTS.

PR Close #19298
2017-09-21 13:55:52 -07:00
Tobias Bosch 1a647c399b fix(compiler): also create `.ngfactory.js` files in non obvious cases (#19301)
E.g. when an exported class contains a ctor argument which is
from another compilation unit.

PR Close #19301
2017-09-21 09:59:40 -07:00
Tobias Bosch 04997c8418 fix(compiler): don’t type check property access of literal maps (#19301)
This was the behavior in Ng4, so we put the stricter
check behind the `fullTemplateTypeCheck` flag.
PR Close #19301
2017-09-21 09:59:40 -07:00
Victor Berchet 34fdb91899 refactor(compiler): misc minor refactor / cleanup (#19189)
PR Close #19189
2017-09-20 13:50:25 -07:00
Olivier Combe bc0750eb93 refactor(compiler): update i18n comments deprecation message (#19215)
PR Close #19215
2017-09-20 12:37:06 -07:00
Jason Aden 15e8d50313 build: roll up to named .js files rather than 'index.js' (#19190)
PR Close #19190
2017-09-19 16:59:18 -07:00
Tobias Bosch edd5f5a333 perf(compiler): make the creation of `ts.Program` faster. (#19275)
We now create 2 programs with exactly the same fileNames and
exactly the same `import` / `export` declarations,
allowing TS to reuse the structure of first program
completely. When passing in an oldProgram and the files didn’t change,
TS can also reuse the old program completely.

This is possible buy adding generated files to TS
in `host.geSourceFile` via `ts.SourceFile.referencedFiles`.

This commit also:
- has a minor side effect on how we generate shared stylesheets:
  - previously every import in a stylesheet would generate a new
    `.ngstyles.ts` file.
  - now, we only generate 1 `.ngstyles.ts` file per entry in `@Component.styleUrls`.
  This was required as we need to be able to determine the program files
  without loading the resources (which can be async).
- makes all angular related methods in `CompilerHost`
  optional, allowing to just use a regular `ts.CompilerHost` as `CompilerHost`.
- simplifies the logic around `Compiler.analyzeNgModules` by introducing `NgAnalyzedFile`.

Perf impact: 1.5s improvement in compiling angular io
PR Close #19275
2017-09-19 16:55:23 -07:00
Yuan Gao 0c44e733ad refactor(core): remove readonly getters in common, compiler (#19150)
PR Close #19150
2017-09-14 13:37:52 -04:00
Tobias Bosch 996c7c2dde feat(compiler): reuse the TypeScript typecheck for template typechecking. (#19152)
This speeds up the compilation process significantly.

Also introduces a new option `fullTemplateTypeCheck` to do more checks in templates:
- check expressions inside of templatized content (e.g. inside of `<div *ngIf>`).
- check the arguments of calls to the `transform` function of pipes
- check references to directives that were exposed as variables via `exportAs`
PR Close #19152
2017-09-14 13:37:08 -04:00
Matias Niemelä 4695c69cf1 refactor(compiler): remove all source-level traces to tsc-wrapped (#18966)
- temporarily keeps the old sources under packages/tsc-wrapped
  until the build scripts are changed to use compiler-cli everywhere.
- removes the compiler options `disableTransformerPipeline` that was introduced
  in a previous beta of Angular 5, i.e. the transformer based compiler
  is now always enabled.

PR Close #18966
2017-09-13 20:47:37 -04:00
Tobias Bosch bf94f878bc refactor(compiler): use new ngc for i18n (#19095)
This also changes ngc to support all tsc command line arguments.
PR Close #19095
2017-09-12 18:55:32 -04:00
Kara Erickson c8f742e288 test(packaging): added test for source map correctness 2017-09-12 16:59:32 -04:00
Olivier Combe c056b8c7f1 fix(tsc-wrapped): deduplicate metadata for re-exported modules 2017-09-07 14:21:25 -04:00
Olivier Combe b56dd32454 refactor(compiler): update template parse error message to ng-template (#19029)
PR Close #19029
2017-09-05 15:34:28 -05:00
Olivier Combe 66a5dab85a feat(compiler): deprecate i18n comments in favor of `ng-container` (#18998)
PR Close #18998
2017-09-05 15:33:29 -05:00
Olivier Combe 3c4eef8a86 refactor(core): remove deprecated `OpaqueToken` (#18971)
BREAKING CHANGE: `OpaqueToken` has been removed as it was deprecated since v4. Use `InjectionToken` instead.
PR Close #18971
2017-09-01 16:29:47 -05:00
Olivier Combe 56238fe94e feat(compiler): set `enableLegacyTemplate` to false by default (#18756)
BREAKING CHANGE: the compiler option `enableLegacyTemplate` is now disabled by default as the `<template>` element has been deprecated since v4. Use `<ng-template>` instead. The option `enableLegacyTemplate` and the `<template>` element will both be removed in Angular v6.
PR Close #18756
2017-08-31 18:38:34 -07:00
Jason Aden fd701b07f0 build: publish tree of files rather than FESMs (#18541)
* Remove now unnecessary portions of build.
* Add a compilePackageES5 method to build ES5 from sources
* Rework all package.json and rollup config files to new format
* Remove "extends" from tsconfig-build.json files and fixup compilation roots

PR Close #18541
2017-08-31 15:34:50 -07:00
Tobias Bosch f1e526f046 fix(compiler): use either summary or metadata information when reading .d.ts files (#18912)
This fix applies for getting all symbols in file.

PR Close #18912
2017-08-31 13:27:55 -07:00
Chuck Jazdzewski cf7d47dda0 feat(compiler-cli): add watch mode to `ngc` (#18818)
With this change ngc now accepts a `-w` or a `--watch`
command-line option that will automatically perform a
recompile whenever any source files change on disk.

PR Close #18818
2017-08-31 09:46:24 -07:00
Chuck Jazdzewski 0e64261f26 feat(compiler-cli): lower metadata `useValue` and `data` literal fields (#18905)
With this commit the compiler will "lower" expressions into exported
variables for values the compiler does not need to know statically
in order to be able to generate a factory. For example:

```
  providers: [{provider: 'token', useValue: calculated()}]
```

produced an error as the expression `calculated()` is not supported
by the compiler because `calculated` is not a
[known function](https://angular.io/guide/metadata#annotationsdecorators)

With this commit this is rewritten, during emit of the .js file, into
something like:

```
export var ɵ0 = calculated();

  ...

  provdiers: [{provider: 'token', useValue: ɵ0}]
```

The compiler then will now generate a reference to the exported `ɵ0`
instead of failing to evaluate `calculated()`.

PR Close #18905
2017-08-31 09:46:16 -07:00
Jason Aden c7e1bda32f Revert "feat(compiler-cli): lower metadata `useValue` and `data` literal fields (#18905)"
This reverts commit c685cc2f0a.
2017-08-30 19:02:17 -07:00
Jason Aden 3a6d270bb8 Revert "feat(compiler-cli): add watch mode to `ngc` (#18818)"
This reverts commit 06d01b2287.
2017-08-30 19:02:03 -07:00
Chuck Jazdzewski 06d01b2287 feat(compiler-cli): add watch mode to `ngc` (#18818)
With this change ngc now accepts a `-w` or a `--watch`
command-line option that will automatically perform a
recompile whenever any source files change on disk.

PR Close #18818
2017-08-30 18:00:52 -07:00
Chuck Jazdzewski c685cc2f0a feat(compiler-cli): lower metadata `useValue` and `data` literal fields (#18905)
With this commit the compiler will "lower" expressions into exported
variables for values the compiler does not need to know statically
in order to be able to generate a factory. For example:

```
  providers: [{provider: 'token', useValue: calculated()}]
```

produced an error as the expression `calculated()` is not supported
by the compiler because `calculated` is not a
[known function](https://angular.io/guide/metadata#annotationsdecorators)

With this commit this is rewritten, during emit of the .js file, into
something like:

```
export var ɵ0 = calculated();

  ...

  provdiers: [{provider: 'token', useValue: ɵ0}]
```

The compiler then will now generate a reference to the exported `ɵ0`
instead of failing to evaluate `calculated()`.

PR Close #18905
2017-08-30 18:00:38 -07:00
Victor Berchet 043f104738 fix(compiler): normalize the locale name (#18963) 2017-08-30 17:33:26 -07:00
Tobias Bosch 8c858d76dd fix(compiler): don’t reexport types in `.ngfactory` files (#18788)
This is needed as the typescript no longer elides type reexports
in the generated code when using transformers.

A nice side effect is that this make summaries shorter and produces
less reexports as we rollup reexports.

PR Close #18788
2017-08-28 18:46:43 -05:00
Tobias Bosch f83b819bea fix(compiler): always check summaries first before falling back to metadata from .d.ts files (#18788)
PR Close #18788
2017-08-28 18:46:43 -05:00
Tobias Bosch 0262e37301 fix(compiler): always emit ngfactories with reexports (#18788)
Previously, we only did this when setting the `generateCodeForLibraries: false`.

This is needed so that libraries compiled with `generateCodeForLibraries: true` can be used as dependencies of other compilation units.

PR Close #18788
2017-08-28 18:46:43 -05:00
Matias Niemelä 2159342038 feat(animations): allow @.disabled property to work without an expression (#18713)
PR Close #18713
2017-08-18 23:28:04 -05:00
Pawel Kozlowski 7d72d0eb9b refactor(compiler): align &ngsp; handling with Angular Dart implementation (#18774)
PR Close #18774
2017-08-18 17:13:15 -05:00
Tobias Bosch 7bfd850493 refactor(compiler): add missing test to compare core and compiler metadata (#18739)
PR Close #18739
2017-08-17 18:00:55 -05:00
Tobias Bosch 0cc77b4a69 refactor(compiler): split compiler and core (#18683)
After this, neither @angular/compiler nor @angular/comnpiler-cli depend
on @angular/core.

This add a duplication of some interfaces and enums which is stored
in @angular/compiler/src/core.ts

BREAKING CHANGE:
- `@angular/platform-server` now additionally depends on
  `@angular/platform-browser-dynamic` as a peer dependency.


PR Close #18683
2017-08-16 17:58:53 -05:00
Jeremy Elbourn 3a500981ef feat(compiler): allow multiple exportAs names
This change allows users to specify multiple exportAs names for a
directive by giving a comma-delimited list inside the string.

The primary motivation for this change is to allow these names to be
changed in a backwards compatible way.
2017-08-16 15:31:48 -07:00
Tobias Bosch 43226cb93d feat(compiler): use typescript for resolving resource paths
This can also be customized via the new method `resourceNameToFileName` in the
`CompilerHost`.
2017-08-16 15:24:48 -07:00
Tobias Bosch 2572bf508f feat(compiler): make `.ngsummary.json` files portable
This also allows to customize the filePaths in `.ngsummary.json` file
via the new methods `toSummaryFileName` and `fromSummaryFileName`
on the `CompilerHost`.
2017-08-16 15:24:48 -07:00
Tobias Bosch 6a1ab61cce refactor(compiler): simplify the `CompilerHost` used for transformers
- remove unneeded methods (`getNgCanonicalFileName`, `assumeFileExists`)
- simplify moduleName <-> fileName conversion logic as we don’t need to
  account for `genDir` anymore.
- rename `createNgCompilerHost` -> `createCompilerHost`
2017-08-16 15:24:48 -07:00
Zhicheng Wang 64b4be9670 fix(compiler): Don't strip CSS source maps
Fix CSS source mapping for component by keeping `/*# sourceMappingURL= ... */` and  `/*# sourceURL= ... */` comments.

Relates to <https://github.com/angular/angular-cli/issues/4199>.
2017-08-15 16:30:09 -07:00
Pawel Kozlowski d2c0d986d4 perf(core): add option to remove blank text nodes from compiled templates 2017-08-14 13:26:16 -07:00