3036 Commits

Author SHA1 Message Date
Alan Agius
26456b93d5 fix(@angular-devkit/build-angular): do not print Angular is running in development mode. in the server console when using dev-server
This commit disables logging `Angular is running in development mode.` when using SSR with vite dev-server. This to avoid polluting the server console with `Angular is running in development mode.` logs for each page load and reload.

Example:
```
ng s

Initial Chunk Files | Names         | Raw Size
main.js             | main          | 34.31 kB |
polyfills.js        | polyfills     | 95 bytes |
styles.css          | styles        | 95 bytes |

                    | Initial Total | 34.49 kB

Application bundle generation complete. [5.205 seconds]

  ➜  Local:   http://localhost:4200/
Watch mode enabled. Watching for file changes...
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
Angular is running in development mode.
```
2023-09-27 18:58:31 +02:00
Alan Agius
6b5c469a42 build: update all non-major dependencies 2023-09-27 14:08:41 +02:00
Charles Lyding
c3a87a60e0 feat(@angular-devkit/build-angular): support basic web worker bundling with esbuild builders
When using the esbuild-based builders (`application`/`browser`), Web Workers that use the supported
syntax will now be bundled. The bundling process currently uses an additional synchronous internal
esbuild execution. The execution must be synchronous due to the usage within a TypeScript transformer.
TypeScript's compilation process is fully synchronous. The bundling itself currently does not provide
all the features of the Webpack-based builder. The following limitations are present in the current
implementation but will be addressed in upcoming changes:
* Worker code is not type-checked
* Nested workers are not supported
2023-09-22 16:47:55 +02:00
Alan Agius
61f409cbe4 perf(@angular-devkit/build-angular): disable ahead of time prerendering in vite dev-server
When using the devserver, instead of prerendering every page for every incremental change, we now perform a server rendering on the page during request time. This ensures that incremental build times are faster when prerending is enabled as we avoid rendering of pages that are never viewed.
2023-09-22 15:41:58 +02:00
Charles Lyding
c5f3ec71f5 feat(@angular-devkit/build-angular): support i18n inlining with esbuild-based builder
When using the esbuild-based application build system through either the `application`
or `browser-esbuild` builder, the `localize` option will now allow inlining project
defined localizations. The process to configure and enable the i18n system is the same
as with the Webpack-based `browser` builder. The implementation uses a similar approach
to the `browser` builder in which the application is built once and then post-processed
for each active locale. In addition to inlining translations, the locale identifier is
injected and the locale specific data is added to the applications. Currently, this
implementation adds all the locale specific data to each application during the initial
building. While this may cause a small increase in the polyfills bundle (locale data is
very small in size), it has a benefit of faster builds and a significantly less complicated
build process. Additional size optimizations to the data itself are also being
considered to even further reduce impact. Also, with the eventual shift towards the standard
`Intl` web APIs, the need for the locale data will become obsolete in addition to the build
time code necessary to add it to the application.
While build capabilities are functional, there are several areas which have not yet been
fully implemented but will be in future changes. These include console progress information,
efficient watch support, and app-shell/service worker support.
2023-09-22 10:48:17 +02:00
Charles Lyding
ccdd268d7e refactor(@angular-devkit/build-angular): avoid double emit of TypeScript files in AOT with esbuild
Some TypeScript files may previously have been emitted twice during builds when using the Angular compiler
esbuild plugin used within the esbuild-based browser application builder. It did not cause any build problems.
However, it may have caused builds to take longer than expected. This was caused by an incorrect comparison of the
transformed source file and the original source file found within the TypeScript program. Comparisons during
emit now compare only original source files which avoids the issue with the emitted files checks.
2023-09-21 11:02:20 +02:00
Charles Lyding
8bce80b91b feat(@angular-devkit/build-angular): initial support for application Web Worker discovery with esbuild
When using the esbuild-based builders (application/browser-esbuild), Web Workers following the previously
supported syntax as used in the Webpack-based builder will now be discovered. The worker entry points are not
yet bundled or otherwise processed. Currently, a warning will be issued to notify that the worker will not
be present in the built output.
Additional upcoming changes will add the processing and bundling support for the workers.

Web Worker syntax example: `new Worker(new URL('./my-worker-file', import.meta.url), { type: 'module' });`
2023-09-21 11:02:20 +02:00
cexbrayat
4e89c3cae4 fix(@angular-devkit/build-angular): use a dash in bundle names
This updates the esbuild based builder to use a dash in bundles and media instead of a dot to be consistent with the chunks files `chunk-xxx.js`.
2023-09-21 10:58:48 +02:00
Alan Agius
f9fdd0907c refactor(@angular-devkit/build-angular): use ɵloadChildren helper from router package
This commit updates the routes extractor to use the newly exported private `ɵloadChildren` method from the router to executes a `route.loadChildren` callback and return an array of child routes.

See: https://github.com/angular/angular/pull/51818
2023-09-21 07:02:17 +02:00
Alan Agius
1c00fd3fe9 refactor: drop support for older TypeScript versions
Drops support for versions of TypeScript older than 5.2

BREAKING CHANGE:
Versions of TypeScript older than 5.2 are no longer supported.
2023-09-20 21:27:35 +02:00
Alan Agius
c0eb2eb5fd build: update Angular to 17.0.0-next.5 2023-09-20 21:27:35 +02:00
cexbrayat
fe64193b78 refactor(@angular-devkit/build-angular): typo in ignore list plugin function 2023-09-20 19:48:55 +02:00
Alan Agius
8168ae2a89 feat(@angular-devkit/build-angular): apply global CSS updates without a live-reload when using vite
This commit changes the way that global style updates are applied when using `vite`.  When either live-reload or hmr are enabled the styles are replaced in placed (HMR style) without a live-reload.
2023-09-20 15:49:56 +02:00
Alan Agius
8f9a0d70cd feat(@angular-devkit/build-angular): support standalone apps route discovery during prerendering
This fixes an issue were routes could not be discovered automatically in a standalone application.

This is a total overhaul of the route extraction process as instead of using `guess-parser` NPM package, we now use the Angular Router. This enables a number of exciting possibilities for the future which were not possible before.

# How it works?
The application is bootstrapped and through DI injection we get the injector and router config instance and recursively build the routes tree.
2023-09-18 22:26:06 +02:00
Alan Agius
5a204b81c7 refactor(@angular-devkit/build-angular): accept boolean and string in ssr option
This is to align with the `serviceWorker` option.
2023-09-15 22:12:34 +02:00
Charles Lyding
b07ba1a90c refactor(@angular-devkit/build-angular): remove usage of terser constants in esbuild
The terser build time constant import from the `@angular/compiler-cli` package is no
longer used in the esbuild-based builder. The constants present are already defined
and conditionally added within the build configuration itself. This not only provides
more flexibility but also removes the need to import the package early in the process.
The import is also an expensive import due to it needing TypeScript and being ESM that
needs to be dynamically imported via a function helper to work around current ESM/TypeScript/CommonJS
limitations.
2023-09-14 21:59:56 +02:00
Alan Agius
48963fc17f fix(@angular-devkit/build-angular): several windows fixes to application builder prerendering
This commit fixes several Windows issues in the prerendering pipeline. Primarily due to path normalization and other Windows only constraints.
2023-09-14 17:25:30 +02:00
Angular Robot
5441d78ffa build: update all non-major dependencies 2023-09-14 10:56:09 +02:00
Alan Agius
c8909406a5 fix(@angular-devkit/build-angular): correctly re-point RXJS to ESM on Windows
Previously, the path matching and replacement did not consider non posix file systems like windows.
2023-09-14 10:53:38 +02:00
Alan Agius
a35ec17dee refactor(@angular-devkit/build-angular): remove experimental warning when using esbuild based builder
This is no longer experimental.
2023-09-13 17:40:50 +02:00
Alan Agius
e41e2015bf fix(@angular-devkit/build-angular): avoid spawning workers when there are no routes to prerender
This commit fixes an issue were previously we spawned piscina with `maxThreads` set to `0` which causes it to exit with a non zero error code when there are no routes to prerender.

Now, in the application builder we exit at n earlier stage if there are no routes to prerender.
2023-09-13 17:40:50 +02:00
Alan Agius
3f8aa9d8c7 feat(@schematics/angular): update ng new to use the esbuild application builder based builder
This commit updates the `ng generate application` to use the esbuild `application` builder. This also updates the schematics to support both `browser` and `application` builders.

BREAKING CHANGE: `rootModuleClassName`, `rootModuleFileName` and `main` options have been removed from the public `pwa` and `app-shell` schematics.
2023-09-13 17:40:50 +02:00
Alan Agius
7632bafe72 refactor(@angular-devkit/build-angular): remove deep import of zone.js/node
This is no longer needed as `zone.js` now has proper package exports.
2023-09-13 16:23:22 +02:00
Alan Agius
71424e1c93 build: update https-proxy-agent to version 7.0.2
This commit updates `https-proxy-agent` to version 7+
2023-09-13 16:23:08 +02:00
Kristiyan Kostadinov
2f299fc7b5 fix(@angular-devkit/build-angular): account for styles specified as string literals and styleUrl
An upcoming change in Angular will allow `style` specified as strings, in addition to a new `styleUrl` property. These changes update the JIT resource transform to support the change.
2023-09-13 09:33:50 +02:00
Angular Robot
271edea6de build: update all non-major dependencies 2023-09-13 09:33:17 +02:00
Charles Lyding
b4a12a9264 refactor(@angular-devkit/build-angular): update babel package usage and types based on current versions
Newer versions of the babel packages allow for removing some types packages as well as some helper
packages. The `@babel/template` package export used within the CLI is accessible from the `@babel/core`
package which allows removal of `@babel/template` as a direct dependency. Also, the `@babel/plugin-proposal-async-generator-functions`
package has been transitioned to `@babel/plugin-transform-async-generator-functions` due to async generators
being merged into the ECMAScript standard. Minor code cleanup based on the type cleanup was also performed
in the build optimizer babel passes.
2023-09-11 20:15:15 +02:00
Alex Castle
f437545705 feat(@ngtools/webpack): add automated preconnects for image domains
use TypeScript AST to find image domains and add preconnects to generated index.html
2023-09-11 20:12:43 +02:00
Charles Lyding
7d3fd226c5 fix(@angular-devkit/build-angular): support dev server proxy pathRewrite field in Vite-based server
The development server proxy configuration file for Webpack supports a `pathRewrite` field that is
not directly supported by the underlying Vite development server when using the application or esbuild-
browser builders. To provide equivalent support, especially for JSON file-based proxy configurations,
the `pathRewrite` field is now converted internally to a proxy `rewrite` function.
2023-09-11 09:18:53 +02:00
Charles Lyding
c11a0f0d36 fix(@angular-devkit/build-angular): support custom index option paths in Vite-based dev server
When using the Vite-based development server and a custom `index` build option (not `index.html`),
the custom index path will now be used as the root of the development server. This mimics the behavior
of the Webpack-based development server.
2023-09-11 08:25:17 +02:00
Angular Robot
7176bfdeb8 build: update all non-major dependencies 2023-09-08 10:20:47 -07:00
Kristiyan Kostadinov
0ba845c177 build: update to TypeScript 5.2
Updates the repo to TypeScript 5.2.
2023-09-08 10:20:17 -07:00
Charles Lyding
0811f641b3 build: update package output to use ES2022
The JavaScript generated for the published packages is now using ES2022.
This removes additional downleveling of code that was previously necessary
to use newer features.
The minimum Node.js version of 18.13 provides support for the needed features.
While this change does require a patch to `@bazel/concatjs` to allow the target
to be set to `ES2022`, this patch is now already required by the migration of
the universal repository into the CLI repository.
2023-09-08 10:19:37 -07:00
Charles Lyding
4b67d2afd3 perf(@angular-devkit/build-angular): use single JS transformer instance during dev-server prebundling
By setting up a single instance of the `JavaTransformer`, the Vite-based development server will now
have a fixed and controllable number of worker threads available to process prebundling requests. This
avoids a potentially large number of initial worker threads when a new application with a large number
of dependencies is first used with the development server. This is particularly beneficial for web
container setups which may not be able to efficiently handle the number of workers.
2023-09-08 10:19:24 -07:00
Alan Agius
b3b478798e docs: update statsJson application builder description
The description was outdated.
2023-09-08 12:39:27 +02:00
Alan Agius
7e726ebb5d refactor(@angular-devkit/build-angular): update polyfills option in application and jest builder to be only an array.
This commit updates the polyfills options in application and jest builder to support only an array of string as value.
2023-09-06 16:02:53 +02:00
Angular Robot
d44527b28d build: update all non-major dependencies 2023-09-05 10:06:30 -07:00
Kristiyan Kostadinov
188a00f3e4 fix(@angular-devkit/build-angular): elide setClassMetadataAsync calls
Updates the logic that elides `setClassMetadata` calls to also elide `setClassMetadataAsync`. The latter will be emitted when the component uses the new `defer` block syntax.
2023-09-05 10:03:04 -07:00
Kristiyan Kostadinov
6b08efa6ff fix(@angular-devkit/build-angular): account for arrow function IIFE
Updates the logic for removing Angular metadata and pure top-level functions to account for arrow-function-based IIFEs. Currently Angular doesn't generate arrow functions, but it's being explored in https://github.com/angular/angular/pull/51637.
2023-09-05 10:03:04 -07:00
Angular Robot
04f61aa7ef build: update all non-major dependencies 2023-08-31 09:04:29 +02:00
Charles Lyding
1dcff01fcd refactor(@angular-devkit/build-angular): normalize i18n options for application builder
The esbuild-based application builder will now access the project level i18n configuration
as well as the builder `localize`, `duplicateTranslationBehavior`, and `missingTranslationBehavior`
options to construct a full, normalized i18n option structure.
These options are not yet used by the builder but they are now available to access as future
work incrementally adds i18n support.
2023-08-31 07:29:25 +02:00
Alan Agius
2702419364 build: update peer Angular peer deps
This is needed to satisfy the pre-release checks.
2023-08-30 18:28:18 +02:00
Alan Agius
cdcc8586a0 refactor(@angular-devkit/build-angular): remove disabling certificate validation when inlining fonts
Disabling certificate validation is strongly discouraged and is not required for inling of fonts.

Addresses https://github.com/angular/angular-cli/security/code-scanning/29
Closes #25731
2023-08-30 17:02:29 +02:00
Alan Agius
f917b67e75 refactor: remove polynomial regular expression
This change updates the critical css processor to remove the need for a Polynomial regular expression.

Addresses: https://github.com/angular/angular-cli/security/code-scanning/51
Closes #25742
2023-08-30 17:02:10 +02:00
Alan Agius
c30e3692b3 refactor(@angular/ssr): remove express engine
This removes the util function for express, instead the "CommonEngine" is called directly infuture before this package is final we might rename the "CommonEngine" to something else.
2023-08-30 09:53:57 +02:00
Angular Robot
683f84dc13 build: update all non-major dependencies 2023-08-30 09:08:28 +02:00
Angular Robot
d90f2f6047 build: update all non-major dependencies 2023-08-29 05:10:59 -07:00
Alan Agius
dfc80adb58 build: update ng-packagr version to v17 prerelease
Update package to support version 17.
2023-08-29 03:53:23 -07:00
Angular Robot
e36cbd020f build: update dependency tslib to v2.6.2 2023-08-29 00:40:09 -07:00
Olivier Combe
7970c3f25e fix(@angular-devkit/build-angular): use correct type for extraEntryPoints 2023-08-29 00:39:30 -07:00