2667 Commits

Author SHA1 Message Date
Charles Lyding
60086dbd01 perf(@angular-devkit/build-angular): avoid template diagnostics for declaration files in esbuild builder
The experimental esbuild-based browser application builder will now avoid trying to query the Angular
Compiler for template diagnostics when a TypeScript source file is a declaration file (`.d.ts`). This
avoids the overhead of the in-memory diagnostics caching logic as well as any Angular Compiler logic
to determine if the file has any template diagnostics.
2022-10-25 10:51:01 -07:00
Alan Agius
de8d846b98 docs: replace browserslist with AIO link
https://angular.io/guide/build#configuring-browser-compatibility will be updated to include additional information.
2022-10-24 15:12:42 -07:00
Charles Lyding
2b27679d9c refactor(@angular-devkit/build-angular): show more cumulative metrics for esbuild perf debug output
When the `NG_BUILD_DEBUG_PERF` environment variable is used to debug performance of the experimental
esbuild-based browser application builder, additional information will be logged for cumulative
profiling actions. This includes the count, minimum, maximum, and average.
2022-10-24 08:00:16 -04:00
Charles Lyding
1c87de6d8b perf(@angular-devkit/build-angular): avoid extra TypeScript emits with esbuild rebuilds
To further improve incremental rebuild performance of the experimental esbuild-based browser
application builder, the output of the TypeScript file loader within the Angular compiler plugin
are now cached in memory by the input file name and invalidated via the file watching events.
This allows an additional TypeScript emit including the associated transformations per input file
to be avoided if the file has not changed or has not been affected by other files within the
TypeScript program.
2022-10-24 08:00:16 -04:00
Alan Agius
b29ae2feda fix(@schematics/angular): add @angular/localize as type when localize package is installed
The `@angular/localize` entrypoint now exposes the global `$localize` method type.

See: https://github.com/angular/angular/pull/47763
2022-10-21 10:32:24 -04:00
Alan Agius
708011ea8e build: update all non-major dependencies 2022-10-21 10:24:39 -04:00
Angular Robot
30ce7435d6 build: update all non-major dependencies to v0.15.11 2022-10-17 10:33:42 +02:00
Alan Agius
c49f1eea62 fix(@angular-devkit/build-angular): resolve transitive dependencies in Sass when using Yarn PNP
Enhanced resolver is unable to resolve transitive dependencies in Sass when using Yarn PNP. The main reason for this is that Sass doesn't provide context on which file is requesting the module. See: sass/sass#3247.

As a workaround for this we store previously resolved paths and when a new request comes in we try to resolve this from the previously resolved files if we are unable to resolve the request from the workspace root.
2022-10-14 16:05:53 +02:00
Alan Agius
96551365e2 fix(@angular-devkit/build-angular): add @angular/platform-server as an optional peer dependency
`@angular/platform-server` is now an optional peer dep due to the recent changes in 1cd53d6be1/packages/angular_devkit/build_angular/src/builders/server/index.ts (L182)
2022-10-14 15:47:02 +02:00
Angular Robot
ef5b40f7e4 build: update all non-major dependencies 2022-10-14 10:01:11 +02:00
Angular Robot
c95bab80d0 build: update dependency cacache to v17 2022-10-14 10:00:42 +02:00
Charles Lyding
717bd03de6 fix(@angular-devkit/build-angular): account for package.json exports fields with CSS import statements
The `postcss-imports` package was previously used to support `@import` within CSS files. Unfortunately,
the package does not account for `package.json` exports fields. This prevents imports defined within that
field from working when used within a build.  The `css-loader` package does provide this functionality and
is now used to provide support for CSS `@import` instead of `postcss-imports`. This change does not affect
preprocessors that provide their own import behavior.
2022-10-14 09:36:08 +02:00
Alan Agius
5954d240fa fix(@angular-devkit/build-angular): only import karma when running karma builder
Karma is an optional peer dependency, but with the recent changes we broke this as we imported karma outside of the execution method, which made this package to be always imported even when the Karma builder was not invoked.
2022-10-13 15:25:20 +02:00
Charles Lyding
2adeb6fbf2 perf(@angular-devkit/build-angular): use Uint8Arrays for incremental caching with esbuild-based builder
When using the experimental esbuild-based browser application builder in watch mode, the in-memory
incremental caching will now use Uint8Arrays where possible to limit the amount of encoding needed
when passing data to esbuild. When passing a string to esbuild, it must encode the string prior to
sending it. By providing the pre-encoded data from the in-memory cache, this step can be skipped
for rebuilds of input files that have not changed.
2022-10-13 12:02:53 +02:00
Angular Robot
e7189f6e88 build: update dependency postcss to v8.4.18 2022-10-13 12:02:20 +02:00
Alan Agius
e34bfe5eb1 fix(@angular-devkit/build-angular): ignore specs in node_modules when finding specs
Some libraries ship spec in node_modules which might result errors such

```
./node_modules/comment-parser/tests/unit/spacer-description-joiner.spec.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: /Users/kkostadinov/Projects/material.angular.io/node_modules/comment-parser/tests/unit/spacer-description-joiner.spec.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
```
2022-10-12 16:06:19 +02:00
Alan Agius
3d253e3b4a test: remove node16-broken from app-shell unit test
This is no longer the case and thus this test can be enabled.
2022-10-12 15:32:13 +02:00
Alan Agius
979bce45e6 feat(@angular-devkit/build-angular): auto include @angular/platform-server/init during server builds
This changes removes the need to import `@angular/platform-server/init` in the `main.server.ts` instead we now include this as an entry-point when we are bundling as server bundle.
2022-10-12 08:57:29 +02:00
Alan Agius
a95d130ef4 feat(@angular-devkit/build-angular): auto include @angular/localize/init when found in types
With this change we remove the need to include the `@angular/localize/init` package as polyfills in `polyfills.ts`, `angular.json` and `main.server.ts`.

Instead when `@angular/localize/init` is included in the TypeScript `types` we add this as entry-point. The `@angular/localize/init` will be added as a parts of the `types` array in a seperate PR to address https://github.com/angular/angular/issues/47677 which is caused by the fact that `@angular/localize/init` types are no longer imported when `@angular/localize/init` is added as a polyfill in `angular.json`.
2022-10-12 08:57:29 +02:00
Charles Lyding
52db3c0007 perf(@angular-devkit/build-angular): minimize Angular diagnostics incremental analysis in esbuild-based builder
When using the experimental esbuild-based browser application builder, the Angular diagnostic analysis performed
per rebuild is now reduced to only the affected files for that rebuild. A rebuild will now query the TypeScript
compiler and the Angular compiler to determine the list of potentially affected files. The Angular compiler will
then only be queried for diagnostics for this set of affected files instead of the entirety of the program.
2022-10-12 08:27:54 +02:00
Charles Lyding
1518133db3 fix(@angular-devkit/build-angular): use relative sourcemap source paths for Sass in esbuild builder
The Sass preprocessor's modern API will generate absolute file URLs for the `sources` field of generated
sourcemaps. These URLs will not be properly processed by esbuild and will not be correctly adjusted to be
relative to the workspace root directory for the built application. To correct this behavior, the Sass
generated sourcemaps are now adjusted to remove the `file:` protocol prefix and to make each path relative
to its input file. This allows esbuild to properly resolve and process the paths.
2022-10-11 22:09:50 +02:00
Alan Agius
4fcb0a82b5 fix(@angular-devkit/build-angular): correctly resolve Sass partial files in node packages
Prior to this change non relative partial files were not resolved properly. Example we did not try to resolve `@material/button/button` as `@material/button/_button` which caused the compilation to fail.
2022-10-11 20:15:02 +02:00
Alan Agius
124be1cc9c refactor: add build and rebuild related statistics and analytics
The new build and rebuild statistics are used by the CLI to submit build related information to GA.
2022-10-11 18:52:30 +02:00
Alan Agius
c969152de6 refactor: remove analytics API from core and architect
All analytics is now in the @angular/cli package

BREAKING CHANGE: analytics APIs have been removed without replacement from `@angular-devkit/core` and `@angular-devkit/architect`.
2022-10-11 18:52:30 +02:00
Alan Agius
639a3071c3 refactor: migrate analytics collector to use GA4
This change updates the analytics collector collector to use GA4 instead of UA. The motivation behind this change is that UA will stop collecting data in 2023.

BREAKING CHANGE:

`analyticsSharing` option in the global angular configuration has been
removed without replacement. This option was used to configure the Angular CLI to  access to your own users' CLI usage data.

If this option is used, it can be removed using `ng config --global cli.analyticsSharing undefined`.
2022-10-11 18:52:30 +02:00
Alan Agius
6c3f281d92 fix(@angular-devkit/build-angular): show warning when using TypeScript target older then ES2022 in esbuild builder
This commits adds a warning similar to that in the Webpack builder.
2022-10-11 16:46:56 +02:00
Charles Lyding
0d97c05115 refactor(@angular-devkit/build-angular): add debug profiling support to esbuild angular compiler plugin
When using the experimental esbuild-based browser application builder, initial debug performance profiling
information can now be output to the console by using the `NG_BUILD_DEBUG_PERF` environment variable. When
enabled, duration information for elements of the Angular build pipeline will be shown on the console.
Certain elements marked with an asterisk postfix represent the total parallel execution time and will
not correlate directly to the total build time. This information is useful for both experimentation with
build process improvements as well as diagnosing slow builds.
2022-10-11 12:30:37 +02:00
Angular Robot
8ccf87308e build: update all non-major dependencies 2022-10-11 10:55:54 +02:00
Charles Lyding
484cda5f9e fix(@angular-devkit/build-angular): isolate zone.js usage when rendering server bundles
When generating an app-shell via the app-shell builder, the server application rendering
will now take place within a Node.js Worker. Since the rendering requires the presence of
Zone.js, this change allows for the Zone.js patching to be isolated from the remainder
of the builder and Angular CLI code. This prevents Zone.js from persisting past the needed
render operation. This also allows for a workaround to a Zone.js/Node.js v18 problem where
the TypeScript dynamic import workaround involving the Function constructor to ensure a native
dynamic import expression will cause a failure when running on Node.js v18.10.
2022-10-10 17:18:16 +02:00
Angular Robot
cdf78d4641 build: update all non-major dependencies 2022-10-10 12:22:40 +02:00
Alan Agius
fd41753579 feat(@angular-devkit/build-angular): drop support for TypeScript 4.6 and 4.7
This commit drops support for TypeScript 4.6 and 4.7

BREAKING CHANGE: TypeScript versions older than 4.8.2 are no longer supported.
2022-10-07 10:37:21 -04:00
Angular Robot
cd1ae437e3 build: update all non-major dependencies 2022-10-07 10:36:46 -04:00
Charles Lyding
212609e81e refactor(@angular-devkit/build-angular): use high resolution time for esbuild builder completion time
Update the build time calculation for the experimental esbuild-based browser application builder to
use the `process.hrtime` time source.  The high resolution time provides a more accurate time source
and allows for nanosecond level timings if needed.  Currently the console output is rounded to the
nearest millisecond. Future performance monitoring capabilities may leverage the more fine-grained
values.
2022-10-07 10:35:11 -04:00
Alan Agius
f79f8b1d71 test: update colors in inlineStyleLanguage test
`color: green` is not part of the compiler code https://github.com/angular/angular/compare/15.0.0-next.4...15.0.0-next.5#diff-6051c2c8a3dc4a133880a8344097be738955132464028402155390c38e0ad18aR197 which causes our tests to fail. This replaces color `green` with another color `indianred`.
2022-10-06 13:43:33 -04:00
Charles Lyding
8c915d4149 perf(@angular-devkit/build-angular): avoid extra babel file reads in esbuild builder rebuilds
To further improve incremental rebuild performance of the experimental esbuild-based browser
application builder, the output of JS file babel transformations are now cached in memory by
the input file name and invalidated via the file watching events. This allows an additional
file read per JS input file to be avoided if the file has not changed. Previously the content
of the JS input file was used as the basis of the cache key for the transformation output which
necessitated reading the file. With the file change information available, the content based method
is no longer necessary.
2022-10-06 09:10:59 -04:00
Angular Robot
24bcfaaca1 build: update all non-major dependencies 2022-10-05 09:55:07 -04:00
Charles Lyding
67324b3e58 feat(@angular-devkit/build-angular): add initial incremental code rebuilding to esbuild builder
The experimental esbuild-based browser application builder will now support incremental JavaScript
bundling when run in watch mode via the `watch` option. This initial implementation integrates the
esbuild incremental rebuild functionality. TypeScript source file caching has also been added to
improve the rebuild initialization time for the TypeScript and Angular compilation steps.
This initial support is not yet fully optimized and additional work is planned to further improve
the rebuild performance.
2022-10-05 07:47:13 -04:00
Charles Lyding
e02d718170 refactor(@angular-devkit/build-angular): use single normalized options object in esbuild builder
A single options object is now used within the experimental esbuild-based browser application builder.
This removes the need to pass around two different options objects with potentially overlapping properties
throughout the build process.
2022-10-04 09:15:52 -04:00
Charles Lyding
fc1164b5fd refactor(@angular-devkit/build-angular): move more esbuild option setup into normalize option helper
The initial global stylesheet, file replacement, index HTML, and service worker option analysis and cleanup has
now been moved into the `normalizeOptions` helper for the esbuild-based browser application builder. This better
organizes the option related setup steps as well as reduces the amount of code in the main builder source file.
2022-10-04 09:15:52 -04:00
Charles Lyding
648e6d6b86 refactor(@angular-devkit/build-angular): prepare esbuild angular plugin for incremental rebuilds
This adds the initial infrastructure to support incremental esbuild rebuilds within the Angular
compiler plugin. Currently, these changes will not yet have an effect on the watch mode rebuild
performance. Integration of esbuild's incremental rebuild mode will be needed within the builder
itself to take advantage of these changes.
2022-10-03 10:42:08 -04:00
Charles Lyding
7f27908a7e refactor(@angular-devkit/build-angular): centralize babel transformation in esbuild-based builder
The Babel transformation code was mostly duplicated in two places within the esbuild-based browser
application builder. The code has now been extracted into a helper function and used where needed.
2022-10-03 10:42:08 -04:00
Charles Lyding
3d94ca21bb feat(@angular-devkit/build-angular): add initial watch support to esbuild-based builder
The experimental esbuild-based browser application builder now contains initial support for
watching input files and rebuilding the application via the `--watch` option. This initial
implemention is not yet optimized for incremental rebuilds and will perform a full rebuild
upon detection of a change. Incremental rebuild support will be added in followup changes
and will significantly improve the rebuild speed.
The `chokidar` npm package is used to perform the file watching which allows for native file-
system event based watching. Polling is also support via the `--poll` option for environments
that require it.
2022-10-03 10:42:08 -04:00
Angular Robot
1a4615c787 build: update all non-major dependencies 2022-09-30 16:23:52 +02:00
minijus
f9a2c3a121 fix(@angular-devkit/build-angular): allow both script and module sourceTypes to be localized 2022-09-30 16:23:39 +02:00
Alan Agius
b6df9c1367 fix(@angular-devkit/build-angular): handle conditional exports in scripts and styles option
With this change scripts and styles options better support Yarn PNP resolution.

Closes #23568
2022-09-30 08:56:54 +02:00
Alan Agius
2b60292453 feat(@angular-devkit/build-angular): providing a karma config is now optional
Karma will now use a builtin config when the `karmaConfig` is not specified.
2022-09-28 17:37:53 +02:00
Alan Agius
8f8e02c322 fix(@angular-devkit/build-angular): support Yarn PNP resolution in modern SASS API
This change add a Sass File importer that uses Webpack resolvers to better support scenarios when node packages are not stored in node_modules, such as Yarn PNP.
2022-09-28 17:37:33 +02:00
Alan Agius
15355a8576 test: reduce polling test median greatest value
This is an effort to reduce the flakiness of this test.
2022-09-28 17:16:45 +02:00
Alan Agius
fb5a66ae66 fix(@angular-devkit/build-angular): fix crash when Sass error occurs
In some cases the build will crash when there is a Sass error due to the fact that the `span` property on the Error instance cannot be cloned.

```
  process.nextTick(() => { throw err; });
                           ^

DataCloneError: function StaticClosure() {
    } could not be cloned.
    at MessagePort.<anonymous> (/node_modules/@angular-devkit/build-angular/src/sass/worker.js:61:41)
```
2022-09-28 15:28:15 +02:00
Angular Robot
89b86f37dc build: update all non-major dependencies 2022-09-28 09:19:16 +02:00