299 Commits

Author SHA1 Message Date
Jan Krems
2c9904ec7a fix(@angular-devkit/build-angular): handle basename collisions 2024-11-06 07:19:43 -08:00
Alan Agius
8f6ee1ac83 fix(@angular/build): skip wildcard routes from being listed as prerendered routes
This fix ensures that the wildcard routes are not included in the prerendered list, improving the accuracy of prerendered route generation.
2024-11-06 13:39:28 +01:00
Charles Lyding
a2f5ca9908 refactor(@angular/build): use structured component stylesheet tracking for hot replacement
When using the development server with the application builder, the internal state of
any external component stylesheets is now more comprehensively tracked. This allows
for more flexibility in both debugging potential problems as well as supporting additional
stylesheet preprocessing steps including deferred component stylesheet processing.
2024-11-06 10:26:56 +01:00
Alan Agius
e16cbb9ad5 refactor(@angular/ssr): remove duplicate code and streamline functionality
This commit cleans up duplicate code left from the previous implementations of process, serve, and render. Additionally, prerender serve now exclusively handles HEAD and GET requests, aligning with updated handling requirements. The private `renderStatic` method has been removed in favor of the `handle` method for improved maintainability.
2024-11-06 10:14:07 +01:00
Charles Lyding
e6ff801ba0 fix(@angular/build): workaround Vite CSS ShadowDOM hot replacement
When using the development server with the application builder (default for new projects),
Angular components using ShadowDOM view encapsulation will now cause a full page reload.
This ensures that these components styles are correctly updated during watch mode. Vite's
CSS hot replacement client code currently does not support searching and replacing `<link>`
elements inside shadow roots. When support is available within Vite, an HMR based update
for ShadowDOM components can be supported as other view encapsulation modes are now.
2024-11-05 17:27:50 +01:00
Alan Agius
a1fa483633 fix(@angular/build): handle APP_BASE_HREF correctly in prerendered routes
This commit resolves path stripping issues when `APP_BASE_HREF` does not align with the expected value.

Closes #28775
2024-11-05 17:19:38 +01:00
Alan Agius
daea0ab685 docs: replace @note with @remarks
Updated TSDoc comments by replacing @note with @remarks across the codebase. This aligns with TSDoc's preferred conventions, where @remarks is used for supplementary explanations and additional context.
2024-11-05 15:00:05 +01:00
Charles Lyding
46335625eb fix(@angular/build): disable dev-server websocket when live reload is disabled
When live reload is disabled (`"liveReload": false`/`no-live-reload`) within
the development server, the Vite websocket server will no longer be initialized.
Additionally, the client code will not be loaded by the browser. This allows the
development server to be used in test scenarios that would prefer to more fully
represent the production fielded configuration such as E2E testing or other forms
of browser-based testing.
2024-11-05 10:59:24 +01:00
Charles Lyding
9f5b5eb46e fix(@angular/build): correctly use dev-server hmr option to control stylesheet hot replacement
The development server's `hmr` option will now disable both global and component
stylesheet hot replacement if explicitly disabled. These features are enabled by
default for all projects.
2024-11-05 10:59:24 +01:00
Charles Lyding
ae9dfddbe5 refactor(@angular/build): integrate template update function generation with builder results
When using the development server with the application builder (default for new projects),
experimental support for component template hot replacement is now available for use. To
enable support, the `NG_HMR_TEMPLATES=1` environment variable must present when executing
the development server (for example, `NG_HMR_TEMPLATES=1 ng serve`). Once support has become
stable, template hot replacement will be enabled by default.
2024-11-05 10:30:58 +01:00
Charles Lyding
99192a791b fix(@angular/build): always clear dev-server error overlay on non-error result
Now that additional result object types can be returned from the build
system, the error overlay must be cleared on all non-error results. The
introduction of component update results and eventual incremental results
will now properly clear the error overlay after a successful build.
2024-11-05 08:23:17 +01:00
Alan Agius
71b3de8364 fix(@angular/build): ensure accurate content size in server asset metadata
Updated the calculation to use `Buffer.byteLength()` for determining the length of escaped file content. This change ensures that the `size` property in server asset metadata accurately represents the length of the escaped content.
2024-11-04 20:31:03 +01:00
Alan Agius
d21e511b6b refactor(@angular/build): split SSR server assets into separate chunks
This commit refactors the build process for server-side rendering (SSR) by dividing server assets into separate, importable chunks rather than bundling them into a single output file.
2024-11-04 20:31:03 +01:00
Angular Robot
316df8fbba build: update all non-major dependencies 2024-11-04 16:44:14 +01:00
Charles Lyding
d16a9aa437 fix(@angular/build): check referenced files against native file paths
When checking for bundler context invalidation for any referenced files,
the native path format is now used to ensure that the watch files can
be correctly matched. This is particularly important for Windows due to
the differing path segment separator.
2024-11-02 15:57:50 -04:00
Charles Lyding
aaaa4bc5f4 refactor(@angular/build): allow in-memory caching of server main code bundling during rebuilds
In addition to the other main code bundling steps, the server main code will
also be cached and invalidated based on file changes in watch mode.
2024-11-02 08:26:57 -04:00
Charles Lyding
7eabe7d4b3 refactor(@angular/build): avoid need to pre-import angular compiler package in dev server
Within the development server, the external stylesheet encapsulation logic has been
adjusted to avoid needing to asynchronously import the `@angular/compiler` package within
the request execution. This removes the need to pre-import the package at the start of the
development server which was previously used to avoid a delay in stylesheet response on
first use. The external stylesheet response execution is also now fully synchronous.
2024-11-01 18:42:00 -04:00
Charles Lyding
5efcf88a35 refactor(@angular/build): send error status code on invalid external style component ID
If an invalid component identifier is provided to the development server for an external
stylesheet requiring encapsulation, both a console message and a 400 status response will
now be sent. This removes the potential for invalid styles to be sent to the browser.
2024-11-01 18:42:00 -04:00
Alan Agius
505521e546 perf(@angular/ssr): integrate ETags for prerendered pages
When using the new developer preview API to serve prerendered pages, ETags are added automatically, enabling efficient caching and content validation for improved performance.
2024-11-01 19:52:03 +01:00
Charles Lyding
fba2799154 refactor(@angular/build): allow caching of TypeScript build contexts for rebuilds
Now that the TypeScript bundler contexts perform additional checks for validity,
they can now be cached in memory during watch modes. This allows the TypeScript
bundler contexts to skip rebundling when not affected by a file changed. This is
particularly beneficial for style related file changes where no code processing
is otherwise required.
2024-11-01 10:13:13 -04:00
Charles Lyding
2aa25a73a8 fix(@angular/build): ensure SVG template URLs are considered templates with external stylesheets
When using the development server with the application builder (default for new projects),
the external stylesheet functionality for component style hot replacement was incorrectly
considering SVG files as stylesheet resources. This resulted in a build error when using
SVG files as a template source. The file extension based checks have now been improved to
account for this usage.
2024-11-01 10:12:44 -04:00
Charles Lyding
abde078233 refactor(@angular/build): improve typescript bundling context rebuild checking
The TypeScript-based bundling contexts have now been separated from the other
bundling contexts that may be present in an application build. The later of which
include global styles, scripts, and non-TypeScript polyfills. This allows for
the TypeScript bundling contexts to perform additional checks during a rebuild to
determine if they actually need to be rebundled. The bundling context caching for
the TypeScript contexts has not yet been enabled but these changes prepare for the
switch to allow conditional rebundling on file changes.
2024-11-01 09:30:09 -04:00
Angular Robot
69768bdaa4 build: update all non-major dependencies 2024-11-01 08:25:17 -04:00
Charles Lyding
5c2aa2f4b1 refactor(@angular/build): allow experimental template update generation via environment variable
The experimental Angular component template hot replacement capabilities
will be initially controlled via an environment variable. Setting `NG_HMR_TEMPLATES=1`
with the development server that is using the application builder will generate the
runtime event code to support hot replacement of an individual component template.
The build system itself does not yet generate the component update build results needed
to trigger the runtime events. The environment variable is currently intended to support
integration of the remaining code to fully implement the feature.
2024-11-01 07:17:29 -04:00
Alan Agius
481ccdbc5a fix(@angular/ssr): enable serving of prerendered pages in the App Engine
This commit implements the capability for the App Engine to serve prerendered pages directly. Previously, we relied on frameworks like Express for this functionality, which resulted in inconsistent redirects for directories where in some cases a trailing slash was added to the route.

**Note:** This change applies only when using the new SSR APIs. When using the `CommonEngine`, a 3rd party static serve middleware is still required.
2024-11-01 10:45:05 +01:00
Alan Agius
3371f5b9ab fix(@angular/build): Exclude known --import from execArgv when spawning workers
This change prevents Bazel compilation issues in the ADEV build process.
2024-10-31 12:42:53 +01:00
Alan Agius
a3e2bcd6b4 refactor(@angular/build): remove experimental buildApplication overload
An experimental overload of `buildApplication` has been removed.
2024-10-30 19:47:40 -04:00
Charles Lyding
7172df1243 refactor(@angular/build): allow forcing bundler context rebundle
A bundle call for a `BundlerContext` can now force a rebundling in cases
where the cached version should not be used. This is currently not leveraged
within the code but will be used for improvements to typescript based context
rebuilds in the future.
2024-10-30 18:21:43 -04:00
Alan Agius
c242d2933a fix(@angular/build): set ngServerMode during vite prebundling
This commit sets the `ngServerMode` in the prebundled deps.
2024-10-30 23:19:10 +01:00
Charles Lyding
bc43f9567c build: add return types for component stylesheet bundler 2024-10-30 14:26:19 -04:00
Angular Robot
170bb19074 build: update all non-major dependencies 2024-10-30 12:27:43 -04:00
Charles Lyding
a9772068d5 refactor(@angular/build): directly bundle external component file-based style changes
When using the development server with the application builder, file-based component
styles will now be bundled during the main builder execution instead of within the
application code bundling step. This allows for these styles to be processed independently
from any code bundling steps and will support future changes that will allow the
builder to completely skip code bundling if only file-based component stylesheets are changed.
2024-10-30 11:07:53 -04:00
Charles Lyding
bc771ae2d0 fix(@angular/build): always record component style usage for HMR updates
When using the development server with the application builder, external
component stylesheet usage must always be record to ensure that any hot
replacement actions correctly reference the relevant components. Previously,
browser cached styles would return a 304 status prior to recording the usage.
This resulted in the development server not knowing that the component needed
a potential update in the future.
2024-10-29 13:14:00 -04:00
Alan Agius
8e2829c851 refactor(@angular/build): add handling for ngServerMode
Configure esbuild to add `ngServerMode` as define.
2024-10-29 07:44:55 +01:00
Angular Robot
afec9297dc build: update all non-major dependencies 2024-10-28 14:36:59 -04:00
Charles Lyding
4df44dcfb6 refactor(@angular/build): use ETags for dev-server resource requests
When using the development server with the application build system,
resource files managed by the build system will now using ETag headers
to avoid resending content that has not changed since the last request.
This includes such content as global stylesheet files, image/font files
referenced in stylesheets, and other files managed by the bundler.
2024-10-28 14:16:16 -04:00
Alan Agius
15677d0cb7 refactor: replace critters with beasties
The Critters project has been transferred to the Nuxt team, who will now manage its development and has been renamed to Beasties.

See: https://github.com/danielroe/beasties
2024-10-28 18:57:05 +01:00
Charles Lyding
b73b98de65 refactor(@angular/build): use ETag headers for development external component styles
When using the development server, Angular component stylesheet requests that
use hot replacement (default for v19) will now use the `ETag` header to remove
the need to reprocess and resend encapsulated component styles if the styles
have not changed since last usage. The ETag value used is a combination of the
style content and the encapsulation component identifier.
2024-10-28 12:29:01 -04:00
Alan Agius
d8f926fa7f fix(@angular/build): simplify disabling server features with --no-server via command line
When `outputMode` is configured, `--prerender` and `--app-shell` become no-ops, making server feature disabling difficult without modifying the configuration.

This commit introduces the `--no-server` option, which can be used with `--output-mode static` to fully disable all server features.

```
ng build --output-mode static --no-server
```
2024-10-28 16:08:06 +01:00
Alan Agius
137e8e0ceb fix(@angular/build): add warning when --prerendering or --app-shell are no-ops
Both options are ineffective when used with `outputMode`, so a warning is now issued.
2024-10-28 16:08:06 +01:00
Angular Robot
1890fe4e94 build: update all non-major dependencies 2024-10-24 08:29:52 -07:00
Charles Lyding
31f903709c fix(@angular/build): avoid hashing development external component stylesheets
When using the development server with a production configuration or with bundle
hashing enabled, the external stylesheet files used by the development server for
hot replacement of component styles are no longer hashed. This ensures that the
requests from the runtime served by the development server match the available
generated component stylesheet files.
2024-10-24 10:15:32 -04:00
Angular Robot
ff88c3f6a1 build: update all non-major dependencies 2024-10-23 11:49:20 +02:00
Alan Agius
cc345b02d8 fix(@angular/build): Address build issue in Node.js LTS versions with prerendering or SSR
In Node.js 20, changes to ESM loader hooks result in the `--import` execArgv being passed from the parent to child workers.

This commit resolves the issue by setting an empty `execArgv` in the JavaScript transformer, preventing unintended propagation.

Closes #28683
2024-10-23 11:20:07 +02:00
Aaron Shim
efb434136d feat(@angular/build): Auto-CSP support as a part of angular.json schema
Following up on the logic provided in #28639, we want to offer an opt-in
option in angular.json to enable the auto-CSP transformation.

For now, builds for `ng serve` will have Auto-CSP disabled.
2024-10-22 15:47:23 -07:00
Alan Agius
b893a6ae9d refactor: remove workarounds for Safari 14 and 15
Both of these versions are no longer supported by Angular and thus these workers are no longer required.
2024-10-22 19:18:12 +02:00
Aaron Shim
6beffd138e refactor(@angular/build): Auto-CSP support as an index file transformation.
Auto-CSP is a feature to rewrite the `<script>` tags in a index.html
file to either hash their contents or rewrite them as a dynamic loader
script that can be hashed. These hashes will be placed in a CSP inside a
`<meta>` tag inside the `<head>` of the document to ensure that the
scripts running on the page are those known during the compile-time of
the client-side rendered application.
2024-10-22 09:57:16 -07:00
Charles Lyding
6486b575b9 refactor(@angular/build): add internal support for generating template update functions
The internal AOT Angular compilation processing can now generate the newly
introduced template update functions during development server rebuilds of
template only file changes. These template update functions are not yet used
but provide the infrastructure to enable template hot replacement in a
future change.
2024-10-22 05:53:14 -04:00
Angular Robot
1128773122 build: update all non-major dependencies 2024-10-21 14:32:48 -07:00
Charles Lyding
446fd9486f refactor(@angular/build): create component stylesheet bundler at start of build
The component stylesheet bundler is now created at the start of the build
and accessible prior to the bundling actions. This will provide support for
generating updated component styles and bypassing all code bundling when using
the development server and only component styles have been modified.
2024-10-21 07:21:28 -04:00