Commit graph

22474 commits

Author SHA1 Message Date
Kristiyan Kostadinov
5dff077d50 feat(core): add migration to remove entryComponents (#44308)
Adds an automated migration that will drop any usages of `entryComponents` from `@NgModule` and `@Component`.

PR Close #44308
2021-11-30 13:47:03 -05:00
Joey Perrott
cd502b76b3 ci: update owners for fw-benchmarks (#44304)
Add alxhub and jelbourn to owners for fw-benchmarks group.

PR Close #44304
2021-11-30 13:45:59 -05:00
Paul Gschwendtner
960068899c build: fix lint errors in build-saucelabs legacy script (#44311)
Fixes lint errors in the build-saucelabs legacy script. Likely this only
surfaces now after merge due to some other lint-affecting changes
landing just before the script landed.

PR Close #44311
2021-11-30 12:23:24 -05:00
Kristiyan Kostadinov
d56e3f43a1 feat(core): support TypeScript 4.5 (#44164)
Adds support for TypeScript 4.5. Includes the following changes:
* Bumping the package versions.
* Fixing a few calls to `createExportSpecifier` and `createImportSpecifier` that require an extra parameter.
* Adding some missing methods to the TS compiler hosts.
* Fixing an issue in the TS mocks for the ngcc tests where a regex was too agressive and was trying to match a path like `/node_modules/@typescript/lib-es5`.
* Accounting for type-only import specifiers when reporting DI errors (see #43620).

Fixes #43620.

PR Close #44164
2021-11-30 11:59:02 -05:00
Paul Gschwendtner
0fcf18d5f4 ci: increase jasmine default timeout for saucelabs legacy tests (#44281)
Previously, when we did not bundle tests, we also had the jasmine
default timeout increased to 15000ms. This commit re-introduces this
increased timeout by also maintaining a custom test init file for the
legacy saucelab jobs. This is desirable as all of the Saucelabs test
code is local in the `tools/legacy-saucelabs` folder.

PR Close #44281
2021-11-30 11:56:05 -05:00
Paul Gschwendtner
444b2c497a test: remove unused router karma legacy setup (#44281)
Removes unused router karma legacy test setup that
just caused unnecessary confusion.

PR Close #44281
2021-11-30 11:56:05 -05:00
Paul Gschwendtner
6c1573bc08 fix(compiler-cli): downlevel transform incorrectly extracting constructor parameters for nested classes (#44281)
The downlevel decorator transform (commonly used in the CLI and other
tooling of the ecosystem for enabling JIT ES2015+), is currently
incorrectly dealing with nested classes.

The transform will accidentally visit nested classes (in a constructor)
multiple times and generate duplicated instances of the `ctorParameters`
fields. This does not sound like an issue at first, but the duplicated
`ctorParameters` fields will miss significant type information that has
been elided by the first visit, resulting in generated code like the
following:

```js
      let MyClass = /* @__PURE__ */ __name(class MyClass extends UpgradeNg1ComponentAdapter {
        constructor(scope, injector3, elementRef) {
        }
      }, "MyClass");
      MyClass.ctorParameters = () => [
        { type: void 0, decorators: [{ type: Inject, args: [$SCOPE] }] },
        { type: Injector },
        { type: ElementRef }
      ];
      MyClass.ctorParameters = () => [
        { type: void 0 }, // <---- NOTE!
        { type: Injector },
        { type: ElementRef }
      ];
```

PR Close #44281
2021-11-30 11:56:05 -05:00
Paul Gschwendtner
a87fcaaabb test: re-add downlevel decorator transform test (#44281)
Re-adds the accidentally deleted downlevel decorator transform test.

PR Close #44281
2021-11-30 11:56:05 -05:00
Paul Gschwendtner
43dfab447d fix(core): destroy hooks not set up for useClass provider using forwardRef (#44281)
Fixes an issue where destroy hooks are not set up for `useClass` providers
that rely on `forwardRef` for passing the actual class reference.

Currently the destroy hooks are not captured because forward refs are
not resolved for class providers. In ES2015+ this issue becomes even
more critical if arrow-functions are used for

e.g. `useClass: () => forwardRef(..)`.

This is because arrow functions do not have a prototype, unlike in ES5
where the function assigned to `useClass` would always have a prototype.
In ES2015+ a runtime exception as followed is returned (and doesn't give
any useful indication of the forwardRef issue):

```
TypeError: Cannot read properties of undefined (reading 'ngOnDestroy')
  at registerDestroyHooksIfSupported (dist/packages/core/src/render3/di_setup.ts:196:35 <- dist/legacy-test-bundle.spec.js:41508:37)
  at resolveProvider (dist/packages/core/src/render3/di_setup.ts:153:9 <- dist/legacy-test-bundle.spec.js:41485:11)
  at resolveProvider (dist/packages/core/src/render3/di_setup.ts:70:7 <- dist/legacy-test-bundle.spec.js:41445:9)
  at providersResolver (dist/packages/core/src/render3/di_setup.ts:54:5 <- dist/legacy-test-bundle.spec.js:41438:7)
  at Object.definition.providersResolver (dist/packages/core/src/render3/features/providers_feature.ts:48:18 <- dist/legacy-test-bundle.spec.js:41600:16)
  at resolveDirectives (dist/packages/core/src/render3/instructions/shared.ts:1179:40 <- dist/legacy-test-bundle.spec.js:35611:17)
  at elementStartFirstCreatePass (dist/packages/core/src/render3/instructions/element.ts:40:7 <- dist/legacy-test-bundle.spec.js:38432:27)
  at ɵɵelementStart (dist/packages/core/src/render3/instructions/element.ts:87:7 <- dist/legacy-test-bundle.spec.js:38453:43)
  at ɵɵelement (dist/packages/core/src/render3/instructions/element.ts:180:3 <- dist/legacy-test-bundle.spec.js:38510:5)
  at MultipleFormControls_Template (ng:///MultipleFormControls.js:9:9)
```

PR Close #44281
2021-11-30 11:56:05 -05:00
Paul Gschwendtner
b23ce150d0 build: bundle spec files for saucelabs legacy job (#44281)
Bundle spec files similar to how it is done within the Angular
Components repo. This should simplify the setup and also speed
up the Saucelab job as only a single spec bundle would need to be
downloaded, compared to having to load hundreds of files through the
Saucelabs tunnel.

Also makes a couple of tests more robust with the emulators/and accounts
for ES2015 test runner changes. The tests should be less reluctant to
such build process changes.

Note for reviewers: Some imports have been simplified here. This work
came from Joey's original WIP for this. It's unclear to me whether this
is still needed, but it sounded like this was necessary for the ESBuild
bundling to work. I have robusted the module resolution plugin though,
so I doubt it's still needed. At the same time though: Not worth
reverting/trying as these changes are nice to have anyway!

Co-Authored-By: Joey Perrott <josephperrott@gmail.com>
Co-Authored-By: Paul Gschwendtner <paulgschwendtner@gmail.com>

PR Close #44281
2021-11-30 11:56:04 -05:00
Paul Gschwendtner
61e023488e ci: attempt to increase stability of saucelabs legacy job (#44281)
This is an attempt to increase the stability of the Saucelabs legacy
job by using an emulator recommended by the Saucelabs platform
configurator, explicitly specifying the appium server version etc.

PR Close #44281
2021-11-30 11:56:04 -05:00
Andrew Scott
3aafa765ee fix(language-service): Correctly parse inputs and selectors with dollar signs (#44268)
When we are going to the definition of an input, we find _both_ the
definition of the input _and_ also look for any directives which have
a selector that matches the input. For example:

```
@Directive({
  selector: '[greeting]'
})
export class MyDir {
  @Input() greeting!: string;
}
```

With this commit, we now correctly handle the case where inputs and/or
selectors have a dollar sign in them. The dollar sign has special
meaning in CSS, but when we encounter the dollar in a template, we need
to escape it when used as a selector so that it is taken as a dollar
literal rather than a character with special meaning.

Previously, we were not escaping the dollar sign and the CSS parsing
logic would throw an error. The change in this commit prevents that
error from happening, but a `try...catch` is still added in case there
is another unhandled use-case. If this happens, we do not want the
`goToDefinition` operation to completely fail.

Fixes https://github.com/angular/vscode-ng-language-service/issues/1574

PR Close #44268
2021-11-29 17:22:12 -05:00
dario-piotrowicz
708eb8c8d6 docs: fix instructions for debugging a karma test (#44244)
PR Close #44244
2021-11-29 17:21:42 -05:00
George Kalpakas
ef140a76d9 fix(docs-infra): fix the main content layout (#44282)
Fix the layout of the main docs content on both small and large screens.
On small screens, content could overlap with the floating ToC, while on
large screens the content was not centered correctly (see screenshots
below).

(For reference, this was accidentally broken in #44236.)

**Before:**
- ![content on small screen before](https://user-images.githubusercontent.com/8604205/143491577-97255ee7-f79d-4c95-9287-ff2afeb5b29d.png)
- ![content on large screen before](https://user-images.githubusercontent.com/8604205/143491582-2c19f7a2-d5ad-475a-a58b-e449efc492a9.png)

**After:**
- ![content on small screen after](https://user-images.githubusercontent.com/8604205/143491580-a405f650-cd4a-4804-8e65-422fc91f4c6e.png)
- ![content on large screen after](https://user-images.githubusercontent.com/8604205/143491585-d0d2e914-a1a2-45ba-8e6b-b9546aa80354.png)

PR Close #44282
2021-11-29 17:21:14 -05:00
George Kalpakas
8077695167 test(ngcc): use main property in test package.json files for UMD tests (#44245)
Previously, the mock packages created for `UmdDependencyHost`'s tests,
specified the entry-point as `esm2015`. This does not matter in tests,
since the packages are explicitly passed to the `UmdDependencyHost`
(while in reality the appropriate host would be determined based on the
name of the entry-point property - in this case, detecting the
entry-point as ES2015 and not UMD).

However, in order to avoid confusion, this commit updates the test
packages to use `main` (the default property used for the UMD format in
`package.json` files).

PR Close #44245
2021-11-29 12:38:06 -05:00
George Kalpakas
de0975c6d9 fix(ngcc): correctly report error when collecting dependencies of UMD module (#44245)
Previously, the ngcc `UmdReflectionHost` would throw a misleading error
when trying to collect dependencies of an invalidly formatted UMD
module. This happened because an error would be thrown while trying to
construct the error message for the actual error, by calling `getText()`
on certain TypeScript AST nodes. See
https://github.com/angular/angular/issues/44019#issuecomment-959954121
for a more in-depth explanation.

This commit ensures `getText()` can be safely called on TypeScript AST
nodes when collecting dependencies of UMD modules.

PR Close #44245
2021-11-29 12:38:06 -05:00
George Kalpakas
707bf41fa6 test(ngcc): run more tests against more supported UMD formats (#44245)
This commit utilizes the infrastructure added in the previous commit to
run more tests against more of the supported UMD formats. This shall
give us more confidence that all aspects of UMD processing work
correctly with the various formats.

PR Close #44245
2021-11-29 12:38:05 -05:00
George Kalpakas
557857a4f2 test(ngcc): use helper function for generating UMD modules for tests (#44245)
Previously, several ngcc test suites used their own helper to generate
test UMD modules.

This commit switches to using the same helper for generating UMD modules
across test suites. This improves DRYness (ensuring changes/fixes to the
UMD format need only be applied once) and makes it easier to test
different UMD formats in all test suites.

PR Close #44245
2021-11-29 12:38:05 -05:00
George Kalpakas
3c8a5d1c70 fix(ngcc): support the UMD wrapper function format emitted by Webpack (#44245)
Previously, ngcc could only handle UMD modules whose wrapper function
was implemented as a `ts.ConditionalExpression` (i.e. using a ternary
operator). This is the format emitted by popular bundlers, such as
Rollup.

This commit adds support for a different format, that uses `if/else`
statements, which is what is [emitted by Webpack][1].

[1]: https://webpack.js.org/configuration/output/#type-umd

Fixes #44019

PR Close #44245
2021-11-29 12:38:05 -05:00
George Kalpakas
e145b7a3f8 refactor(ngcc): make it easy to support more UMD wrapper function formats (#44245)
Previously, ngcc could only handle UMD modules whose wrapper function
was implemented as a `ts.ConditionalExpression` (i.e. using a ternary
operator). This is the format emitted by popular bundlers, such as
Rollup. However, this failed to account for a different format, using
`if/else` statements, such as the one [emitted by Webpack][1].

This commit prepares ngcc for supporting different UMD wrapper function
formats by decoupling the operation of parsing the wrapper function body
to capture the various factory function calls and that of operating on
the factory function calls (for example, to read or update their
arguments). In a subsequent commit, this will be used to add support for
the Webpack format.

[1]: https://webpack.js.org/configuration/output/#type-umd

PR Close #44245
2021-11-29 12:38:05 -05:00
dario-piotrowicz
8fae7df512 fix(docs-infra): add safari-only media query for aio footer flex (#44266)
safari handles rem based media queries differently so in order to
provide a similar user-experience to safari users, add a new
safari-only media query for the footer's flex container

resolves #44242

PR Close #44266
2021-11-29 12:37:44 -05:00
JoostK
1284d00dc7 refactor(platform-browser-dynamic): remove private export of ResourceLoaderImpl (#44267)
This type was exported for the ViewEngine compiler as it needed to
reference the class in its DI codegen. This is no longer a requirement
with Ivy, hence the private export can be removed.

This change prevents an import of `@angular/compiler` to be referenced
in the .d.ts file of `@angular/platform-browser-dynamic`, which is
beneficial for application compilations as that prevents the
`@angular/compiler` .d.ts files from being included in the `ts.Program`
of an application.

Closes #44157.

PR Close #44267
2021-11-29 12:37:00 -05:00
Pete Bacon Darwin
47f1c0fa33 fix(docs-infra): ensure deprecated styling is not overridden (#44275)
The `.code-anchor` styling was overriding the `.deprecated-api-item` styling.
The `text-decoration` is not needed on `.code-anchor` since it inherits this from the `a` rule in the typography.scss file.

Fixes #44264

PR Close #44275
2021-11-29 12:36:23 -05:00
Kristiyan Kostadinov
594bd12d5d test(core): clean up tests relying on entryComponents (#44276)
Cleans up all the tests that had to declare a separate module in order to pass in `entryComponents` when creating components dynamically. This covers almost all of the `entryComponents` usages, except for a few which I've left for now, because they're testing some of the existing leftover `entryComponents` logic in core.

PR Close #44276
2021-11-29 12:36:04 -05:00
Christian-E
2c954bb75d docs: fix filename of the file containing the 'routes'-array in lazy loading guide (#44297)
PR Close #44297
2021-11-29 12:35:44 -05:00
Andrew Kushnir
b31973c176 test: remove Ivy/ViewEngine switch helpers and obsolete tests (#44120)
This commit removes special functions that were used to run tests in ViewEngine or Ivy only.
Since ViewEngine is deprecated and we no longer run ViewEngine tests on CI, we can cleanup
those special helpers and ViewEngine-only tests.

PR Close #44120
2021-11-24 19:42:39 +00:00
JoostK
d8e65776cb refactor(ngcc): remove Ivy switch marker transform (#43891)
ngcc used to rewrite `PRE_R3` markers to become `POST_R3` in order to
switch the runtime implementation in `@angular/core` from View Engine to
Ivy. Now that `@angular/core` is published as native Ivy package and the
runtime switch code has been removed, there is no need for ngcc to
perform this transform anymore.

PR Close #43891
2021-11-24 19:26:25 +00:00
JoostK
b2ac81d147 refactor(compiler-cli): remove Ivy switch transform (#43891)
Now that the core package has been cleaned up to no longer contain Ivy
switch code, the transform to switch the `PRE_R3` markers to become
`POST_R3` is deleted as well.

PR Close #43891
2021-11-24 19:26:25 +00:00
Rohan Pednekar
b06e3981bc fix(core): add missing info about a component in the "pipe could not be found" error message (#44081)
Add error handling for pipe with component class name in which it has a problem. Add it in ngDevMode, so that it will be a tree-shake away from the production bundle.

PR Close #44081
2021-11-24 18:57:11 +00:00
Doug Parker
83bbbd3784 docs: document ng update support guarantees (#44142)
PR Close #44142
2021-11-24 18:56:32 +00:00
Pei Wang
adaff4109b ci: Upgrade tsec to 0.2.0. (#44205)
tools/tsec.bzl is now part of tsec. Remove from Angular repo and update
BUILD.bazel files.

PR Close #44205
2021-11-24 18:55:58 +00:00
Joey Perrott
0ad0054083 build: update repository to node@16 locally (#44211)
As node 16 is now active LTS, updating to node 16 is a better choice for our own development. Notably its
support for M1 chips is an important value add for us.

PR Close #44211
2021-11-24 18:55:33 +00:00
Joey Perrott
29c8feef75 test(common): change fallback default URL in MockPlatformLocation (#44211)
In node@16 the URL constructor fails for for a malformed URL such as http://<empty>/. Instead http://_empty_ is
used as this conveys the same information in tests but is correctly formed.

PR Close #44211
2021-11-24 18:55:33 +00:00
dario-piotrowicz
7b0e9b0f88 docs(animations): remove incorrect information regarding animateChild (#44216)
Remove incorrect information present in the angular.io animations documentation
stating that animateChild does not work with route transition animations
as that turned out not to be true

This PR effectively reverts the changes make in PR: #44014

For more context see issue #30477

PR Close #44216
2021-11-24 18:54:22 +00:00
dario-piotrowicz
6ae38584b0 docs(core): improve viewEncapsulation documentation (#44151)
Slighlty improve the `viewEncapsulation` documentation (both in code
comments and content files) to make it more clear and understandable.

See https://github.com/angular/angular/pull/44099#discussion_r745890903

PR Close #44151
2021-11-24 18:53:45 +00:00
dario-piotrowicz
2bf131a8a0 fix(docs-infra): move aio footer inside mat-sidenav-container (#44236)
currently the aio footer sits outside the mat-sidenav-container, as a
result when the mat-sidenav in over mode appears, the footer is not
placed under the sidenav backdrop, move the footer inside the
mat-sidenav-container so that it does

PR Close #44236
2021-11-24 17:04:01 +00:00
George Kalpakas
3697acc842 build(docs-infra): upgrade cli command docs sources to 481eb4544 (#44250)
Updating [angular#master](https://github.com/angular/angular/tree/master) from
[cli-builds#master](https://github.com/angular/cli-builds/tree/master).

##
Relevant changes in
[commit range](b8e198ba5...481eb4544):

**Modified**
- help/new.json

PR Close #44250
2021-11-24 17:03:38 +00:00
Artur
4527931977 docs: fix issue link in v13 release notes (#44258)
See:  #44181
PR Close #44258
2021-11-24 17:02:57 +00:00
Jessica Janiuk
414d5fef7f ci: add jessicajaniuk to pullapprove groups (#44255)
This adds jessicajaniuk to fw-animations and fw-testing.

PR Close #44255
2021-11-24 17:02:30 +00:00
Alex Rickabaugh
8c71b9fc42 refactor: delete the View Engine runtime (#43884)
This commit removes the View Engine runtime. Itself, this change is
relatively straightforward, but it represents the final step in a multi-year
journey. It's only possible due to the hard work of many current and former
team members and collaborators, who are too numerous to list here.

Co-authored-by: Alan Agius <alan.agius4@gmail.com>
Co-authored-by: Andrew Kushnir <akushnir@google.com>
Co-authored-by: Andrew Scott <atscott01@gmail.com>
Co-authored-by: Andrew Seguin <andrewjs@google.com>
Co-authored-by: Cédric Exbrayat <cedric@ninja-squad.com>
Co-authored-by: Charles Lyding <19598772+clydin@users.noreply.github.com>
Co-authored-by: Dave Shevitz <dshevitz@google.com>
Co-authored-by: Doug Parker <dgp1130@users.noreply.github.com>
Co-authored-by: Dylan Hunn <dylhunn@gmail.com>
Co-authored-by: Emma Twersky <emmatwersky@google.com>
Co-authored-by: George Kalpakas <kalpakas.g@gmail.com>
Co-authored-by: Igor Minar <iminar@google.com>
Co-authored-by: Jeremy Elbourn <jelbourn@google.com>
Co-authored-by: Jessica Janiuk <jessicajaniuk@google.com>
Co-authored-by: JiaLiPassion <JiaLi.Passion@gmail.com>
Co-authored-by: Joey Perrott <josephperrott@gmail.com>
Co-authored-by: Joost Koehoorn <joost.koehoorn@gmail.com>
Co-authored-by: Kristiyan Kostadinov <crisbeto@abv.bg>
Co-authored-by: Madleina Scheidegger <mscheid@google.com>
Co-authored-by: Mark Thompson <2554588+MarkTechson@users.noreply.github.com>
Co-authored-by: Minko Gechev <mgechev@gmail.com>
Co-authored-by: Paul Gschwendtner <paulgschwendtner@gmail.com>
Co-authored-by: Pawel Kozlowski <pkozlowski.opensource@gmail.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Co-authored-by: Wagner Maciel <wagnermaciel@google.com>
Co-authored-by: Zach Arend <zachzach@google.com>

PR Close #43884
2021-11-23 21:10:06 +00:00
Alex Rickabaugh
aadfad739b build: remove view engine build infrastructure (#43884)
This commit removes --config=viewengine and makes Ivy the default for
building Angular.

PR Close #43884
2021-11-23 21:10:06 +00:00
Alex Rickabaugh
bb9ff6003c test: remove view-engine-only tests (#43884)
This commit removes most tests that were designated as only covering View
Engine code. It also removes tag filters from CI and local commands to run
tests.

In a few cases (such as with the packages/compiler tests), this tag was
improperly applied, and certain test cases have been added back running in
Ivy mode.

This commit also empties `@angular/compiler/testing` as it is no longer
necessary (this is safe since compiler packages are not public API). It can
be deleted in the future.

PR Close #43884
2021-11-23 21:10:06 +00:00
unknown
f44cb57c12 fix(router): prevent componentless routes from being detached (#44240)
Currently, when deactivating a route, the detach method of the RouteReuseStrategy is always called
even when we are dealing with a componentless route. If when using a custom strategy we attempt to
detach a componentless route, an exception is thrown causing the navigation to break.
This change prevents this from happening, by not triggering the detach of the route reuse strategy.

Fixes #44239

PR Close #44240
2021-11-23 17:12:27 +00:00
Ramesh Thiruchelvam
2772eea649 refactor(core): clean up isDevMode for tree-shaking (#44210)
Removing the usage of isDevMode with ngDevMode flag. This will make the
dev-mode code tree-shakable from the production builds.

PR Close #44210
2021-11-23 17:11:59 +00:00
Renovate Bot
40eb2f57f4 build: update dependency source-map-support to v0.5.21 (#44225)
PR Close #44225
2021-11-23 17:10:59 +00:00
Renovate Bot
a0177c6a3a build: update angular (#44241)
PR Close #44241
2021-11-23 17:10:24 +00:00
Renovate Bot
782b893a98 build: update dependency @angular-eslint/eslint-plugin-template to v13 (#44224)
PR Close #44224
2021-11-22 20:18:00 +00:00
Pete Bacon Darwin
24b635395f fix(ngcc): ensure that ngcc does not write a lock-file into node_modules package directories (#44228)
When executing, ngcc writes a lock-file that is used to coordinate multiple concurrent instances of ngcc.
Previously, this file was written at `node_modules/@angular/compiler-cli/ngcc`, or similar depending upon the bundling of the package.
But this causes problems for setups where `node_modules` package directories are expected to be read-only.
Now, the lock-file is written as `.ngcc_lock_file` into the top of the `node_modules`, which is an acceptable place to store transient files.

This change should help to unblock use of tools like pnpm and lerna, which can use symlinks to readonly package directories.

PR Close #44228
2021-11-22 17:55:13 +00:00
George Kalpakas
f7dd0f83f0 build(docs-infra): update examples lockfile (#44232)
In #44214, the `package.json` used to install dependencies for docs
examples was updated, but the corresponding lockfile was not.

Update the lockfile to keep it in sync with `package.json`.

PR Close #44232
2021-11-22 17:40:27 +00:00
Renovate Bot
34c3ec61f9 build: update dependency @angular-eslint/eslint-plugin to v13 (#44223)
PR Close #44223
2021-11-22 17:36:00 +00:00