9292 Commits

Author SHA1 Message Date
Paul Gschwendtner ae34e6cabd fix(language-service): expose package.json for vscode extension resolution (#48678)
The VSCode extension looks for `@angular/language-service/package.json`
using `require`. This currently breaks as of the ESM changes because
we introduced the `exports` field but did not expose the `package.json`.

This commit fixes it.

Co-authored-By: Andrew Scott <atscott@google.com>
Co-authored-By: Dylan Hunn <dylhunn@gmail.com>

PR Close #48678
2023-01-10 09:13:55 -08:00
Kristiyan Kostadinov aa31d611c9 fix(compiler): resolve deprecation warning (#48652)
Fixes a deprecation warning that was being logged by compiler when generating aliases, because we weren't going through `ts.factory` to create an AST node.

PR Close #48652
2023-01-10 08:13:28 -08:00
Andrew Kushnir 84d436e504 refactor(platform-browser): prepare the code to use MockPlatformLocation by default (#48651)
This commit prepares the code of the `BrowserTestingModule` to include the `MockPlatformLocation` by deafult in the future. With this change, the set of providers to add the `MockPlatformLocation` would be disabled by a flag, which will be switched in v16.

PR Close #48651
2023-01-10 08:06:37 -08:00
Matthieu Riegler c139d2de1a docs(compiler-cli): fix commands to run compliance unit test (#48559)
PR Close #48559
2023-01-10 07:59:53 -08:00
Doug Parker d0f732a85c refactor(bazel): disables the Tsickle decorator transform (#47934)
This is no longer needed in google3 and actively impedes prodmode tests. See http://b/254054103#comment7 for deeper analysis.

This just turns off the transform for now, if it lands successfully I'll follow up with deleting the flag and dead code altogether.

PR Close #47934
2023-01-10 07:58:39 -08:00
Paul Gschwendtner 993217e192 fix(language-service): ship /api entry-point (#48670)
The `/api` entry-point was accidentally dropped when we switched the
compilation in the repo to full ESM- thinking the entry-point is not
needed externally.

We re-add it because the VSCode repo extension relies on it for checking
whether `ts.LanguageService` is an Angular one.

PR Close #48670
2023-01-09 10:13:34 -08:00
Greg Magolan 0e0d686d1e fix(language-service): update packages/language-service/build.sh script to work with vscode-ng-language-service's new Bazel build (#48663)
2nd half of https://github.com/angular/vscode-ng-language-service/pull/1846. `npm_traslate_lock` in vscode-ng-language-service now has a data attribute so sed should only add another item to the list instead of adding a duplicate data attribute.

PR Close #48663
2023-01-09 10:13:07 -08:00
Matthieu Riegler 433dd5c66f fix(forms): Form provider FormsModule.withConfig return a FormsModule (#48526)
Because of a transitive dependency, FormsModule.withConfig wasn't providing FormModule.

fixes: #48519

PR Close #48526
2023-01-05 16:26:22 -08:00
Matthieu Riegler 10de92c68a refactor(forms): cleanup type any in forms tests (#48624)
Removing every type any in forms with a reference to #9100

PR Close #48624
2023-01-05 14:52:03 -08:00
Matthieu Riegler f3babe0458 refactor(common): remove non-null assertions (#48476)
As part of angular#24571, removing all non-null assertions from common/test/directives

PR Close #48476
2023-01-05 14:46:21 -08:00
Matthieu Riegler 406ae85e10 refactor(common): code cleaning (#48476)
* removing guard as console.warn is now widely supported
* Couldn't remove non-null assertion, waiting for TS support of getters with different types (microsoft/typescript#43662)

PR Close #48476
2023-01-05 14:46:20 -08:00
Matthieu Riegler be321f017a refactor(common): remove non-null assertions (#48476)
As part of angular#24571, removing all non-null assertions from common/directives

PR Close #48476
2023-01-05 14:46:20 -08:00
Matthieu Riegler 7d30528fbd refactor(common): remove non-null assertions (#48476)
As part of angular#24571, removing all non-null assertions from common/directives

PR Close #48476
2023-01-05 14:46:20 -08:00
Andrew Scott a9a7e9fb00 refactor(router): Remove files no longer in use (#48500)
These files exist to support internal patches that are no longer needed

PR Close #48500
2023-01-05 14:42:27 -08:00
Matthieu Riegler cea2d192d9 refactor(compiler): Remove unnecessary assignment (#48478)
This is well known problem and has a opened issue at microsoft/typescript.  @ts-expect-error will highlight an error when this is fixed.

PR Close #48478
2023-01-04 12:23:51 -08:00
Matthieu Riegler 10c10ee559 refactor(core): cleanup type any (#48623)
Removing every type any in core with a reference to #9100

PR Close #48623
2023-01-04 12:15:17 -08:00
Pawel Kozlowski 4621be3081 refactor(core): move attachDebugGetter to i18n specifc code (#48549)
The attachDebugGetter function is only used in the i18n specific code
so could be moved closer to the sole usage site instead of being
exported to the entire framework code. It also lets us remove the
entire packages/core/src/render3/util/debug_utils.ts file.

PR Close #48549
2023-01-04 12:14:30 -08:00
Pawel Kozlowski 9a1083c0ee refactor(core): remove unused attachDebugObject function (#48549)
This commit removes the unused attachDebugObject function.

PR Close #48549
2023-01-04 12:14:30 -08:00
Matthieu Riegler dfa69553a0 refactor(common): remove unnecessary parseFloat from ng_optimized_image directive. (#48527)
There is no need to parse clientWidth/clientHeight/naturalWidth/naturalHeight on HTMLImageElement as there is no sign of other types being returned on everygreen browers.

PR Close #48527
2023-01-04 12:07:03 -08:00
Matthieu Riegler 864a425de1 docs: fix typo on SkipSelf (#48511)
fixes #48506

PR Close #48511
2023-01-04 11:53:31 -08:00
Alan Agius 881ecb0936 fix(localize): add triple slash type reference on @angular/localize on `ng add (#48502)
This commits add a triple slash type reference to the `main.ts` of the project when running `ng add @angular/localize`. This is purely needed for IDE purposes so that `$localize` is available globally. For the compilations `@angular/localize` types are adding the the respective TS configs files.

This commits also add better support for using `@angular/localize` in `/// <reference types="@angular/localize" />`. To support this we need to move the global definition outside of a barrel file and into the index.ts file. Without this change the `$localize` method will not available globally when using triple slash type references.

Closes #48434

PR Close #48502
2023-01-04 11:50:45 -08:00
Alex Castle acff032f4b fix(common): Add data attribtue to NgOptimizedImage (#48497)
Add a tracking attribute in oder to be able to distinguish usages of NgOptimizedImage from standard images

PR Close #48497
2023-01-04 11:46:27 -08:00
robertIsaac 7bbe492383 docs: add NG0403.md for Bootstrapped NgModule doesn't specify which component to initialize error (#48483)
- update `errors.ts` to annotate the error NG0403, so that the runtime can add a link to that guide when an error is thrown
- update `application_ref_spec.ts` to include the new link of the error
- update `errors.md` as a result of running `yarn bazel test packages/core/test`

Fixes #47985

PR Close #48483
2023-01-04 09:59:25 -08:00
Paul Gschwendtner 2b8d8f0077 fix(compiler-cli): update @babel/core dependency and lock version (#48634)
Similar to how the `@babel/core` dependency is managed for the localize
NPM package, the version should be locked. Also the version should
correspond to the version we install for building & testing.

Currently the Babel version allowed by the compiler-cli may not
work given the ESM -> CJS interop. causing errors like:

```
import { types as t } from "@babel/core";
         ^^^^^
SyntaxError: Named export 'types' not found. The requested module '@babel/core' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@babel/core';
const { types: t } = pkg;
```

We can only be confident about the interop if we know the version
installed- is the one we test.

PR Close #48634
2023-01-03 16:36:50 +00:00
Vadim e88d3ae171 docs: fix typo in preconnect_link_checker.ts (#48595)
PR Close #48595
2023-01-02 12:17:52 +00:00
Alan Agius ac106cc432 build: remove duplicate license banners from FESM bundles (#48560)
Prior to this change the FESM bundles have the license banner duplicated multiple of times in each published file.

With this change we remove all the banners from the individual input files. A new banner will be appended at the top of the FESM using rollup's banner option.

While there is a rollup plugin on NPM to strip these banners (https://github.com/mjeanroy/rollup-plugin-strip-banner) we could not use this as it does not support `.mjs`.

PR Close #48560
2023-01-02 12:16:55 +00:00
Alan Agius e7c2249dd7 fix(bazel): remove duplicate license banners from FESM bundles (#48560)
Prior to this change the FESM bundles for the FW packages have the license banner duplicated hundreds of times in each published file.

With this change we remove all the banners from the individual input files. A new banner will be appended at the top of the FESM using rollup's banner option.

While there is a rollup plugin on NPM to strip these banners (https://github.com/mjeanroy/rollup-plugin-strip-banner) we could not use this as it does not support `.mjs`.

PR Close #48560
2023-01-02 12:16:55 +00:00
Paul Gschwendtner cbb9183ed4 refactor: update packages/bazel npm artifact to not rely on defaults.bzl (#48538)
Fixes that we temporarily broke the Bazel npm package artifact as
part of the ESM work. This commit adjusts it and also makes the
artifact subsitutions more maintainable.

PR Close #48538
2022-12-19 20:12:38 +00:00
Paul Gschwendtner e7e5a0adc6 build: make devmode a noop and ensure it never runs (#48538)
This is basically a pre-step for combining devmode and prodmode into a
single compilation. We are already achieving this now, and can claim
with confidence that we reduced possible actions by half. This is
especially important now that prodmode is used more often, but rules
potentially still using the devmode ESM sources. We can avoid double
compilations (which existed before the whole ESM migration too!).

We will measure this more when we have more concrete documentation
of the changes & a better planning document.

Changes:

  * ts_library will no longer generate devmode `d.ts`. Definitions are
    generated as part of prodmode. That way only prodmode can be exposed
    via providers.
  * applied the same to `ng_module`.
  * updates migrations to bundle because *everything* using `ts_library`
    is now ESM. This is actually also useful in the future if
    schematics rely on e.g. the compiler.
  * updates schematics for localize to also bundle. similar reason as
    above.

PR Close #48538
2022-12-19 20:12:38 +00:00
Paul Gschwendtner eda0a7af2b build: remove remaining usages of deprecated ts_devserver (#48538)
* Switches all remaining targets (even if not tested and failing as per
  build) away from `ts_devserver` to the canonical `http_server` from
  dev-infra.

PR Close #48538
2022-12-19 20:12:38 +00:00
Paul Gschwendtner e296d1d01d build: fix legacy saucelabs test bundle generation after ESM changes (#48538)
ZoneJS is no longer loaded as an UMD, but instead is included as part
of the browser init entry-point. This means that ZoneJS is bundled and
the ESBuild logic needs to be adjusted for that.

PR Close #48538
2022-12-19 20:12:38 +00:00
Paul Gschwendtner 548f196bea refactor: update service-worker tests to work with ESM (#48538)
* Updates circular dependency tests to use the `.mjs` outputs
* Switches away from CommonJS specific `require` calls.
* Simplifies the test helper logic since all browsers/NodeJS versions
  support `URL` as a global.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 627d0070e3 refactor: update language-service package and tests to work with ESM (#48538)
The Angular Language Service package is now tested & compiled using ESM.
Previously it was a mismatch of CommonJS and ESM.

Still the language-service ESM output is transformed into a single UMD
bundle to allow for module resolution to be overriden. See
`bundles/BUILD`.

This is kept as is. To fully ship ESM (language-service is an exception
here), we need to:

 * Update all code to no longer reference typescript via import. Instead
   typescript needs to be passed around so that the extension can
   control the version
 * The VSCode extension/ the TS server needs to be able to load ESM. It
   looks like the server supports ESM global plugins, but the extension
   might not yet.

This is out of scope for the dev-infra effort as it requires more
insight into VSCode & the extension system & the TS language server.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 15d61f6798 refactor: switch packages/examples to ESM-compatible http server (#48538)
* Switches all examples to use dev-infra's canonical ESM-compatible
  `http_server`.
* Uses ESBuild for bundling ESM into a single file, compared to having
  to load hundreds of individual ESM files in the browser (potential
  source of flakiness & slowness).

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner e0e3c85c83 refactor: convert AIO tooling scripts used in Bazel to ESM (#48538)
Since the Bazel setup in this repo will now always use ESM,
the tooling scripts/binaries in AIO need to be switched to ESM
too. Most of the scripts are already ESM, but a few had to be converted.

Note that the Dgeni generation does not use ESM because it's unaffected
and the Dgeni CLI is used. In the future we could also update the Dgeni
setup to ESM but there is no need currently.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner d3bd820ea3 refactor: update zone.js and tests to work with ESM (#48538)
* Adjusts tests to no longer rely on CommonJS features. Switches them to
  ESM
* Updates test initialization files to not double-initialize Jasmine now
  that bootstrap files are loaded after Jasmine. The `jasmine.boot`
  setup was hacky from `rules_nodejs` and will break in the future
  regardless if we e.g. use `rules_js` with actual unmodified `jasmine`.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner d2689012bf refactor: update elements test to work with ESM outputs (#48538)
* Uses the `.mjs` ESM output for testing/checking circular dependencies.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 6b8c3e2d63 refactor: update forms package tests to work with ES2020 ESM (#48538)
Tests now always run with ESM 2020, while previously they ran with
ES2015 CommonJS UMD bundles.

Since ZoneJS does not support intercepting native `async/await` syntax,
the forms test needs to use the zone-compatible variant of
`jasmine_node_tests`. This variant downlevels the native `async/await`
syntax to generators that ZoneJS can intercept. All of this is done
using the dev-infra ESBuild `spec_bundle` rule.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 61d2eacf79 refactor: update upgrade package tests to work with ESM output (#48538)
* Uses the `.mjs` output of the upgrade package when checking for
  circular deps.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner 4fce3e3a02 refactor: update platform-browser-dynamic to work with ESM output (#48538)
* Switches circular dependency tests to use the `.mjs` output.

PR Close #48538
2022-12-19 20:12:37 +00:00
Paul Gschwendtner b6424ac3c5 refactor: update platform-server tests to work with ESM (#48538)
* Uses `.mjs` for circular deps tests
* Replaces `require` with ESM-equivalent. uses an import statement here
  for proper typing, and specify dependency properly.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner ab4b5c8b0e refactor: update packages/localize to be strict ESM (#48538)
The `packages/localize` package still required some trickery
to support CommonJS because tests in the repo were running as CommonJS.

This commit removes the CommonJS logic in localize and its tests, so
that only ESM is used in production & tests.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 2597e3b7ff build: add missing dependencies to platform-server and tools/testing (#48538)
There are two build targets which never had all its runtime dependencies
properly specified. This wasn't noticed because there were macros in
`defaults.bzl` that automatically included these deps.

In a follow-up we will clean-up this legacy auto-deps feature in
`defaults.bzl`.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner cca335dc40 refactor: update packages/router tests to be compatible with ESM (#48538)
The ESM js files need to be referenced, and the router tests rely
on `async/await` with change detection- so a special rule is required
that downlevels `async/await` to generators (similar to the Angular CLI)

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 4f156fb6da refactor: update image-directive e2e test to work with ESM (#48538)
* Switches to the canonical dev-infra http server
* Uses the bundle for serving.
* Switches app_bundle to simple `esbuild` since the test relies
  on `ngDevMode` which `app_bundle` elides as optimization.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 0787f0131a refactor: update platform-browser tests to run as ESM (#48538)
`platform-browser` tests now run in ESM and with `.mjs` output, so
the build targets and tests need to be updated.

Here we change the `zone_event_unpatched` script to include the
`.init` suffix that will be picked up by `spec_bundle`.

Also some circular dependency tests are updated to refer to the
`.mjs` files.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner 260faaf912 refactor: update compiler-cli to work with ESM (#48538)
Updates compiler-cli & tests to be full ESM compatible. Tests
no longer with CommonJS.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner ef2de133a3 refactor: change ngcc to only rely on ESM features (#48538)
Refactors ngcc to only rely on ESM features because CJS
is no longer needed & tested.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner f25d71498d refactor: update compiler-cli babel linker to be ESM only (#48538)
Since the linker is no longer being tested with CommonJS, we can remove
most of the CJS/ESM interop trickery.

PR Close #48538
2022-12-19 20:12:36 +00:00
Paul Gschwendtner e8783286af build: refactor packages/compiler/test to work with ESM (#48538)
Switches the circular deps test to use the ESM output. The
normal `.js` devmode output is no longer available.

PR Close #48538
2022-12-19 20:12:36 +00:00