Commit graph

590 commits

Author SHA1 Message Date
Payam Valadkhan
5feed80523 refactor(bazel): make option generateExtraImportsInLocalMode configurable (#53543)
This is to allow testing this option using bazel

PR Close #53543
2024-01-30 15:05:42 +00:00
Joey Perrott
ec03e462f3 refactor: migrate bazel, benchpress, elements and misc to prettier formatting (#53995)
Migrate formatting to prettier for bazel, benchpress, elements and misc from clang-format

PR Close #53995
2024-01-22 09:07:15 +01:00
Andrew Kushnir
d28cf00df6 refactor(compiler-cli): add an internal config to enforce explicit deps in @defer for local compilation mode (#53591)
This commit adds an internal config option to enforce explicit deps in `@defer` for local compilation mode.

PR Close #53591
2024-01-10 15:28:58 -08:00
Payam Valadkhan
59ba2a6e9f feat(bazel): make forbidOrphanComponents option configurable (#52061)
Now users can configure the option `forbidOrphanComponents` in the tsconfig's angularCompilerOptions part.

PR Close #52061
2023-10-10 15:30:26 -07:00
Matthieu Riegler
c2f270cf14 refactor(compiler): Delete the @angular/compiler/testing module. (#49872)
The package was removed in components, it can now be deleted here also.

PR Close #49872
2023-10-09 15:58:25 -07:00
Kristiyan Kostadinov
43e6fb0606 feat(core): enable block syntax (#51994)
Enables the new `@` block syntax by default by removing the `enabledBlockTypes` flags. There are still some internal flags that allow special use cases to opt out of the block syntax, like during XML parsing and when compiling older libraries (see #51979).

PR Close #51994
2023-10-03 15:26:05 -07:00
Paul Gschwendtner
cb545807bc fix(bazel): allow setting _enabledBlockTypes angular compiler option (#51862)
We control most flags via Starlark and therefore limit configuration
options via `tsconfig` to a minimum. We do not intend to support the
enabled block types option via Starlark, so this commit allows for
the option to be picked up.

(This is useful for benchmarking the new control flow blocks).

PR Close #51862
2023-09-22 09:51:25 -07:00
Paul Gschwendtner
a6b7dbc1db fix(bazel): dedupe es2022 javascript files properly (#51500)
We were collecting all ES2022 files from entry-points (including
transitive files). Those are later on combined and filtered so that
we know which files to copy over to the package. There was no
deduping here. This did not have an effect, but could be a source
of slowness in `ng_package` and also breaks validation checks which
could show same errors multiple times for the same file.

PR Close #51500
2023-08-29 17:55:34 +00:00
Paul Gschwendtner
9aa71cc8e0 feat(bazel): prohibit cross entry-point relative imports (#51500)
Introduces a check into `ng_package` that will ensure that there are no
cross entry-point or cross-package relative imports that would end up
contributing to duplicate code. Not only would duplicate code result in
size increases, but also it could cause subtle hard-to-debug bugs,
especially when cross imports rely on e.g. singletons. Like for example
the deps tracker that is used in angular/core but also in
angular/core/testing.

PR Close #51500
2023-08-29 17:55:34 +00:00
Paul Gschwendtner
552ea77854 refactor(compiler-cli): drop tsickle code paths (#50602)
`tsickle` is not used in any code paths in 3P and we can remove
this complexity. The `tsickle` npm package has not been released
in a while and we are risking breakages with e.g. future TypeScript
versions.

Note that the `ng_module` rule was updated to not emit through
tsickle at all. The tsickle in 1P is done directly by `tsc_wrapped`
and our code path in `compiler-cli` is not needed at all.

PR Close #50602
2023-08-17 10:23:49 -07:00
Payam Valadkhan
8506cf426c refactor(bazel): Circuit out ts semantic check in local mode compilation (#50486)
In local mode compilation the TS semantic check issues tons of diagnostics due to the fact that the file dependencies (.d.ts files) are not available in the program. So it needs to be disabled.

This commit should not cause any issue for the exsiting projects as it just removes a diagnostic in the local compilation mode.

PR Close #50486
2023-06-07 12:50:54 -07:00
Alan Agius
6e26af52fa feat(bazel): (APF) Angular Package Format updates (#49559)
Several updates to Angular Package Format.

BREAKING CHANGE:

Several changes to the Angular Package Format (APF)
- Removal of FESM2015
- Replacing ES2020 with ES2022
- Replacing FESM2020 with FESM2022

PR Close #49559
2023-03-23 08:18:45 -07:00
Andrew Scott
07cbaa3e28 Revert "feat(bazel): (APF) Angular Package Format updates (#49332)" (#49555)
This reverts commit 842d569a94.

PR Close #49555
2023-03-22 16:01:20 -07:00
Alan Agius
842d569a94 feat(bazel): (APF) Angular Package Format updates (#49332)
Several updates to Angular Package Format.

BREAKING CHANGE:

Several changes to the Angular Package Format (APF)
- Removal of FESM2015
- Replacing ES2020 with ES2022
- Replacing FESM2020 with FESM2022

PR Close #49332
2023-03-22 14:00:19 -07:00
Andrew Kushnir
83a6e203e3 refactor(compiler): drop obsolete NgFactory and NgSummary config options (#48268)
The options to generate NgFactory and NgSummary files were added to Ivy for backwards compatibility with ViewEngine. Since ViewEngine was deprecated and removed, the NgFactory and NgSummary files are no longer used as well.

This commit drops obsolete options to generate NgFactory and NgSummary files. Also, the logic that generates those files is also removed.

PR Close #48268
2023-02-21 13:03:59 -08:00
Paul Gschwendtner
b6e3840ed4 refactor(bazel): remove unnecessary banner stamping code (#48798)
The `ng_package` rule supports replacing `0.0.0-PLACEHOLDER`
in license files that are inserted as part of rollup. This
requires additional logic to detect stamping, reading the status
files and then replacing the placeholder.

All of this already handled as part of normal package substitutions
and we can replace this unnecessary complexity.

See: da50feb23f/internal/pkg_npm/pkg_npm.bzl (L195)

PR Close #48798
2023-01-20 18:39:22 +00:00
Payam Valadkhan
08b72b77e3 refactor(bazel): Extract the helper patchNgHostWithFileNameToModuleName to its own file for 1P use (#48739)
Some 1P tools require to use the helper patchNgHostWithFileNameToModuleName, and the present location of this helper leads to circular depedency. So it is required to move this helper into a separate module to facilitate importing.

PR Close #48739
2023-01-19 17:34:57 +00:00
Paul Gschwendtner
1898190c28 build: update ng-dev and account for stamping changes (#48731)
* updates ng-dev and build-tooling since the previous SHAs are
no longer existent after the CircleCI incident snapshot build removal.
* accounts for the new stamping variables.

PR Close #48731
2023-01-13 14:10:39 +00:00
Doug Parker
edd7982d51 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
Alan Agius
82d0998968 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
9add063c17 refactor: update packages/bazel npm artifact to not rely on defaults.bzl (#48521)
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 #48521
2022-12-19 19:50:45 +00:00
Paul Gschwendtner
90c2088679 build: make devmode a noop and ensure it never runs (#48521)
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 #48521
2022-12-19 19:50:45 +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
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
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
Derek Cormier
b4c40c5d55 build(bazel): merge aio/tools/defaults.bzl and tools/defaults.bzl
Detect the correct workspace for the source maps dep.
2022-11-22 13:51:16 -07:00
Derek Cormier
22a317de3d build(bazel): stamp targets to build, test, and serve aio against
first party deps

Architect is not compatible with disabling the rules_nodejs linker so
these targets must use npm_link to link first party deps
2022-11-22 13:51:16 -07:00
Paul Gschwendtner
11288f2504 refactor(bazel): enable typescript strictness flags for package (#47893)
No longer maintains a separate tsconfig for the Bazel package. This
seems to be a legacy artifact back when ngc-wrapped was put into GitHub.

We now use the canonical repository Bazel tsconfig. This commit also
fixes all strictness-related errors and makes ngc-wrapped compatible.

PR Close #47893
2022-11-01 04:44:28 -07:00
Alan Agius
16f96eeabf refactor(compiler-cli): remove enableIvy options (#47346)
This option has no longer any effect as Ivy is the only rendering engine.

BREAKING CHANGE: Angular compiler option `enableIvy` has been removed as Ivy is the only rendering engine.

PR Close #47346
2022-09-06 11:33:48 -07:00
Kristiyan Kostadinov
ac6e7fa97e fix(bazel): allow extendedDiagnostics option to be passed in through tsconfig (#46953)
Adds the `extendedDiagnostics` field to the list of allowed options so that it is picked up from the user's tsconfig.

PR Close #46953
2022-08-01 09:49:14 -07:00
Doug Parker
4e328c47be refactor(bazel): remove experimental_extended_template_diagnostics flag (#46898)
Extended diagnostics are enabled by default now and this flag doesn't do anything anymore but I missed it in a previous cleanup.

PR Close #46898
2022-07-20 08:50:43 -07:00
Paul Gschwendtner
f74bd1b0f5 perf(bazel): reduce input files for ng_package rollup and type bundle actions (#46187)
We currently use all the ESM2020 and type sources as inputs for rollup
and type bundle actions, respectively. This is a source of slowness in
Bazel sandboxed builds because many unused files will be linked/made
available for many concurrently-running actions.

We should limit the inputs only to what is assumed to be used. We cannot
know exactly and need to include transitive types from `node_modules`,
but that is an inevitable construct with the current Bazel rules.

Note that the external node modules could still bring in a lot of files,
like in Material where the `.d.ts` files for all locales are brought
into the sandbox (from `@angular/common`). We likely would need to
remove these files in a postinstall for now, to speed up actions,
similar to how we did it for RxJS in all repositories. These are known
to be not used in the components repo.

PR Close #46187
2022-06-02 13:43:22 -07:00
Jan Kuehle
7efa09b401 perf(bazel): use allowedInputs to avoid fs.stat (#46069)
Call tsc_wrapped's fileExists function instead of TypeScript's.

tsc_wrapped (used internally by ngc-wrapped) has an optimization under
bazel to avoid file system calls where possible. It takes advantage
bazelOpts.allowedInputs, which contains a list of all files available
for compilation.

File system calls can be quite slow depending on the file system. In
google3 I saw a 38 seconds compilation, which spent 6 seconds just doing
fs.stat calls during module resolution. Those fs.stat calls are entirely
gone after with this change.

PR Close #46069
2022-05-24 10:39:17 -07:00
Paul Gschwendtner
bd91572986 build: lock file maintenance to avoid node module differences for babel types (#45967)
We recently updated Babel and the Bazel types but this actually
resulted in duplicates, causing differences between what people
seen in their IDE vs. what Bazel builds.

This commit removes the lock file and generates it fully fresh,
deduping dependencies and also fixing the differences between
local IDE and Bazel.

As part of this we also need to update/fixup one assertion on the
Babel node path types, because the node start/end can now also
be `undefined`.

PR Close #45967
2022-05-20 14:18:09 -07:00
Roy Dorombozi
6375fa7987 refactor(bazel): add support for starlark's unused_inputs_list (#45946)
This change adds the capability of ngc_wrapped to emit an
unused_inputs_list file that could be used by starlark.

We are making this change because in situations where angular modules
depend on angular modules, it becomes very easy for a single change to
trigger a long cascading set of angular builds since each angular rule
depends on the transitive closure of input files.

With this change in place, and once it is properly configured, bazel
will update the set of inputs to a build rule after it is built once
removing any of the inputs specified in this list, making incremental
builds quicker by skipping any rebuilds that only had changes to unused
inputs.

This logic should be, and is likely duplicated in tsc_wrapped to solve
the same problem in pure TypeScript situations, ideally we could use the
same implementation one day.

In addition, its possible that tree artifacts are not as supported as
we'd like, and where this change should mark entire directories as
unused, we may get better performance gains by enumerating the directory
and being more explicit about specific inputs which are unused.

PR Close #45946
2022-05-11 11:21:56 -07:00
Paul Gschwendtner
a6b6590339 fix(bazel): speed up d.ts bundling by configuring worker (#45900)
Speeds up the `d.ts` bundling by configuring it as a Bazel
persistent worker. Also improve logging for the ng packager
rule to make it easier to spot which actions/bundles take
up significant time.

Type bundling will occur for every entry-point so for machines
with rather limited cores/threads, this will be useful to save
NodeJS boot and resolution time.

PR Close #45900
2022-05-05 15:35:14 -07:00
Paul Gschwendtner
68a6a075f4 build: clean up references to old master branch (#45856)
Cleans up all references to the `master` branch we renamed to
`main` across Angular.

PR Close #45856
2022-05-04 16:23:33 -07:00
Paul Gschwendtner
95555658cf build: disable bazel nodejs linker to improve stability on windows (#45872)
The NodeJS Bazel linker does not work well on Windows because there
is no sandboxing and linker processes from different tests will attempt
to modify the same `node_modules`, causing concurrency race conditions
and resulting in flakiness.

PR Close #45872
2022-05-04 16:20:57 -07:00
Ryan Day
f0b5e830a5 build(bazel): change ngc-wrapped to use new bazelOpts.devmode (#45804)
bazelOpts.es5Mode is being removed and replaced with devmode. Adding a
check for either will allow a smooth migration.

PR Close #45804
2022-05-02 13:10:06 -07:00
Joey Perrott
970a3b5c70 fix(bazel): add this_is_bazel marker (#45728)
Add marker for noting that this check confirms we are running in a bazel environment.

PR Close #45728
2022-04-22 12:46:23 -07:00
Paul Gschwendtner
68597bb0ca feat(bazel): speed up dev-turnaround by bundling types only when packaging (#45405)
Speeds up the dev-turnaround by only bundling types when packaging. Currently
bundling occurs for all the `ng_module` targets in devmode.

This has various positive benefits:

* Avoidance of this rather slower operation in development
* Makes APF-built packages also handle types for `ts_library` targets consistently.
* Allows us to ensure APF entry-points have `d.ts` _always_ bundled (working with ESM
module resolution in TypeScript -- currently experimental)
* Allows us to remove the secondary `package.json` files from APF (maybe APF v14? - seems
low-impact). This would clean-up the APF even more and fix resolution issues (like in Vite)

PR Close #45405
2022-04-21 11:09:39 -07:00
Paul Gschwendtner
f8a1ea0c11 fix(bazel): do not error if files part of srcs are outside of package (#45622)
We recently refactored how the ng package rule deals with static files.
As part of this refactoring, transitive files outside of the current
Bazel package were flagged as errors, while previously this was just
ignored. We need to revert back this behavior (even though code remains
much simpler and predicable now) since sass library targets for example
reference all transtive files in the default info and break packages then

PR Close #45622
2022-04-14 14:58:27 -07:00
Paul Gschwendtner
1219c5a374 refactor(bazel): fix dts bundling by accounting for api-extractor change (#45470)
Fixes the dts bundling by accounting for recent API extractor changes
which made API-extractor support path mappings. This causes
cross-package and cross-entry-point imports to no longer be considered
external, resulting in the imports to be dropped.

PR Close #45470
2022-04-11 21:01:09 +00:00
Paul Gschwendtner
4b2e98d55d fix(bazel): remove unnecessary file extractions from ng_package (#45470)
Looks like there is some old legacy code for extracting files
from NPM packages. This is already captured by the unscoped
ESM2020 output extraction.

PR Close #45470
2022-04-11 21:01:09 +00:00
Paul Gschwendtner
28e835b4bb feat(bazel): report error when dependency does not provide JS sources in ng_package (#45470)
Non-JavaScript source-providing targets in the `ng_package` rule can throw-off
the entry-point detection and therefore should be flagged. Currently e.g.
a genrule-generated static file might unnecessarily cause additional
actions to be generated (non-breaking but just unnecessary)

PR Close #45470
2022-04-11 21:01:09 +00:00
Paul Gschwendtner
636909fba7 feat(bazel): allow for generated package.json files in ng_package (#45470)
Currently the `ng_package` rule does not support generated
`package.json` files. Generated `package.json` files are sometimes
useful when e.g. dependencies are automatically inserted (e.g.
many dependencies in the components repo for the MDC deps)

Currently the `package.json` files would be copied as part of
the `data` attribute, but they would not be processed. i.e. missing
out on the `exports` field and more.

We can simplify the rule attributes and make this more ergonomic.

PR Close #45470
2022-04-11 21:01:09 +00:00
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