Commit Graph

15511 Commits

Author SHA1 Message Date
Paul Gschwendtner 6f5f481fda refactor(core): undecorated-classes-with-di migration should ignore referenced resources (#32953)
Currently the undecorated-classes-with-di migration leverages NGC in order
to work with metadata resolution. Since NGC by default tries to resolve referenced
resources on initialization of the underlying TS program, it can result in unexpected
migration failures due to missing resource files.

This is especially an issue since the CLI wraps the `AngularCompilerProgram` with
special logic (i.e. to support SCSS preprocessing etc.). We don't have all of this since
we instantiate a vanilla NGC program.

The solution to the problem is to simply treat resource requests as valid, and returning
a fake content. The migration is not dependent on templates or stylesheets.. so it's the
simplest and most robust solution.

Fixes #32826

PR Close #32953
2019-10-02 14:54:33 -07:00
Paul Gschwendtner 90dda5873a test(core): remove "enableIvy" compiler option from migration tests (#32954)
ec4381d explicitly set `enableIvy: false` for all migrations inside
the core package. This actually hides migration issues because the
migration itself should ensure that it instantiates the right
compiler program if it relies on `@angular/compiler-cli`.

We should remove these options from all migration tests to
ensure that we catch issues with migrations running in version
9 where Ivy is enabled by default.

e.g. e5636a322c
was accidentally hidden due to the `enableIvy: false` option.

PR Close #32954
2019-10-02 14:53:41 -07:00
Paul Gschwendtner 7503e3540d refactor(core): static-queries migration should never use ngtsc (#32954)
ec4381d enabled Ivy by default. This is problematic as migrations
like `static-queries` depend on the `AngularCompilerProgram` (NGC)
in order to perform the migration from version 7 to version 8.

In order to ensure that the migration always runs with NGC
(and doesn't get the `NgtscProgram`), we need to explicitly disable
ivy when creating the `@angular/compiler-cli` program for the migration.

This code is still relevant even though the update from version 7
to version 8 landed. Developers can run `ng update` from version 7
and immediately get to version 9 where Ivy is enabled by default (and in
that case we need to ensure that ngtsc is not accidentally used).

Similar to
e5636a322c.

PR Close #32954
2019-10-02 14:53:41 -07:00
Pete Bacon Darwin 32e315755b test(ivy): add runtime translations to integration test app (#32867)
PR Close #32867
2019-10-02 14:52:00 -07:00
Pete Bacon Darwin 9188751adc fix(ivy): i18n - do not render message ids unnecessarily (#32867)
In an attempt to be compatible with previous translation files
the Angular compiler was generating instructions that always
included the message id. This was because it was not possible
to accurately re-generate the id from the calls to `$localize()` alone.

In line with https://hackmd.io/EQF4_-atSXK4XWg8eAha2g this
commit changes the compiler so that it only renders ids if they are
"custom" ones provided by the template author.

NOTE:

When translating messages generated by the Angular compiler
from i18n tags in templates, the `$localize.translate()` function
will compute message ids, if no custom id is provided, using a
common digest function that only relies upon the information
available in the `$localize()` calls.

This computed message id will not be the same as the message
ids stored in legacy translation files. Such files will need to be
migrated to use the new common digest function.

This only affects developers who have been trialling `$localize`, have
been calling `loadTranslations()`, and are not exclusively using custom
ids in their templates.

PR Close #32867
2019-10-02 14:52:00 -07:00
Pete Bacon Darwin d24ade91b8 fix(ivy): i18n - support colons in $localize metadata (#32867)
Metadata blocks are delimited by colons. Previously the code naively just
looked for the next colon in the string as the end marker.

This commit supports escaping colons within the metadata content.
The Angular compiler has been updated to add escaping as required.

PR Close #32867
2019-10-02 14:52:00 -07:00
Pete Bacon Darwin 9b15588188 refactor(ivy): i18n - move marker block serialization to helpers (#32867)
Previously the metadata and placeholder blocks were serialized in
a variety of places. Moreover the code for creating the `LocalizedString`
AST node was doing serialization, which break the separation of concerns.

Now this is all done by the code that renders the AST and is refactored into
helper functions to avoid repeating the behaviour.

PR Close #32867
2019-10-02 14:52:00 -07:00
Pete Bacon Darwin 97d5700456 fix(ivy): i18n - better translation warnings (#32867)
The missing translation and invalid placeholder warnings now contain the
"meaning" if one was provided.

PR Close #32867
2019-10-02 14:52:00 -07:00
Pete Bacon Darwin 601f87c2ec fix(ivy): i18n - throw an error if a translation contains an invalid placeholder (#32867)
Previously if a translation contains a placeholder that
does not exist in the message being translated, that
placeholder is evaluated as `undefined`.

Translations should never contain such placeholder names
so now `translate` will throw a helpful error in instead.

PR Close #32867
2019-10-02 14:52:00 -07:00
Showtim3 052cae6427 docs: fix typo in attribute-directives.md (#32943)
Fixes #32924

PR Close #32943
2019-10-02 14:30:50 -07:00
Jakub Pawlot e7729b6863 docs: add comment about newEvent utility function (#32001)
PR Close #32001
2019-10-02 13:28:38 -07:00
ayazhafiz 0d186dda35 feat(language-service): module definitions on directive hover (#32763)
Adds information about the NgModule a Directive is declared in when the
Directive class name is hovered over, in the form

```
(directive) NgModule.Directive: class
```

Closes #32565

PR Close #32763
2019-10-02 13:26:30 -07:00
Kai Röder 3de59d48b5 docs(docs-infra): use recommended type assertion (#31042)
Angular uses tslint:recommended by default. The default for no-angle-bracket-type-assertion is true
See https://github.com/palantir/tslint/blob/master/src/configs/recommended.ts#L69

PR Close #31042
2019-10-02 13:25:39 -07:00
Nikita Potapenko 3c7ac5f835 docs: add ngOnInit description (#32789)
PR Close #32789
2019-10-02 13:24:30 -07:00
Kara Erickson 41ed694d01 ci: update size benchmarks for core with 9.0.0-next.8 (#32947)
PR Close #32947
2019-10-02 13:22:36 -07:00
Paul Gschwendtner 954b8e53a2 refactor(bazel): ng_module action description should include compile mode (#32955)
Similarly to `ts_library` compilation actions, the `ng_module` compile action should include
the current compile mode in the action description. This makes it consistent with `ts_library`
targets and also avoids confusion when both output flavors are requested.

Currently when both output flavors are requested (e.g. in the `ng_package` rule), both
devmode and prodmode compilations have the same action name. This is confusing and
looks like the given target is built *twice* due to a bug (which is obviously not the case though)

PR Close #32955
2019-10-02 13:21:40 -07:00
Stephen Fluin a3b6b109d8 docs: fix stackblitz example polyfills (#32969)
PR Close #32969
2019-10-02 13:20:37 -07:00
crisbeto 4e35e348af refactor(ivy): generate ngFactoryDef for injectables (#32433)
With #31953 we moved the factories for components, directives and pipes into a new field called `ngFactoryDef`, however I decided not to do it for injectables, because they needed some extra logic. These changes set up the `ngFactoryDef` for injectables as well.

For reference, the extra logic mentioned above is that for injectables we have two code paths:

1. For injectables that don't configure how they should be instantiated, we create a `factory` that proxies to `ngFactoryDef`:

```
// Source
@Injectable()
class Service {}

// Output
class Service {
  static ngInjectableDef = defineInjectable({
    factory: () => Service.ngFactoryFn(),
  });

  static ngFactoryFn: (t) => new (t || Service)();
}
```

2. For injectables that do configure how they're created, we keep the `ngFactoryDef` and generate the factory based on the metadata:

```
// Source
@Injectable({
  useValue: DEFAULT_IMPL,
})
class Service {}

// Output
export class Service {
  static ngInjectableDef = defineInjectable({
    factory: () => DEFAULT_IMPL,
  });

  static ngFactoryFn: (t) => new (t || Service)();
}
```

PR Close #32433
2019-10-02 13:04:26 -07:00
atscott 2729747225 release: cut the v9.0.0-next.9 release 2019-10-02 11:43:00 -07:00
atscott be83ae752e docs: release notes for the v8.2.9 release 2019-10-02 11:34:17 -07:00
Judy Bogart 70429bf350 docs: add lib build note (#32940)
PR Close #32940
2019-10-02 10:59:05 -07:00
Niklas Merz add5c3992c docs(router): fix typo for "urlUpdateStrategy" (#32960)
PR Close #32960
2019-10-02 10:58:40 -07:00
atscott 04bfe87764 Revert "feat(core): default to dynamic queries (#32720)" (#32966)
This reverts commit 948b01ce55.

PR Close #32966
2019-10-02 10:40:24 -07:00
atscott 879ad69602 Revert "feat(core): make static query flag optional (#32686)" (#32965)
This reverts commit 25219baeb4.

PR Close #32965
2019-10-02 10:39:49 -07:00
Alison Gale 39e8ceb2cd fix(upgrade): fix AngularJsUrlCodec to support Safari (#32959)
Safari throws an error when the new URL() constructor is called with an
undefined base. This change checks whether the base is undefined and
then calls the corresponding version of the URL constructor.

fix(upgrade): simplify solution by replacing undefined with ''

Co-Authored-By: Pete Bacon Darwin <pete@bacondarwin.com>

Simplify solution by replacing undefined with ''

Co-Authored-By: Pete Bacon Darwin <pete@bacondarwin.com>

fix(upgrade): Avoid passing an empty string as the base as well.

Browsers other than Safari may have issues with the empty string.

PR Close #32959
2019-10-02 10:00:47 -07:00
Jordan Amman 448749cafa docs: added '>' to ng-template closing tag. (#32939)
Fixes #32931

PR Close #32939
2019-10-02 09:44:23 -07:00
crisbeto 25219baeb4 feat(core): make static query flag optional (#32686)
Switches back to having the `static` flag be optional on `ViewChild` and `ContentChild` queries, in preparation for changing its default value.

PR Close #32686
2019-10-02 09:39:05 -07:00
crisbeto 948b01ce55 feat(core): default to dynamic queries (#32720)
These changes switch to defaulting the `static` flag on `ViewChild` and `ContentChild` queries to `false`, in addition to removing the logic that statically determines whether a query is dynamic.

PR Close #32720
2019-10-02 09:38:21 -07:00
Filipe Silva 0f3a48e4d4 ci: refactor notification commands into a single parametrized one (#32745)
notify_caretaker_on_fail and notify_dev_infra_on_fail are the same, except for the url they notify.

PR Close #32745
2019-10-02 09:34:12 -07:00
Filipe Silva 653eb0fef9 ci: use workspaces and cache for Windows jobs (#32745)
Making use of these functionalities lets our Windows jobs be more similar to the Linux ones, and draw common artifacts from them too.

PR Close #32745
2019-10-02 09:34:12 -07:00
Filipe Silva fc3260d87e ci: use CircleCI parameterized jobs (#32745)
Parameterized jobs lets us reduce duplication of very similar jobs.

See https://circleci.com/docs/2.0/reusing-config/#authoring-parameterized-jobs for more info.

PR Close #32745
2019-10-02 09:34:11 -07:00
Filipe Silva 296954041e ci: use CircleCI commands (#32745)
When we needed to run multiple commands in a reusable fashion, we needed to make a giant run block with multiple things inside. Using custom commands gives us a better way to do this.

See https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-commands for more info.

PR Close #32745
2019-10-02 09:34:11 -07:00
Filipe Silva 1115961892 ci: keep cache key fallback in a var (#32745)
This way it's right next to the original key and it's easier to keep them in sync.

PR Close #32745
2019-10-02 09:34:11 -07:00
Filipe Silva 6db5c4a6f6 ci: use CircleCI executors (#32745)
Executors let you define custom execution contexts for jobs.

See https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors for more information.

PR Close #32745
2019-10-02 09:34:11 -07:00
Alan Agius 5d5c94d83a feat(service-worker): remove deprecated `versionedFiles` option (#32862)
BREAKING CHANGE:

Remove deprecated option `versionedFiles` from service worker asset group configuration in `ngsw-config.json`

Before
```json
"assetGroups": [
  {
    "name": "test",
    "resources": {
      "versionedFiles": [
        "/**/*.txt"
      ]
    }
  }
]
```

After
```json
"assetGroups": [
  {
    "name": "test",
    "resources": {
      "files": [
        "/**/*.txt"
      ]
    }
  }
]
```

PR Close #32862
2019-10-02 09:30:59 -07:00
George Kalpakas 090732fc2d fix(docs-infra): show hamburger button on getting started guide (#32941)
In 1c3ee4190, the `getting-started` guide/tutorial was renamed to
`start`, but the corresponding CSS class that controls the display of
the top-left hamburger (and it automatically derived based on the URL)
was not updated.

This commit updates the class to ensure that the hamburger is not hidden
when navigating to the getting started guide.

PR Close #32941
2019-10-02 09:20:22 -07:00
Kapunahele Wong 206fb82330 docs: add dynamic queries flag migration documentation (#32582)
PR Close #32582
2019-10-01 17:19:05 -07:00
Andrew Scott 63256b511a fix(ivy): Only restore registered modules if user compiles modules with TestBed (#32944)
There are a couple scenarios that are problematic and need special
handling:

1. A user has a custom implementation of lazy-loaded modules, sets some
provider overrides, then compiles the module so it can be loaded. In a
follow-up test, the user sets different overrides for the module and
then compiles. This is problematic because we need to be sure the module
registered in the first test is not used, so we need to clear it out of
the modules list in `ng_module_factory_registration`.
2. A user has a similar lazy-loaded module factory implementation but
relies on the module being registered automatically. This can happen,
for example, as a side effect of importing the ngfactory file.

PR Close #32944
2019-10-01 17:17:47 -07:00
ayazhafiz 01e4d44e8c fix(language-service): add closing quote in invalid test template (#32785)
Fixes an invalid TypeScript code in the language service tests. I must
have missed this while reviewing previously; sorry about that!

PR Close #32785
2019-10-01 14:57:45 -07:00
Alan Agius 66658c447f feat: update rxjs peerDependencies minimum requirment to 6.5.3 (#32812)
PR Close #32812
2019-10-01 14:56:45 -07:00
Alan Agius 668f57abaa build: update rxjs to 6.5.3 (#32812)
PR Close #32812
2019-10-01 14:56:45 -07:00
Andrew Scott 72f3747d7b fix(ivy): refresh child components before executing ViewQuery function (#32922)
Child component refresh must happen before executing the ViewQueryFn because
child components could insert a template from the host that contains the result
of the ViewQuery function (see related test added in this PR).

PR Close #32922
2019-10-01 14:47:15 -07:00
Judy Bogart 088435c5eb docs: emphasize headers for code examples (#32938)
PR Close #32938
2019-10-01 14:45:29 -07:00
Joshua Colvin 32b6548be9 docs: fix capitalization in elements docs (#32917) (#32936)
PR Close #32917

PR Close #32936
2019-10-01 14:44:49 -07:00
ayazhafiz 98feee7e0e feat(language-service): allow retreiving synchronized analyzed NgModules (#32779)
Sometimes modules retreived from the language service need to be
synchronized to the last time they were updated, and not updated
on-the-fly. This PR adds a flag to
`TypeScriptServiceHost#getAnalyzedModules` that retreives cached
analyzed NgModules rather than potentially recomputing them.

PR Close #32779
2019-10-01 11:02:09 -07:00
Keen Yee Liau 28358b6395 fix(language-service): Turn on strict mode for test project (#32783)
This is the last part in refactoring of the test project.
This PR turns on strict mode for typechecking and fixed tests that
fail under this mode.

PR Close #32783
2019-10-01 11:01:01 -07:00
Judy Bogart 9e7aa60ae7 docs: clarify http response type (#32817)
PR Close #32817
2019-10-01 11:00:36 -07:00
crisbeto ffc34b3676 perf(ivy): avoid repeat global state accesses in i18n instructions (#32916)
Removes repeat global state accesses from the i18n instructions in the cases where we have the information available already.

PR Close #32916
2019-10-01 10:59:27 -07:00
Gérôme Grignon b3549e6680 docs: fix typo in creating-libraries (#32930)
PR Close #32930
2019-10-01 10:59:01 -07:00
Andrew Scott 475e36abb5 fix(ivy): R3TestBed should clean up registered modules after each test (#32872)
PR Close #32872
2019-09-30 15:01:08 -07:00