Commit Graph

198 Commits

Author SHA1 Message Date
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
Miško Hevery fcadbf4bf6 perf: switch angular to use StaticInjector instead of ReflectiveInjector
This change allows ReflectiveInjector to be tree shaken resulting
in not needed Reflect polyfil and smaller bundles.

Code savings for HelloWorld using Closure:

Reflective: bundle.js:  105,864(34,190 gzip)
    Static: bundle.js:  154,889(33,555 gzip)
                            645( 2%)

BREAKING CHANGE:

`platformXXXX()` no longer accepts providers which depend on reflection.
Specifically the method signature when from `Provider[]` to
`StaticProvider[]`.

Example:
Before:
```
[
  MyClass,
  {provide: ClassA, useClass: SubClassA}
]

```

After:
```
[
  {provide: MyClass, deps: [Dep1,...]},
  {provide: ClassA, useClass: SubClassA, deps: [Dep1,...]}
]
```

NOTE: This only applies to platform creation and providers for the JIT
compiler. It does not apply to `@Compotent` or `@NgModule` provides
declarations.

Benchpress note: Previously Benchpress also supported reflective
provides, which now require static providers.

DEPRECATION:

- `ReflectiveInjector` is now deprecated as it will be remove. Use
  `Injector.create` as a replacement.

closes #18496
2017-08-07 15:42:34 -07:00
Marc Laval 1dca575701 fix(compiler): ignore @import in multi-line css (#18452)
Fixes #18038
2017-08-03 11:00:38 -07:00
Chuck Jazdzewski 7c47b62a96 fix(compiler): cleanly compile with TypeScript 2.4 (#18456) 2017-08-02 16:26:42 -07:00
Victor Berchet 9479a106bb build: enable TSLint on the packages folder 2017-07-31 15:47:57 -07:00
Chuck Jazdzewski e64b54b67b fix(compiler): do not consider arguments when determining recursion
The static reflectory check for macro function recursion was too
agressive and disallowed calling a function with argument that also
calls the same function. For example, it disallowed nested animation
groups.

Fixes: #17467
2017-07-31 13:42:31 -07:00
Victor Berchet 381471d338 fix(compiler): fix for element needing implicit parent placed in top-level ng-container
fixes #18314
2017-07-31 11:30:19 -07:00
Olivier Combe 38ec05f533 fix(compiler): add equiv & disp attributes to Xliff2 ICU placeholders (#18283)
Fixes #17344

PR Close #18283
2017-07-25 15:58:53 -05:00
Olivier Combe b3085e96c2 feat(compiler): add representation of placeholders to xliff & xmb
Closes #17345
2017-07-25 15:58:53 -05:00
Alex Eagle 6fc5940959 build: Bazel builds ngfactories for packages/core (#18289)
PR Close #18289
2017-07-21 18:09:47 -05:00
Miško Hevery b7a6f52d59 perf: latest tsickle to tree shake: abstract class methods & interfaces (#18236)
In previous version of tsickle abstract class methods were materialized.
The change resulted in 6Kb savings in angular.io bundle.

This change also required the removal of `@private` and `@return` type
annotation as it is explicitly dissalowed by tsickle.

NOTE: removed casts in front of `makeDecorator` due to:
https://github.com/angular/devkit/issues/45

```
 14938 Jul 19 13:16 0.b19e913fbdd6507d346b.chunk.js
  1535 Jul 19 13:16 inline.d8e019ea3cfdd86c2bd0.bundle.js
589178 Jul 19 13:16 main.54c97bcb6f254776b678.bundle.js
 34333 Jul 19 13:16 polyfills.4a3c9ca9481d53803157.bundle.js

 14938 Jul 18 16:55 0.b19e913fbdd6507d346b.chunk.js
  1535 Jul 18 16:55 inline.0c83abb44fad9a2768a7.bundle.js
582786 Jul 18 16:55 main.ea290db71b051813e156.bundle.js
 34333 Jul 18 16:55 polyfills.4a3c9ca9481d53803157.bundle.js

main savings: 589178 - 582786 = 6,392
```

PR Close #18236
2017-07-21 16:35:37 -05:00
Chuck Jazdzewski abee785821 refactor(tsc-wrapped): update tsc-wrapped to pass strictNullCheck (#18160)
PR Close #18160
2017-07-21 12:26:20 -05:00
Victor Berchet e0a9625e46 test: fix bad merge (#18267)
PR Close #18267
2017-07-21 11:53:34 -05:00
Olivier Combe a3a54299af fix(compiler): allow numbers for ICU message cases in lexer (#18095)
Closes #18095
Fixes #17799
2017-07-20 17:41:54 -05:00
Olivier Combe 65c9e13105 fix(compiler-cli): don't generate empty <target/> when extracting xliff
Fixes #15754
2017-07-19 09:45:52 -07:00
Chuck Jazdzewski 95635c18c7 fix(compiler): ensure jit external id arguments names are unique
Fixes: #17558, #17378, #8676
2017-07-18 10:11:32 -07:00
Chuck Jazdzewski ddb766e456 feat(compiler): do not evaluate metadata expressions that can use references (#18001) 2017-07-13 16:16:56 -07:00
Victor Berchet c723d42d0a refactor: fix typos (#18000) 2017-07-07 16:55:17 -07:00
Victor Berchet 9c1f6fd06f fix(compiler): emits quoted keys only iff they are quoted in the original template
fixes #14292
2017-07-07 16:17:33 -07:00
Victor Berchet 798947efa4 feat(compiler): adds support for quoted object keys in the parser 2017-07-07 16:17:33 -07:00
Victor Berchet 7ae8ad6aab fix(compiler): fix types 2017-07-07 16:17:33 -07:00
Victor Berchet 9c3386b1b7 fix(compiler): remove i18n markup even if no translations (#17999)
Fixes #11042
2017-07-07 16:16:49 -07:00
Victor Berchet dd7c1134e3 feat(compiler): update the schema by extracting from latest chrome (#17858)
adds:
- the slot element,
- the slot attribute on [Element],
- a few other attributes.
2017-07-06 12:11:34 -07:00
Victor Berchet 448d9f9f46 test(compiler): add a test for components not part of any `NgModule` 2017-06-26 13:24:36 -07:00
Chuck Jazdzewski 3097083277 feat(compiler-cli): new compiler api and command-line using TypeScript transformers 2017-06-23 16:18:44 -07:00
Victor Berchet b754e600e3 feat(compiler): add support `::ng-deep`
- /deep/ is deprecated and being removed from Chrome
- >>> is semantically invalid in a stylesheet
- sass will no longer support either in any version of sass

-> use ::ng-deep in emulated shadow DOM mode

Because the deep combinator is deprecated in the CSS spec,
`/deep/`, `>>>` and `::ng-deep` are also deprecated in emulated shadow DOM mode
and will be removed in the future.

see https://www.chromestatus.com/features/6750456638341120
2017-06-23 14:43:42 -07:00
Chuck Jazdzewski 81734cf7b6 refactor(compiler): add tracking comment for self-import detection
The underlying cause of #17386 needs to be investigated and as a
simple string compare should have been valid.
2017-06-23 14:43:24 -07:00
Chuck Jazdzewski 4352dd27c4 fix(compiler): avoid emitting self importing factories
Fixes: #17389
2017-06-21 16:19:43 -07:00
Trotyl Yu 9315ab88d7 test(compiler): fix typo "mamespace" 2017-06-16 11:17:15 -07:00
olegdunkan 93d1b4ed9d refactor(compiler): remove duplicate code 2017-06-13 13:37:33 -07:00
Tobias Bosch 90b0713e32 refactor(compiler): don’t write summaries for jit by default
The default is false externally but true internally at Google.
2017-06-09 15:58:53 -07:00
Georgios Kalpakas 022835bab2 ci: update Chromium to 464641 (Chrome v59) 2017-06-08 09:36:35 -07:00
Alex Eagle b00b80a45b feat(compiler-cli): introduce synchronous codegen API 2017-06-06 14:12:02 -07:00
Chuck Jazdzewski 230255f887 feat(compiler-cli): produce template diagnostics error messages (#17125)
Refactoring the compiler to use transformers moves the code generation
after type-checking which suppresses the errors TypeScript would
generate in the user code.

`TypeChecker` currently produces the same factory code that was
generated prior the switch to transfomers, getting back the same
diagnostics as before. The refactoring will allow the code to
diverge from the factory code and allow better diagnostic error
messages than was previously possible by type-checking the factories.
2017-06-01 10:13:50 -07:00
Andrew Mitchell 8ffa483bb6 fix(compiler): enableLegacyTemplate should not be ignored (#17051)
Fixes #15555
2017-05-30 13:19:42 -07:00
Chuck Jazdzewski 18bf77204e feat(compiler): emit typescript nodes from an output ast (#16823) 2017-05-30 10:43:13 -07:00
Tobias Bosch eba59aaf87 refactor(compiler): add ability to produce stub .ngfactory / .ngsummary files (#16963)
These files are needed so that:
- user code can compile even without real codegen
- as tsc transformers cannot create but only change existing files
  in the transformation pipeline.
2017-05-23 14:40:50 -06:00
Jason Aden fa809ec8cf build: import tslib rather than output TS helpers (#16901) 2017-05-23 14:01:39 -06:00
Chuck Jazdzewski 1651a8f189 fix(tsc-wrapped): ignore `|null` and `|undefined` when collecting types (#16222) 2017-05-23 11:53:38 -06:00
Chuck Jazdzewski 27761b4500 fix(compiler): do not report type errors for arguments with `@Inject` (#16222)
Fixes #15424
2017-05-23 11:53:38 -06:00
Tobias Bosch a80ac0a8d3 fix(core): make decorators closure safe (#16905)
This is required as e.g. `token` from `@Inject` is
accessed in string form via makeParamDecorator
but as a property in the `ReflectiveInjector`.

Closes #16889 as this is a more general fix.
2017-05-23 11:52:40 -06:00
Tobias Bosch 5af143e8e4 refactor(compiler): allow sync AOT compilation (#16832).
AOT compilation can be executed synchronously now,
if the `ReosurceLoader` returns a string directly
(and no `Promise`).
2017-05-23 10:41:23 -06:00
Tobias Bosch 50abca4583 refactor(compiler): don’t rely on global reflector (#16832)
Using the global reflector made it impossible
to compile multiple programs at the same time.
2017-05-23 10:41:23 -06:00
Tobias Bosch de8d7c65f2 refactor(compiler): emit OutputAst and not sources (#16832)
This is in preparation for creating typescript nodes
directly from `OutputAst` nodes.
2017-05-23 10:41:23 -06:00
Tobias Bosch 6123b9c0c6 refactor(compiler): make `OutputAst` contain the moduleName, not the filePath (#16832).
The goal of this change is to simplify the emitters,
as we will soon create a new one to emit TypeScript nodes directly.
2017-05-23 10:41:23 -06:00
Olivier Combe 08dfe91b95 feat(compiler): add location note to extracted xliff2 files (#16791)
Add source location as a note tag as `<note category="location">path/to/file.ts:start_line[,end_line]</note>`.
`[,end_line]` part is optional and specified only if the end line is different from the start line.

Fixes  #16531
2017-05-22 12:20:45 -06:00
Chuck Jazdzewski 9a7f5d580f ci: update build to use TypeScript 2.3.2 (#16707) 2017-05-16 13:29:38 -07:00
Tobias Bosch 5afaa39e68 refactor(compiler): produce more dense generated code (#16666)
This changes the formatting to be less verbose but still
tries to be readable.
2017-05-11 10:28:48 -07:00
Tobias Bosch ce1d7c4a6e refactor: use view engine also for `NgModuleFactory`s (#16658)
* refactor(core): provide error message in stack for reflective DI

Fixes #16355

* fix(compiler): make AOT work with `noUnusedParameters`

Fixes #15532

* refactor: use view engine also for `NgModuleFactory`s

This is a prerequisite for being able to mock providers
in AOTed code later on.
2017-05-11 10:26:02 -07:00
Chuck Jazdzewski b9521b568f feat(compiler): support a non-null postfix assert (#16672)
Template expressions can now use a post-fix `!` operator
that asserts the target of the operator is not null. This is
similar to the TypeScript non-null assert operator. Expressions
generated in factories will be generated with the non-null assert
operator.

Closes: #10855
2017-05-11 10:15:54 -07:00
Chuck Jazdzewski bb0902c592 refactor(compiler-cli): move the expression expression type checker (#16562)
The expression type checker moved from the language service
to the compiler-cli in preparation to using it to check
template expressions.
2017-05-09 16:16:50 -07:00
Martin Probst e0a8376237 fix(compiler): avoid a `...null` spread in extraction (#16547)
This code only runs in ES5 mode in the test suite, so this is difficult to test.
However `updateFromTemplate` is being called with a spread operator, as
`...updateFromTemplate(...)`. The spread operator should fail on `null` values.
This change avoids the problem by always returning a (possibly empty) array.

PR Close #16547
2017-05-08 17:49:43 -05:00
Tobias Bosch 547c363473 feat: add .ngsummary.ts files to support AOT unit tests
Design doc: https://docs.google.com/document/d/1VmTkz0EbEVSWfEEWEvQ5sXyQXSCvtMOw4t7pKU-jOwc/edit?usp=sharing
2017-05-05 13:23:53 -04:00
Tobias Bosch c946a929b7 refactor(compiler): simplify AOT tests 2017-05-02 15:51:54 -07:00
Olivier Combe 6e2abcd5fc feat(compiler-cli): add param to set MissingTranslationStrategy on ngc (#15987)
This commit adds a new parameter to ngc named `missingTranslation`  to set the MissingTranslationStrategy for AoT, it takes the value `error`, `warning` or `ignore`.

Fixes #15808

PR Close #15987
2017-04-27 17:38:59 -05:00
David 745731e1a3 fix(compiler): make I18NHtmlParser provider AoT-compliant (#15980)
PR Close #15980
2017-04-19 22:46:40 -05:00
Miško Hevery 5293794316 fix: turn on nullability in the code base. 2017-04-18 12:07:33 -07:00
Chuck Jazdzewski 38a7e0d1c7 fix(compiler): ignore calls to unresolved symbols in metadata
This only shows up in the language service. Calls to symbols
that are not resolve resulted in null instead of being resolved
causing the language service to see exceptions when the null
was not expected such as in the animations array.

Fixes #15969
2017-04-17 14:36:08 -07:00
Randall Koutnik a77b126d72 fix(compiler): Inform user where Quoted error was thrown 2017-04-17 10:19:09 -07:00
Victor Berchet 5b141fbf27 fix(compiler): support `<ng-container>` whatever the namespace
fixes #14257
2017-04-17 10:14:15 -07:00
Tobias Bosch 86396a43e9 Revert "fix(compiler): ignore calls to unresolved symbols in metadata (#15970)"
This reverts commit ce47d33cd9.
2017-04-14 11:20:12 -07:00
Victor Berchet bd704c90dd fix(compiler): fix build error in xliff2 2017-04-14 11:20:12 -07:00
Olivier Combe 4054055d0d feat(compiler): add source files to xmb/xliff translations (#14705)
Fixes #14190
2017-04-14 09:06:25 -07:00
Panuruj Khambanonda (PK) 09c4cb2540 feat(compiler): Implement i18n XLIFF 2.0 serializer (#14185)
- Ensure that the result passes OASIS XLIFF 2.0 schema validation
- Use <ph/> for self-closing placeholder tags
- Use <pc></pc> for other placeholder tags
- Check for the correct XLIFF file version
- Add ICU support

fixes #11735
2017-04-14 09:05:00 -07:00
Chuck Jazdzewski ce47d33cd9 fix(compiler): ignore calls to unresolved symbols in metadata (#15970)
This only shows up in the language service. Calls to symbols
that are not resolve resulted in null instead of being resolved
causing the language service to see exceptions when the null
was not expected such as in the animations array.

Fixes #15969
2017-04-14 09:02:32 -07:00
Victor Berchet fdb3f26448 refactor(compiler): cleanup (#15960) 2017-04-13 11:56:00 -07:00
Miško Hevery 540581da3e fix(language-service): Update types for TypeScript nullability support 2017-04-12 11:36:19 -07:00
Miško Hevery 09d9f5fe54 fix(compiler): Update types for TypeScript nullability support 2017-04-10 15:26:33 -06:00
Chuck Jazdzewski 7764c5c697 fix(language-service): avoid throwing exceptions when reporting metadata errors 2017-04-04 14:11:51 -06:00
Tobias Bosch 8ef621ad2a fix(compiler): fix inheritance for AOT with summaries (#15583)
Allows to inherit ctor args, lifecycle hooks and statics from a class
in another compilation unit. 
Will error if trying to inherit from a class in another compilation unit 
that has an `@Component` / `@Directive` / `@Pipe` / `@NgModule`.
2017-03-30 14:51:29 -07:00
Dzmitry Shylovich 9c77a7cdaf fix(compiler): throw when a component defines both template and templateUrl (#15572)
Closes #15566
2017-03-29 10:26:48 -07:00
Miško Hevery 910c0d9ee7 fix(core): Update types for TypeScript nullability support (#15472) 2017-03-29 09:34:45 -07:00
Chuck Jazdzewski 6269d28bb0 fix(language-service): improve performance of `updateModuleAnalysis()` (#15543) 2017-03-28 13:32:46 -07:00
Chuck Jazdzewski d438b88f19 fix(compiler): ignore errors when evaluating base classes (#15560)
Fixes #15536
2017-03-28 13:32:34 -07:00
Olivier Combe 53b89ec312 fix(compiler): allow single quotes into named interpolations (#15461)
Fixes #15318
2017-03-24 15:10:41 -07:00
Dzmitry Shylovich c17b912eb9 refactor: use object spread operator rather than merge (#15426) 2017-03-24 14:45:33 -07:00
Marc Laval b8d5f87f96 feat(compiler): support ICU messages in XLIFF
Fixes #12636
Closes #15068
2017-03-24 14:35:28 -07:00
Marc Laval 95afaf495b test(compiler): refactor i18n integration test 2017-03-24 14:35:10 -07:00
Chuck Jazdzewski 0dda01e37c fix(compiler): correctly handle when `toString` is exported (#15430)
Fixes #15420
2017-03-23 13:38:01 -07:00
Tobias Bosch c8ab5cb0c5 fix(compiler): assume queries with no matches as static (#15429)
This has the side effect of allowing `@Input` and `@ContentChild`
on the same property if the query is static (see the bug description
for details).

Fixes #15417
2017-03-23 13:37:45 -07:00