Commit graph

25921 commits

Author SHA1 Message Date
Paul Gschwendtner
b60df2aa6f build: update angular-in-memory-web-api to work with ESM (#48521)
Properly imports `jasmine-ajax` instead of attempting to load
some CommonJS bundle as a bootstrap dependency in Karma.

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
f44b322113 build: override schematics to be built and tested using CommonJS (#48521)
The Angular CLI does not yet support schematics running as ESM. For
this reason we switch the schematics BUILD targets to explicitly
use ESM (as an exception in the repo).

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
57a0499529 build: bundle tests for karma web test suites (#48521)
Since Karma with Bazel does not support ESM natively, we bundle the
tests using ESBuild into a single AMD file. This not only solves the
ESM issue until we can run browser ESM tests natively (also pending
in the components repo - the esbuild generation follows ESM semantics
but since collapsed we don't rely on the real module system).

A benefit of bundling is also faster and more reliable Karma browser
tests since only a single file needs to be loaded- compared to hundreds
of individual files.

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
15c3e11359 test: refactor render3 definition feature test to be less sensitive to JS output (#48521)
If tests are bundled using e.g. esbuild, the `ee` symbols may
be rewritten to `\u0275\u0275`. This breaks assertions that
rely on `Function.toString`. We can avoid this string comparison
and make it more future proof by just comparing the symbols directly.

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
d7fa04fd98 build: update dev-infra build tooling to leverage recent ESM changes (#48521)
Update dev-infra's build-tooling since multiple ESM changes have
landed there. e.g. not relying on `require.main === module` for API
bundling. This will allow us to also execute all dev-infra rules
in ESM because we plan on applying our ESM patching to `ts_library`
(which would also affect build-tooling then).

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
f89a6dbf05 test: refactor core bundling tests to work with ESM (#48521)
Switches all `core/test/bundling` tests to not rely on
CommonJS-specific features like `require.resolve

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
810351ab4c refactor: update symbol extractor test tool to work with ESM (#48521)
The symbol extractor test tool now runs with ESM too. This commit
makes it ESM compatible.

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
c8e021ef4a build: support esbuild configurations using ESM dependencies (#48521)
We use `bazel/esbuild` in various places (e.g. for app bundling tests).
These tests rely on the Angular Compiler-CLI itself for e.g. linking
or the Terser configuration. Since everything in this repo is now
strict ESM, the ESBuild configs (which are already ESM-supported)
need to import from `//packages/compiler-cli`. We also need to be
able to leverage our existing ESM Bazel loader for this though as
otherwise resolution would fail.

Long-term we can remove this if everything in the compiler-cli
would use `.mjs` extensions and the import paths would also specify
an explicit extension. See: https://nodejs.org/api/esm.html#mandatory-file-extensions

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
64f5ed89e8 build: update esm nodejs loader to properly handle subpaths (#48521)
The ESM loader when used with patched Bazel module resolution
handled subpaths incorrectly. e.g.
`@bazel/concatjs/tsc_wrapped/internal/index.js` could be incorrectly
resolved to `@bazel/concatjs/index.js`.

This commit fixes the flawed logic. Also we prioritize the ESM attempts
before the original specifier. This is necessary because otherwise
the default Node resolution (using `require.resolve`) may incorrectly
prefer the `index.js` file over a `index.mjs` when a directory is
imported.

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
5c670b8f77 refactor: adjust packages/core/test to work with ESM (#48521)
The `packages/core/test` test code was relying on non-ESM
compatible features like untyped `require` calls.

We switch these to ESM `import` statements/expressions and
make it strongly typed. It's a trade-off between type-safety
and the dependency graph- but it feels more reasonable typing
this properly to actually benefit from the type system provided
by using TypeScript.

Additionally, we align the IDE tsconfigs to use `esnext` as module
because that is what we use in Bazel and it allows us to use
top-level await.

PR Close #48521
2022-12-19 19:50:42 +00:00
Paul Gschwendtner
211d178f0d refactor(platform-server): use proper ESM-compatible import to domino (#48521)
Now that everything runs from within ESM, we need to use the proper
default-import variant to be able to load `domino` from ESM.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
985dbdb511 build: remove unnecessary import to @bazel/jasmine (#48521)
Since we no properly initialize as part of the spec-entrypoint
the hacky logic starting Jasmine can be removed. The init
file now runs before tests run, but after Jasmine is initialized.

Calling `boot` while Jasmine is already initialized results in
tests executing in a different context and before other
initialization work completes.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
c9415e4d75 build: ensure bootstrap transitive runfiles are made available (#48521)
Since we generate a `.mjs` file as entry-point for jasmine tests,
a couple of issues prevented the transitive dependencies from
bootstrap targets to be brought in (causing resolution errors):

1. The `_files` (previously `_esm2015`) targets are no longer needed,
   and they also miss all the information on runfiles.
2. The aspect for computing linker mappings does not respect the
   `bootstrap` attribute from the `spec_entrypoint` so we manually
   add the extract ESM output targets (this rule works with the aspect
   and forwards linker mappings).

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
369091839f build: fix loader and support rxjs to be used in NodeJS ESM (#48521)
RxJS currently ships ESM output that cannot be executed directly
in NodeJS. This is because RxJS ships ESM as `.js` files but does
not have a `package.json` which instructs Node to execute these as ESM.

RxJS would either need to use the explicit `.mjs` extension, or add
a `type: module` `package.json` next to the `.js` sources.

We manually patch RxJS to do this, while we wait on the upstream fix
to land. See: #7130.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
83dbed0a52 build: patch ts_library to not emit a tsickle extern file (#48521)
The prodmode compilation pipeline -that we intend to use more heavily
now given it emitting files with the `.mjs` extension- exposes an
additional tsickle closure externs file. This file is empty most
of the time anyway since tsickle is not wired up.

We remove this generation as otherwise convenient `$(location` of
such ts library targets break because there always is more than 1 file.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
4b2cbc0334 build: update jasmine_node_test macro to support ESM (#48521)
Note: `--require` does not work for ESM. `--import` does not exist
in the current Node versions. Started being available in NodeJS v19.

A custom entry-point script, already supported by dev-infra, simplifies
the whole logic and solves the ESM case.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
20551503fa build: replace _es2015 shorthand with more flexible _files suffix (#48521)
For every `ts_library` target we expose a shorthand that grants
access to the JS files because `DefaultInfo` of a ts library
only exposes the `.d.ts` files.

We rename this away from `es2015` since in practice it's a much
higher target these days. Additionally we no longer use the devmode
output but rather use the prodmode output which has the explicit
`.mjs` output- compatible with ESM.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
0d83e89217 build: support enabling esm interop loader even outside of defaults.bzl (#48521)
We introduced a loader that supports ESM with Bazel. This loader can
only be enabled as part of our `nodejs_binary` defaults.bzl test. This
works fine, but there might be other binaries/tests e.g. from
`@angular/build-tooling` that should be able to use ESM & might need to
for importing the `compiler-cli`.

We move the logic for installing the patch into a `rules_nodejs` patch.
There is an existing one that is just updated to "enable ESM support".

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
e1513bf58a build: update madge circular deps tests to use .mjs output (#48521)
The underlyijng nodejs tests of the rule now also use the ESM
output, so normal `.js` artifacts are not even available there.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
63b2421f3b build: include default files when extracting ESM outputs (#48521)
This is necessary for e.g. JSON files from the CLDR data repository.
Otherwise these could not be added to the runfiles of the
binaries/tests.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
07c3157e4f build: move nodejs binary patch into more obvious place (#48521)
For the ESM interop patches we expect to have two types
of patches:

* Patches for `node_modules`
* Patches for Bazel repositories.

We move the patches in respective folders to make it very clear
where a patch is used/applied to.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
eac5280bec build: support template make variables in nodejs_binary/test (#48521)
We modified the macros of `nodejs_binary/test` to have a rule
in between that requests the `.mjs` output. This works fine but
breaks make variable substitution for `templated_args` because
Bazel requires referenced labels to be part of the explicit `data`.

The rule in between breaks this, so we add a new argument that
can be used for such "template"/"args" data dependencies.

This can be removed when everything is ESM and we don't need
the rule in between.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
d3d22a9009 build: refactor ng_package to work with ESM (#48521)
Removes `shelljs` which is a known ESM-problematic dependency.
We don't need it anyway.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
c6d48c5366 build: prioritize ESM output in nodejs_test similar to binary-variant (#48521)
The `nodejs_binary` rule already prioritizes the `.mjs` output as
of the recent commits. The `nodejs_test` rule should do the same,
and also set `use_esm = True`

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
553d42c86f build: patch rules_nodejs to prioritize ESM files for nodejs_binary/test (#48521)
The Bazel NodeJS rules will always use the `.js` files as entry-points.
Since we only rely on the `.mjs` output going-forward, we need to teach
`nodejs_binary` and `nodejs_test` to use the `.mjs` extensions if
intended.

Our `defaults.bzl` macros will set `use_esm = True`, but other targets
from e.g. external repositories should keep the original behavior.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
5c51c48f98 refactor: remove __ESM_IMPORT_META_URL__ workaround now that we can use ESM (#48521)
The `__ESM_IMPORT_META_URL__` trick was used because we used both ESM
and CommonJS in this repo. It was an interop needed because
`import.meta.url` syntax couldn't be used as it woud have caused syntax
errors.

We still need to keep the CommonJS/ESM interop in the compiler-cli
because g3 relies on the compiler and uses CommonJS. This affects very
few places, just in the compiler- so this is acceptable.

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
0e1cbecc2c build: refactor generate-locales-tool to ESM (#48521)
The `generate-locales-tool` now needs to run as ESM because we changed
the `ts_library` rule. This commit accounts for the ESM syntax but
removing CJS code parts like `require.main === module`.

Also imports using `require` need to be changed to their ESM
equivalents.

PR Close #48521
2022-12-19 19:50:40 +00:00
Paul Gschwendtner
9e91bbd329 build: refactor ngc-wrapped to support ESM (#48521)
Since this repo will now be strict ESM, and Angular Compiler packages
on NPM are also ESM-only, we can rework `ngc-wrapped` to remove
the CJS/ESM interop and we make it strict ESM too.

PR Close #48521
2022-12-19 19:50:40 +00:00
Paul Gschwendtner
9cd89569f5 build: create NodeJS ESM loader for supporting Bazel setup (#48521)
Replaces the existing ESM loader for dealing with external module
imports. This loader was introduced by Aspect for AIO `.mjs` scripts.

The loader will be used as foundation for a more extensive loader
that also properly handles first-party packages.

Additionally another loader is added, all packed as a single
loader because our current NodeJS version only supports a single
loader per node invocation. So we implement chaining ourselves.

The new loader will attempt rewriting `.js` extensions to `.mjs`,
also it will add `.mjs` if not already done. This is necessary
in the transition phase because we don't/cannot use explicit `.mts`
extensions and also we don't specify extensions in imports yet.

Long-term we would likely use `.mts` and explicit import extensions,
but it's not yet clear how we would sync this into g3 too.

PR Close #48521
2022-12-19 19:50:40 +00:00
Paul Gschwendtner
fe6dcd1f5c build: rename esm-loader.mjs to a more specific filename (#48521)
This is in prearation for having a proper diff when this loader
is adjusted to support more situations than just simple external
node modules. See next commit.

Also the file is formatted to make the diff less verbose later.
The file was never formatted correctly and we don't lint `.mjs` files.

PR Close #48521
2022-12-19 19:50:40 +00:00
Paul Gschwendtner
ba5fe263b5 build: switch ng_module and ts_library devmode to ES2020 ESM (#48521)
Currently the devmode output for `ng_module` and `ts_library` is
using ES5 CommonJS UMD. To bring it in sync with prodmode and
to start with our long-term migration to full ESM- the devmode
is updated to to ES2020 ES modules too.

This will require more tricks to make devmod work with the bazel
setup and also tests may need to be refactored given them relying
on ES5 CJS features, like for `spyOn` jasmine patching etc.

PR Close #48521
2022-12-19 19:50:40 +00:00
Joey Perrott
e59406f5e7 build: enable new merge ready status action (#48494)
Enable new action in preperation for sunset of github robot

PR Close #48494
2022-12-15 15:21:14 +00:00
Andrew Kushnir
63debcc763 ci: mark //aio:e2e tests as flaky (#48498)
AIO e2e tests became more flaky recently. More investigation is needed to identify why,
but we mark the `//aio:e2e` as flaky for now to rerun those tests on CI if they fail.

PR Close #48498
2022-12-15 15:17:29 +00:00
Jessica Janiuk
eb52d9eabd release: cut the v15.1.0-next.3 release 2022-12-14 11:58:18 -08:00
Jessica Janiuk
6ade57cfdd fixup! docs: release notes for the v15.0.4 release 2022-12-14 11:18:04 -08:00
Jessica Janiuk
5303e0b8df docs: release notes for the v15.0.4 release 2022-12-14 11:18:04 -08:00
Andrew Scott
fe50813664 feat(common): Add BrowserPlatformLocation to the public API (#48488)
`PlatformLocation` is already part of the public API so developers can
create their own. This means that developers would already be able to
access the existing `BrowserPlatformLocation` at runtime by injecting
it. The motivation for adding `BrowserPlatformLocation` to the public
API is because of those facts, but driven more by the fact that we are
looking to include `MockPlatformLocation` by default in TestBed.
Developers would need a way to revert back to the current behavior for
some tests that rely directly on browser interaction.

PR Close #48488
2022-12-14 09:54:28 -08:00
Alan Agius
4ab3ed3109 docs: update CLI sources ref (#48486)
This is needed to update AIO documentation as currently the CLI docs are out of date.

PR Close #48486
2022-12-14 08:44:12 -08:00
Jens
b10e6185de docs: update date from 2022 to 2023 (#48485)
PR Close #48485
2022-12-14 08:43:31 -08:00
Jens
ca02f70c25 docs: add planned release schedule till v16 (#48485)
Add release dates for v15.1,v15.2 and v16
PR Close #48485
2022-12-14 08:43:31 -08:00
Andrew Scott
81203c6ec1 refactor(router): Add opt-in provider for upcoming router change (#47988)
This commit adds a swappable provider for an upcoming change to the
implementation of `Router#createUrlTree`. This will be a breaking change
and is planned to be included in V16.

PR Close #47988
2022-12-13 16:57:46 -08:00
Andrew Scott
cf7e4e47fc docs: Add doc page for 'textAttributeNotBinding' extended diagnostic (#48307)
Adds documentation page for `textAttributeNotBinding` extended diagnostic.

fixes #48291

PR Close #48307
2022-12-13 16:56:06 -08:00
Bob Watson
f6ac94c81c docs: edit suggestion to meet style guide (#47979)
PR Close #47979
2022-12-13 14:47:32 -08:00
lsst25
005e2ba57a docs: add a link to hierarchical-dependency-injection (#47979)
It is not clear that when we provide a service to some eagerly loaded module of an application, then that service is available for components of all eagerly loaded modules of that application. It would be better to give a link for more information at least.
PR Close #47979
2022-12-13 14:47:32 -08:00
Andrew Scott
ff84c73603 docs(core): Document invalid multi token (#48267)
Add error page for invalid multi token runtime error

PR Close #48267
2022-12-13 14:05:59 -08:00
Matthieu Riegler
279e7d4465 refactor: cleanup polyfills by importing zone.js directly in angular.json (#48380)
Since v15, polyfills can be passed directly into angular.json. Let's use this opportunity to reduce the number of unecessary files.

PR Close #48380
2022-12-13 13:37:08 -08:00
Angular Robot
d7038475ed build: update eslint dependencies to v5.46.1 (#48464)
See associated pull request for more information.

PR Close #48464
2022-12-13 13:25:00 -08:00
Lukas Matta
2e65a2bd84 fix(devtools): Replace material imports and styles (#48420)
In the #48216 Material deps were updated to v15,
but the components and modules in DevTools were not
updated to MDC nor replaced with the legacy definitions.

PR Close #48420
2022-12-13 13:22:25 -08:00
piyush132000
b05113c621 docs: updated docs removed unnecessary imports and empty methods (#48429)
Removed empty methods and unnecessary imports in files

PR Close #48429
2022-12-13 13:14:35 -08:00
BrowserPerson
2cd76e053f docs: add maria korneeva to GDE resources (#48468)
PR Close #48468
2022-12-13 13:14:06 -08:00