Commit graph

711 commits

Author SHA1 Message Date
Paul Gschwendtner
af303d98db refactor: remove unused variables in starlark code to satisfy buildifier (#45431)
We updated buildifier and a few warnings became errors now. This commit
cleans up the failing unused variable instances, making the linter happy.

Additionally for the API extractor BUILD file, the package defaults
need to move to satisfy buildifier.

PR Close #45431
2022-03-25 12:18:34 -07:00
Paul Gschwendtner
a24293ae80 build: migrate more usages from @bazel/typescript to @bazel/concatjs (#45431)
As mentioned in previous commits (check them for more details), `@bazel/typescript`
no longer contains `ts_library`-specific code, so we no longer need that dependency.

PR Close #45431
2022-03-25 12:18:34 -07:00
Paul Gschwendtner
ffa331b130 refactor(bazel): update api-extractor to account for @bazel/typescript change (#45431)
`@bazel/typescript` code moved to `@bazel/concatjs` for the tsc-wrapped code.

Note that this code is likely going to be removed anyway soon when we
move dts bundling from `ng_module` to `ng_package`.

PR Close #45431
2022-03-25 12:18:34 -07:00
Paul Gschwendtner
7f6859e11f refactor(bazel): update ngc-wrapped to account for tsc-wrapped move to @bazel/concatjs (#45431)
Previously `tsc-wrapped` which is the foundation for `ngc-wrapped`, resided
in `@bazel/typescript`. It has been moved to `@bazel/concatjs` in rules_nodejs
so we need to account for that as part of our rules_nodejs v5 update.

PR Close #45431
2022-03-25 12:18:33 -07:00
Renovate Bot
010a39f856 build: update bazel (#45431)
Update `@bazel` packages to the latest 5.x version.

Some of the changes here are modeled after
angular/dev-infra@40c0ac8559.

Co-Authored-By: George Kalpakas <kalpakas.g@gmail.com>

PR Close #45431
2022-03-25 12:18:33 -07:00
Tobias Speicher
4ddcf81e61 refactor: replace deprecated String.prototype.substr() (#45397)
.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>

PR Close #45397
2022-03-24 11:48:09 -07:00
Paul Gschwendtner
dc72f3007a fix(bazel): ng module compilation workers are subject to linker race-conditions (#45393)
The Bazel NodeJS rules provide two ways of accessing node modules:

* A linker which creates a `node_modules` directory in the execroot/or in the runfiles.
* A patched module resolution where no node modules directory necessarily needs to exist.

The first is the default in `rules_nodejs` and the second is technically the most idiomatic
resolution mechanism in Bazel (as it matches with a runfile resolution library).

The linker is prone to race conditions in persistent workers, or non-sandbox environments (like
windows). This is because the linker for all workers will operate on a shared `execroot` directory
and the same `node_modules` directory is modified all the time / potentially conflicting with other
linker processes from other concurrently-running workers.

We rely on the patched module resolution anyway, but just need to disable the unused linker to avoid
issues like the following:

```
---8<---8<--- Start of log, file at /private/var/tmp/_bazel_splaktar/280f06d55552a0d01f89f0955b5acd78/bazel-workers/worker-8-TypeScriptCompile.log ---8<---8<---
[link_node_modules.js] An error has been reported: [Error: ENOENT: no such file or directory, unlink 'node_modules'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'unlink',
  path: 'node_modules'
} Error: ENOENT: no such file or directory, unlink 'node_modules'
---8<---8<--- End of log ---8<---8<---
INFO: Elapsed time: 12.796s, Critical Path: 5.39s
INFO: 645 processes: 477 internal, 12 darwin-sandbox, 156 worker.
```

PR Close #45393
2022-03-24 10:52:12 -07:00
Kristiyan Kostadinov
c9d566ce4b feat(core): drop support for TypeScript 4.4 and 4.5 (#45394)
Drops support for TypeScript older than 4.6 and removes some workarounds in the compiler.

BREAKING CHANGE:
TypeScript versions older than 4.6 are no longer supported.

PR Close #45394
2022-03-24 10:51:47 -07:00
Alan Agius
6eaaefd22e feat(core): drop support for Node.js 12 (#45286)
Node.js v12 will become EOL on 2022-04-30. As a result, Angular CLI v14 will no longer support Node.js v12.

BREAKING CHANGE:

Support for Node.js v12 has been removed as it will become EOL on 2022-04-30. Please use Node.js v14.15 or later.

PR Close #45286
2022-03-08 12:05:03 -08:00
Kristiyan Kostadinov
94bba76a4a feat(core): support TypeScript 4.6 (#45190)
Adds support for TypeScript 4.6.

PR Close #45190
2022-03-07 11:31:39 -08:00
Doug Parker
e0a340ea5b refactor(compiler-cli): remove leftover _extendedTemplateDiagnostics flag (#44920)
This flag is currently a no-op because extended diagnostics are enabled in production.

PR Close #44920
2022-02-01 18:24:10 +00:00
Martin Probst
4e180cb43b refactor(compiler): pass rootDir to tsickle (#44768)
tsickle's underlying API has changed to require passing a rootDir to getGeneratedExterns.
PR Close #44768
2022-01-20 11:16:35 -08:00
Joey Perrott
3c0446cd2d build: update shelljs dependencies to "^0.8.5" (#44697)
Update shelljs dependencies to ^0.8.5 to fix a vulnerability reported to shelljs.

PR Close #44697
2022-01-13 18:27:32 +00:00
Renovate Bot
dff497f78d build: update all non-major dependencies (#44502)
PR Close #44502
2022-01-10 19:55:23 +00:00
Paul Gschwendtner
c46d533b22 build: switch devmode output to es2015 (#44505)
To make our test output i.e. devmode output more aligned
with what we produce in the NPM packages, or to be more
aligned with what Angular applications will usually consume,
the devmode output is switched from ES5 to ES2015.

Additionally various tsconfigs (outside of Bazel) have been
updated to match with the other parts of the build. The rules
are:

ES2015 for test configurations, ES2020 for actual code that will
end up being shipped (this includes the IDE-only tsconfigs).

PR Close #44505
2022-01-05 23:20:20 +00:00
Adam Plumer
79d1afaf5b build: bump license year (#44590)
The year has advanced by one cycle. In accordance with this
practice, we increment the value of the bounding set of our
license year by one.

PR Close #44590
2022-01-04 12:05:25 -08:00
Renovate Bot
6c05c3fd2d build: update all non-major dependencies (#44152)
PR Close #44152
2021-12-14 16:04:34 -05:00
Paul Gschwendtner
98c5063cd8 build: update visibility for npm package targets to work with new integration test structure (#44238)
As mentioned in the previous commit, integration tests will be declared
in subpackages of `//integration`. For these tests to still rely on the
NPM packages from `HEAD`, we need to update the visibility.

PR Close #44238
2021-12-08 13:42:41 -05:00
Alex Rickabaugh
43db24302c refactor(compiler): delete View Engine components of @angular/compiler (#44368)
This commit finishes the removal of View Engine from the codebase, deleting
those pieces of @angular/compiler which were only used for VE.

Co-Authored-By: JoostK <joost.koehoorn@gmail.com>

PR Close #44368
2021-12-06 13:12:36 -05:00
JoostK
4e6281f114 refactor(bazel): remove metadata collection from ngc_wrapped (#44269)
The generated metadata is obsolete now that ViewEngine is no longer
used, so this commit removes the generation of those file from
`ngc_wrapped`. This is needed to allow removal of the metadata collector
in a subsequent commit.

PR Close #44269
2021-12-01 10:36:30 -08: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
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
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
Doug Parker
c55ce75b14 refactor(bazel): always add strictTemplates option to tsconfig.json (#43674)
`strictTemplates` was only conditionally added to the `tsconfig.json` file to avoid breaking the angular/components repo (see https://github.com/angular/angular/pull/43582#issuecomment-928567758). Components has been updated in https://github.com/angular/components/pull/23677, so this condition is no longer necessary and `strictTemplates` can always be included in `tsconfig.json` without breakage.

PR Close #43674
2021-11-19 22:28:03 +00:00
Renovate Bot
891318e805 build: update all non-major dependencies (#43974)
PR Close #43974
2021-11-09 21:00:17 +00:00
Paul Gschwendtner
d965331cf6 refactor(bazel): fix typo in packager action file comments (#44061)
Fixes two typoes in the packager logic.

PR Close #44061
2021-11-05 16:22:17 +00:00
Joey Perrott
78e52b4799 build: remove ivy-aot bazel tag (#43862)
Remove the ivy-aot bazel tag from usage as it served a duplicate purpose as ivy-only which is now removed as both are
unneeded with Ivy as the default compiler used.

PR Close #43862
2021-10-19 10:06:55 -07:00
Joey Perrott
aef63e7ae5 build: remove "ivy-only" bazel tag (#43862)
Because all actions are assumed to be running on Ivy, things which only work on Ivy should not be marked as
Ivy only.

PR Close #43862
2021-10-19 10:06:55 -07:00
Joey Perrott
a365a1f0ff build: rename "no-ivy-aot" tag to "view-engine-only" (#43862)
Using the tag "view-engine-only" better describes the expected usage of bazel targets with the test. They can
only be run with view engine.

PR Close #43862
2021-10-19 10:06:55 -07:00
Renovate Bot
ba4e18b096 build: update all non-major dependencies (#43838)
PR Close #43838
2021-10-15 10:45:02 -07:00
Renovate Bot
49a0b60dc7 build: update dependency @rollup/plugin-commonjs to v21 (#43675)
PR Close #43675
2021-10-13 16:48:46 +00:00
Renovate Bot
4c00e92023 build: update dependency @microsoft/api-extractor to v7.18.15 (#43771)
PR Close #43771
2021-10-08 20:42:42 +00:00
Renovate Bot
35a1705595 build: update all non-major dependencies (#43760)
PR Close #43760
2021-10-07 20:56:11 +00:00
Paul Gschwendtner
e0667efa6e feat(bazel): allow for custom conditions to be set in ng_package targets (#43764)
The APF v13 `ng_package` rule will generate the `exports` field if not
set. Currently it allows for additional subpath entries to be configured
manually. The packager does not allow for custom conditions in subpath
exports which are auto-generated.

This is sometimes useful and necessary though. e.g. in Angular Material,
we also need to expose the index Sass file through a `sass` conditional
that the Webpack Sass loader will pick up. For this, the packager needs
to support manual additional conditions (as long as they do not
conflict).

PR Close #43764
2021-10-07 16:50:49 +00:00
Paul Gschwendtner
e0a0d05d45 feat(core): update node version support range to support v16 (#43740)
This commit updates the `node` engines range for all Angular
framework packages to:

* No longer support NodeJS v12 `< 12.20`. This is done because APF v13
  uses package export patterns which are only supported as of v12.20.
  https://nodejs.org/api/packages.html#packages_subpath_patterns.

* Allows for the latest v16 NodeJS versions. This matches with the CLI
  which added NodeJS v16 support with https://github.com/angular/angular-cli/pull/21854.

  We already limit this to `>= v16.10.0` in preparation to only
  supporting the LTS minors of Node v16.

BREAKING CHANGE: NodeJS versions older than `v12.20.0` are no longer
supported due to the Angular packages using the NodeJS package exports
feature with subpath patterns.

PR Close #43740
2021-10-06 10:55:44 -07:00
Paul Gschwendtner
cd1b52483e feat(bazel): expose esm2020 and es2020 conditions in APF package exports (#43740)
In addition to the existing `exports` conditional exports we ship
as part of APF v13, we want to expose the non-bundled ESM2020 output
through the `esm2020` conditional name. Additionally we will expose
the flat ES2020 files through the `es2020` conditional field, allowing
consumers (like the CLI) to prioritize certain formats.

e.g. consider the case with RXJS where it currently defaults to
the ESM5 output. The CLI could now set `es2015` as the conditional
to leverage the ES2015 output of RXJS. This unveils a problem though
since this would also mean that `ES2015` output of the framework Angular
packages would be used instead of the available ES2020 output. Here is
the additional `es2020` conditional helpful as it allows the CLI to
prioritize `es2020`, fallback to `es2015` and lastly fallback to `default`.
if none do match for a certain package.

PR Close #43740
2021-10-06 10:55:44 -07:00
Kristiyan Kostadinov
c14085e434 feat(core): drop support for TypeScript 4.2 and 4.3 (#43642)
Bumps the minimum required TypeScript version to 4.4.2 and removes the integration tests for 4.1, 4.2 and 4.3.

BREAKING CHANGE:
TypeScript versions older than 4.4.2 are no longer supported.

PR Close #43642
2021-10-05 17:26:37 -07:00
Paul Gschwendtner
dbe656d1e0 fix(bazel): ngc-wrapped should not rely on linker for external workspaces (#43690)
Currently when `ngc-wrapped` runs in external/consumer workspaces, like
in the Angular Components project, the `ngc-wrapped` binary relies on
the linker due to the patched module resolution in `rules_nodejs` no
longer being default. The reliance on the linker of `rules_nodejs` is
problematic for workers as the required `node_modules` are not
re-linked for every build. This was previously not an issue before the
APF v13 changes because the `compiler-cli` module was loaded only once
through an import statement.

As of APF v13, the compiler-cli module is loaded dynamically for every
build. This dynamic import can then break as the worker does not
initially load the compiler-cli module when becoming online. Instead,
the module is loaded on the first build where the node modules might not
be linked properly anymore (due to e.g. other targets running at the same time).

We fix thi issue by doing the following things:

1. Enabling the patched module resolution for consumer/external
   workspaces. This would match how we use ngc-wrapped inside FW as
   well.

2. Caching the compiler CLI module. Instead of re-fetching the module
   through dynamic imports for every build (in a worker), we should use
   the cached version. This is semantically the same as with APF v12
   where a single import statement at file top-level was used.
   Technically, NodeJS should cache the module, but it doesn't hurt
   directly caching it as the module resolution will be patched by
   `rules_nodejs` and could perform unnecessary tasks.

PR Close #43690
2021-10-05 17:25:14 -07:00
Charles Lyding
6d1c2f79da refactor(migrations): ensure CommonJS migrations can be accessed (#43657)
The `@angular/core` migrations are currently published as CommonJS and also not bundled. Schematics, of which migrations are a type, are currently required to be CommonJS modules due to the Schematics Runtime not yet supporting ESM-based schematics. To ensure that the migration files are loaded as CommonJS modules, a nested `package.json` file has been introduced within the `schematics` directory of the package to set the `type` field for all containing JavaScript files as CommonJS. Since the migrations are also not currently bundled and the `devmode` output used to build the migrations will replace all relative imports with fully-qualified module specifiers, an additional `exports` entry must be added to allow the fully-qualified module specifiers to correctly resolve. If `devmode` did not change the relative imports the additional entry would not be needed. Bundling would also remedy the situation and is the long-term path, especially once the migrations are converted to ESM. Additional followup changes should investigate bundling each migration. The additional `exports` entry should be removed if either `devmode` behavior is changed or the migrations are bundled.

PR Close #43657
2021-10-04 16:24:48 -07:00
Paul Gschwendtner
46045ad3fb refactor(bazel): add module interop for CJS/ESM compiler-cli package (#43431)
In the current Bazel setup, we run CommonJS as devmode output, and ESM
for prodmode output. This means that consumers of the
`@angular/bazel` package will end up using the prodmode-built ESM
package of the compiler-cli. This commit adds interop logic to be able
to load the compiler-cli as strict ESM package.

We cannot switch devmode to ESM, as this would require some changes
in `rules_nodejs` and potentially the reduction of both output flavors
into a single one (which is a future project anyway). This is out of
scope for now and inside g3, there is still devmode output as well.

PR Close #43431
2021-10-01 18:28:46 +00:00
Paul Gschwendtner
8d7f1098d8 refactor: make all imports compatible with ESM/CJS output. (#43431)
As outlined in the previous commit which enabled the `esModuleInterop`
TypeScript compiler option, we need to update all namespace imports
for `typescript` to default imports. This is needed to allow for
TypeScript to be imported at runtime from an ES module.

Similar changes are needed for modules like `semver` where the types incorrectly
suggest named exports that will not exist at runtime when imported from ESM.

This commit refactors all imports to match with the lint rule we have
configured in the previous commit. See the previous commit for more
details on why certain imports have been changed.

A special case are the imports to `@babel/core` and `@babel/types`. For
these a special interop is needed as both default imports, or named
imports break the other module format. e.g default imports would work
well for ESM, but it breaks for CJS. For CJS, the named imports would
only work, but in ESM, only the default export exist. We work around
this for now until the devmode is using ESM as well (which would be
consistent with prodmode and gives us more valuable test results). More
details on the interop can be found in the `babel_core.ts` files (two
interops are needed for both localize/or the compiler-cli).

PR Close #43431
2021-10-01 18:28:45 +00:00
Paul Gschwendtner
d15a692789 build: enable esModuleInterop in TypeScript compilations (#43431)
Enables the `esModuleInterop` for all TypeScript compilations in the
project. This allows us to emit proper ESM-compatible code. e.g.
consider the following import:

```ts
import * as ts from 'typescript';
```

This import currently will break at runtime in NodeJS because the
`typescript` package is not shipping ESM. It's still a CommonJS module.
ES modules are able to import from `typescript` though, using an import
statement as above, but everything in `module.exports` is being exposed
as the `default` named export. TypeScript at runtime does not have any
other named exports, so for actual ESM compatibility, all of our imports
need to be switched to:

```
import ts from 'typescript';
```

The `esModuleInterop` option allows this to work even though the
`d.ts` file of TS currently suggests that there are _only_ named exports.
The TypeScript language service will now suggest the correct import form as
shown above. It doesn't enforce that unfortunately, but this commit also
adds a lint rule that enforces certain patterns so that we emit imports
that are compatible with both ESM and CJS output (CJS still needed here
since tests run with CJS devmode output still; this is a future project
to switch that over to ESM!)

PR Close #43431
2021-10-01 18:28:45 +00:00
Paul Gschwendtner
c7d37f74cf build: expose locales as package export for ES module resolution (#43431)
As part of v13, all APF packages use the `exports` field which defines
the public entry-points/mappings for a package. so-called package exports.

The `ng_package` rule creates all the necessary mappings/sub-path exports
for the entry-points of `@angular/common`. Though, since the locale files are
generated separately and are not an actual entry-point, we need to expose these
files publicly so that they can be imported/resolved by consumers.

PR Close #43431
2021-10-01 18:28:44 +00:00
Paul Gschwendtner
c5a5682b06 build: ship locales in @angular/common in ESM format (#43431)
Similar to other code that is shipped as part of `@angular/common`
(with APF v13), we should ship the generated locale files as ESM
files as well. This is necessary/reasonable because we explicitly
set `type: "module"` for the common package, so it makes sense to
have the same apply for the locale sub-directory.

Note: The global locale scripts remain having the `.js` extension
and will continue to be unmodified. They are CJS/ESM compatible either
way, but refer to browser globals.

PR Close #43431
2021-10-01 18:28:44 +00:00
Paul Gschwendtner
0fbd554948 refactor: switch packages away from deep cross-package imports (#43431)
The Angular Core and localize package currently use deep imports for
code that is shipped. This is problematic as we want to ship the
compiler-cli as full-ESM. To achieve this we need to use a bundler and
this breaks deep imports.

We use a bundler for the compiler CLI because for full ESM
compatibility, we would need to explicitly add the `.js` extension
to all relative imports. This is very cumbersome and prone to mistakes
so to mitigate this problem in a safe way, we bundle the compiler-cli.

Note: Deep imports continue to exist for the language service as it
bundles the compiler-cli.

PR Close #43431
2021-10-01 18:28:43 +00:00
Paul Gschwendtner
49b82ae561 feat(bazel): implement partial compilation APF v13 for ng_package rule (#43431)
This commit implements partial compilation APF v13 for the
`ng_package` rule. The changes involve the following things:

1. Requesting the partial compilation output for all targets (and
   its transitives) in the `deps` or `srcs` attributes.

2. Downleveling of ES2020 prodmode output to a FESM2015 file.

3. Cleanup of file resolution. Previusly, execroot file paths (which are
   passed to the packager tool) were composed manually. This is prone to
   mistakes and breaks with transitions.

   A lot of this code can be simplified by passing the necessary Bazel
   `File` information as JSON. This also simplifies the packager tool
   significantly (and makes it more readable..)

4. Remoal of UMD bundles. This also allows us remove the `globals` rule
   attribute with `externals` (we do not need any UMD global identifier
   names anymore).

5. The `package.json` will set the `exports` field and use subpath
   exports to make module resolution work for ESM consumers.

6. TSLib is also always set as `external` now. Previously it had to be
   added as `dep` to the `ng_package` rule as UMD files bundled `tslib`.

7. The `include_devmode_srcs` option has been removed. This option was
   an addition to APF that allowed the `@angular/compiler` to ship
   non-flattened ES5 CommonJS sources. We want to keep APF consistent
   and not allow such exceptions. Compiler is now a strict APF package
   as well, and the compiler-cli just needs to go through the primary
   entry-point for things it needs (or it bundles the necessary parts
   into the CLI.)

Overall, these are all changes. A lot of changes to make the packager
rule and tool more readable and Bazel-idiomatic were made as well. This
allows us to easier make packaging changes in the future, and it's more
future-proof if we ever change how inputs (like `ng_module` targets) are
generated (e.g. consider a case where we'd use the `ts_project` rule).

PR Close #43431
2021-10-01 18:28:42 +00:00
Paul Gschwendtner
b616e74ceb refactor(bazel): no longer generate VE shims for other workspaces by default (#43431)
We should no longer generate VE shims for workspaces which are not named
`angular`. The default is Ivy compilation and this should be opt-in. The
components repository for example does not need any shims as it is using
Ivy for the common development workflows.

PR Close #43431
2021-10-01 18:28:42 +00:00
Paul Gschwendtner
274cb38e0b feat(bazel): switch prodmode output to ES2020 (#43431)
Previously, the prodmode output was using ES2015 for `ng_module` and
`ts_library` targets. This commit changes it to `ES2020`. This is
necessary as we want to ship es2020 output in APF v13.

PR Close #43431
2021-10-01 18:28:42 +00:00
Paul Gschwendtner
e14d73b293 refactor(bazel): pass flat module out file reference to packager (#43431)
In preparation for using the partial compilation transition on the
packager, we need to be able to have a reference to the flat module
out file (that is used as "index" file for entry-point ng_module targets).

We need a reference to the file because with transitions applied, the
inputs are not necessarily in the default `bazel-out` directory. The
packager currently only guesses such paths (this worked most of the
time) but guessing the output directory with transitions will become
impossible.. so the paths need to be computed in a Bazel-idiomatic way.
This is more future-proof and correct (and more clean IMO).

PR Close #43431
2021-10-01 18:28:42 +00:00