1835 Commits

Author SHA1 Message Date
Joey Perrott
ca1e86b684 build: disable failing strict_deps targets
Disable all failing strict_deps targets with TODOs to fix them moving forward.
2025-02-19 15:22:58 -05:00
Joey Perrott
c9273f8b85 build: add @types/node to assorted locations where node types are being relied on and currently obtained transitively. 2025-02-19 12:53:55 -05:00
Charles Lyding
a5fcf80442 fix(@angular/build): provide karma stack trace sourcemap support
When executing unit tests with `karma`, the stack traces within errors
will now use any sourcemaps that were generated during the build process
to provide source-based locations for the errors. Script sourcemaps must
be enabled for this functionality.
2025-02-18 18:37:15 -05:00
Angular Robot
9f870b4051 build: update all non-major dependencies 2025-02-18 07:46:41 -05:00
Charles Lyding
11fab9c7dd feat(@angular/build): add application builder karma testing to package
An `application` only variant of the `karma` builder found within the
`@angular-devkit/build-angular` package is now available within the
`@angular/build` package as `@angular/build:karma`. This builder will
only use the `application` builder found within `@angular/build` and
does not provide the `builderMode` option as `application` would be the
only valid value. Testing behavior is effectively equivalent to using the
`@angular-devkit/build-angular:karma` builder with the `builderMode`
option set to `application`. However, several options have been adjusted:
* `builderMode` was removed
* `fileReplacements` legacy structure (`src`/`replaceWith`) removed
* `polyfills` only accepts an array of strings
* `loader` has been added
* `define` has been added
* `externalDependencies` has been added
2025-02-18 06:28:08 -05:00
Alan Agius
e6deb82c6c fix(@angular/build): update critical CSS inlining to support autoCsp
This update improves the handling of inlined critical CSS to align with `autoCsp`, ensuring compliance with Content Security Policy (CSP) directives. Previously, inlined styles could trigger CSP violations in certain configurations. With this fix, critical CSS is inlined in a way that maintains security while supporting `autoCsp`.

Closes #29603
2025-02-14 13:55:44 -08:00
Joey Perrott
33ed6e875e refactor: move builtin module imports to use node: prefix imports 2025-02-14 11:09:23 -08:00
Angular Robot
65c99b8139 build: update all non-major dependencies to v7.26.9 2025-02-14 14:35:24 +01:00
Alan Agius
f92787947f fix(@angular/build): suppress asset missing warning for /index.html requests
Prevent incorrect warning display when the Service Worker requests `/index.html`.
2025-02-14 14:35:12 +01:00
Alan Agius
04f331a534 build: update all non-major dependencies
Update packages
2025-02-14 13:11:21 +01:00
Kristiyan Kostadinov
0a77fe09eb build: update to TypeScript 5.8
Updates the repo to TypeScript 5.8 and expands the peer dependency ranges.
2025-02-14 11:39:20 +01:00
Alan Agius
09f5006b5c fix(@angular/cli): prefer installed package as fallback when listing package groups
Previously, the package group name defaulted to the first item in the list. This update prioritizes an installed package as the fallback instead.

Closes #29627
2025-02-13 21:40:05 +01:00
Alan Agius
f5689e9525 refactor(@angular/cli): handle undefined ng add collection name
Fixes an issue where JSON help extraction fails if the `ng add` collection name is undefined.
2025-02-13 16:09:43 +01:00
Alan Agius
8c7c7ac691 fix(@angular/cli): correctly parse and resolve relative schematic collection names on Windows
Previously, the logic incorrectly extracted the drive letter as the collection name when the schematic collection was specified as relative on Windows. This fix ensures that relative paths are parsed and resolved correctly, preventing the drive letter from being mistakenly treated as the collection name.

Closes #29559
2025-02-13 08:47:45 +01:00
Alan Agius
a2747391aa build: update to esbuild 0.25.0
This commit updates esbuild to 0.25.0
2025-02-12 20:31:56 +01:00
Angular Robot
1355d086fe build: update all non-major dependencies 2025-02-12 08:49:47 -08:00
Charles Lyding
964fb778b7 fix(@angular/build): support per component updates of multi-component files
The HMR component update candidate analysis has been improved to now perform
more fine-grained checks for cases where more than one component is present
in a single TypeScript file. Previously it was possible for all components
present in a TypeScript file to be considered update candidates when only
one of the components had relevant changes to its template and/or styles.
2025-02-12 11:34:45 -05:00
Alan Agius
be15b886c7 fix(@angular/build): configure Vite CORS option
Vite's `allowedHosts` option does not enable CORS; instead, it allows the dev server to respond to requests with a matching hostname (e.g., http://example.com/main.js). It only verifies that the request’s hostname is on the allowed list. However, this does not consider the `origin` in the case of a CORS request.

This commit updates Vite's configuration to enable CORS.

Closes #29549
2025-02-12 10:43:18 +01:00
Alan Agius
b50b6ee920 perf(@angular/build): cache translated i18n bundles for faster builds
When disk caching is enabled, translated i18n bundles are stored on disk, improving performance and speeding up both incremental and non-incremental builds.
2025-02-11 20:15:54 +01:00
Alan Agius
833dc986db fix(@angular/ssr): properly handle baseHref with protocol
Enhances handling of `baseHref` when it includes a full URL with a protocol.

Closes #29590
2025-02-10 15:33:31 -08:00
Charles Lyding
beefed839f fix(@angular/build): always provide Vite client helpers with development server
In addition to the WebSocket code, the Vite client module contains helper
functions which may be injected into modules at request time. These helpers
are required for certain behavior to function. Previously, when `--no-live-reload`
was used, these helpers may not have been available which led to runtime
errors. These runtime errors will no longer occur. However, the browser console
will now log that the Vite client cannot connect to the development server
WebSocket. This is expected in this case since live reload functionality
was disabled and the server side is intentionally not available.
2025-02-10 15:25:19 -08:00
Alan Agius
b553069896 fix(@angular/build): handle unlocalizable files correctly in localized prerender
Ensure proper handling of unlocalizable files during localized prerendering to prevent errors.

Closes #29587
2025-02-10 17:31:58 +01:00
Alan Agius
880a50c50c fix(@angular/build): exclude unmodified files from logs with --localize
Ensures that only modified files are displayed in logs when using the `--localize` flag, preventing unnecessary noise.

Closes #29586
2025-02-10 16:31:06 +01:00
Alan Agius
dca408b926 build: update all non-major dependencies 2025-02-10 16:29:51 +01:00
Angular Robot
021985fcb1 build: update angular 2025-02-07 11:04:05 -08:00
Angular Robot
cf2d54b222 build: update all non-major dependencies 2025-02-06 15:19:51 -08:00
Alan Agius
17a7b8cf01 refactor(@angular/build): also add server.preTransformRequests
5c1360179c moved `preTransformRequests` from the `server` to `dev` section. But vite, still uses the `server` section in such cases bcdb51a1ac/packages/vite/src/node/server/index.ts (L673) and
bcdb51a1ac/packages/vite/src/node/server/middlewares/indexHtml.ts (L475)
2025-02-06 12:25:54 -08:00
Alan Agius
414736bc0f fix(@angular/ssr): accurately calculate content length for static pages with \r\n
JS engines convert `\r\n` to `\n` in template literals, potentially leading to incorrect byte length calculations. This fix ensures the correct content length is determined.

Closes #29567
2025-02-06 11:51:26 -08:00
Charles Lyding
b24089ef86 fix(@angular/build): ensure full rebuild after initial error build in watch mode
If an initial build of an application results in an error during watch mode
(including `ng serve`), the following non-error rebuild will now always be
a full build result. This ensures that all new files are available for later
incremental build result updates.
2025-02-05 13:16:48 -08:00
Charles Lyding
5c1360179c fix(@angular/build): avoid pre-transform errors with Vite pre-bundling
Vite 6.0 change the option location of the `preTransformRequests`
to the `dev` section of the Vite configuration. While the previous `server`
section option of the same name is still present, it currently does not
change behavior when configured.
2025-02-05 13:16:32 -08:00
Angular Robot
dc11340113 build: update all non-major dependencies 2025-02-05 06:52:05 -08:00
Angular Robot
5123ff4a58 build: update all non-major dependencies 2025-02-04 07:19:17 -08:00
Charles Lyding
9525eee739 refactor(@angular/build): allow component update invalidation from client
If HMR is enabled, a component update has the potential to be unsupported
at runtime or may cause an exception. While build time analysis attempts
to verify that an update is possible, there could be cases that are as of
yet unknown. For those cases, the runtime can now signal this information
back to the development server which will clear the errant component update
and trigger a full page reload. This action will be logged to the development
server console along with an optional message from the client.
2025-02-04 07:11:15 -05:00
Alan Agius
25dbe7cfc1 refactor(@angular/ssr): simplify preload append logic in metadata
Replace `filter` and `map` with a `for...of` loop to improve readability in the preload append logic within metadata.
2025-02-03 15:20:18 -08:00
Angular Robot
7a8ff1f099 build: update all non-major dependencies 2025-02-03 14:35:08 -08:00
Alan Agius
6448f80bfb fix(@angular/ssr): prioritize the first matching route over subsequent ones
Ensures that the SSR router gives precedence to the first matching route, addressing the issue where later conflicting routes.

This change prevents the incorrect prioritization of routes and ensures the intended route is matched first, aligning routing behavior.

Closes: #29539
2025-02-03 12:23:19 -08:00
Alan Agius
9726cd084b feat(@angular/ssr): Add support for route matchers with fine-grained render mode control
This commit adds support for custom route matchers in Angular SSR, allowing fine-grained control over the `renderMode` (Server, Client) for individual routes, including those defined with matchers.

Routes with custom matchers are **not** supported during prerendering and must explicitly define a `renderMode` of either server or client.

The following configuration demonstrates how to use glob patterns (including recursive `**`) to define server-side rendering (SSR) or client-side rendering (CSR) for specific parts of the 'product' route and its child routes.

```typescript
// app.routes.ts
import { Routes } from '@angular/router';

export const routes: Routes = [
  {
    path: '',
    component: DummyComponent,
  },
  {
    path: 'product',
    component: DummyComponent,
    children: [
      {
        path: '',
        component: DummyComponent,
      },
      {
        path: 'list',
        component: DummyComponent,
      },
      {
        matcher: () => null, // Example custom matcher (always returns null)
        component: DummyComponent,
      },
    ],
  },
];
```

```typescript
// app.routes.server.ts
import { RenderMode, ServerRoute } from '@angular/ssr';

export const serverRoutes: ServerRoute[] = [
  { path: '**', renderMode: RenderMode.Client },
  { path: 'product', renderMode: RenderMode.Prerender },
  { path: 'product/list', renderMode: RenderMode.Prerender },
  { path: 'product/**/overview/details', renderMode: RenderMode.Server },
];
```

Closes #29284
2025-01-31 13:09:34 +01:00
Angular Robot
02d87bcf33 build: update all non-major dependencies 2025-01-31 08:28:30 +01:00
Alan Agius
9b0d730871 fix(@angular/build): prevent server manifest generation when no server features are enabled
This change ensures that the server manifest is not generated if none of the server-related features are enabled.

Closes #29443
2025-01-30 19:40:54 +01:00
Paul Gschwendtner
c0d20e05c3 build: switch beasties bundling to rules_js
Switches the beasties bundling to `rules_js`, using rollup directly from
the node modules installation.

Notably we are facing a small issue that doesn't cause any issues right
now, because rollup tries to dereference symlinks by default given
a bug: https://github.com/aspect-build/rules_js/issues/1827.

This means we can't rely on the jailed resolution, but in practice it
shouldn't cause an issue at this point.
2025-01-30 11:16:46 +01:00
Paul Gschwendtner
2236bc185a build: remove legacy defaults.bzl macro file
This file is currently no longer necessary after migrating all consumers
to their `rules_js` variants, so we can delete the file.

In follow-ups we will consider renaming `defaults2.bzl` back to this
file, or have a better name altogether.
2025-01-30 11:16:46 +01:00
Paul Gschwendtner
83b9d33946 build: migrate remaining usage of pkg_npm to rules_js
This is necessary so that we can delete the `pkg_npm` macro and fully
leverage the `rules_js` variant.
2025-01-30 11:16:46 +01:00
Paul Gschwendtner
01ea33e372 build: migrate CLI schema generation to rules_js
Migrates the CLI schema generation to `rules_js`, also significantly
simplifying the rule boilerplate.
2025-01-30 11:16:46 +01:00
Angular Robot
448e920e34 build: update angular 2025-01-30 08:00:17 +01:00
Alan Agius
2431ab4208
refactor(@angular/build): update version check to account for unreleased FW packages (#29537)
In the FW integration tests the packages version is `0.0.0`. This commit update the compatibility version check to account for this.
2025-01-30 07:58:53 +01:00
Alan Agius
249f9dc26c refactor(@angular/build): remove unused import
Remove unused import.
2025-01-29 20:01:33 +01:00
Alan Agius
9a46be8d68 fix(@angular/build): prevent fallback to serving main.js for unknown requests
Previously, when an unknown `main.js` file was requested, the system would
automatically fall back to serving the default `main.js`. This behavior
could cause unexpected issues, such as incorrect resource loading or
misleading errors.

This fix ensures that only valid `main.js` files are served, preventing
unintended fallbacks and improving request handling.

Closes #29524
2025-01-29 17:31:55 +01:00
Alan Agius
46581db16b fix(@angular/ssr): redirect to locale pathname instead of full URL
When redirecting to the preferred locale, the previous implementation used the full URL for the 302 redirect to i18n subpaths based on the user's preferred locale. This update ensures that the redirect now uses the locale-specific pathname instead of the full URL.

Closes #29514
2025-01-29 16:18:16 +01:00
Paul Gschwendtner
539336e01a build: migrate remaining @angular/ssr tests to rules_js
Migrates the remaining `@angular/ssr` tests to `rules_js`.
2025-01-29 10:16:32 +01:00
Paul Gschwendtner
832bfffc43 build: migrate @angular-devkit/build-angular tests to rules_js
Migrates the `@angular-devkit/build-angular` tests to `rules_js`. This
was a rather larger undertaking as the tests were very reliant on e.g.
the directory structure or specific node module layout; so some changes
were needed.

- the Sass files include a much larger file header now. That is because
  the npm Sass files have much larger paths, given being inside a
  symlinked pnpm store directory. E.g.

  ```

/*!**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
  !*** css ../../../../../node_modules/.aspect_rules_js/css-loader@7.1.2_webpack_5.97.1/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].rules[0].oneOf[0].use[1]!../../../../../node_modules/.aspect_rules_js/postcss-loader@8.1.1_1462687623/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].rules[0].oneOf[0].use[2]!./src/test-style-a.css?ngGlobalStyle ***!
  \**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
.test-a {color: red}
  ```

- Similarly to above, hashed chunk files can change given different
  paths of e.g. Webpack, or external sources.

- Tests for verifying the lazy module chunks may enable
  `preserveSymlinks` just to make the chunk names shorter and easier to
  verify, avoiding truncatd super long paths to the e.g. pnpm stores
  again.

- the ngsw-worker.js file cannot be copied using `copyFile` as that
  results in permissions being copied as well. In Bazel, now that
  the npm files are properly captured, are readonly, so subsequent
  builds (e.g. the watch tests) will fail to copy/override the file
  again! Reading and writing the file consistently seems appropriate.

- Tests relying on puppeteer and webdriver-manager worked in the past,
  by accident, because postinstall scripts (from e.g. puppeteer) were
  able to modify content of other packages (e.g. the puppeteer-core
  cache of browsers then). This does not work with `rules_js` anymore,
  so we need to keep the cache local to the puppeteer postinstall
  script. This requires a little trickery right now to ensure resolution
  of the browsers at runtime works..

- server tests did miss the `node` types to be explicitly listed (as
  they would be in a fresh project), and this caused failures. Likely
  because we no longer patch resolution.

- avoid npm-module style imports from tests within the same package.
  This is not allowed with `rules_js` and also is inconsistent.
2025-01-29 09:02:41 +01:00