487 Commits

Author SHA1 Message Date
Angular Robot
0c720655ea build: update all non-major dependencies 2025-03-12 15:39:24 -04:00
Alan Agius
5bea3de4cb fix(@angular/build): invalidate com.chrome.devtools.json if project is moved
Ensure that when a project is relocated, the `com.chrome.devtools.json` file is properly invalidated by checking the `root` path.
2025-03-11 15:23:37 +01:00
Paul Gschwendtner
9dd3f0344f
Further clean-up rules_nodejs npm workspace and remove yarn.lock (#29779)
* build: disconnect `@npm` workspace from main project

This will speed up significantly as we don't need to fetch all
dependencies again just for the `@npm` repository that is at this point
only leveraged by the `ng_package` rule for some of its dependencies.

This commit allows us to drop the `yarn.lock` and Aspect lock files, and
allows us to independently migrate `ng_package` to `rules_js`.

It also allows us to drop the `_rjs` TS interop layer in follow-up commits.

* build: drop `_rjs` suffix from `ts_project` targets

We don't need the `ts_project` interop in principle
at this point. We only have one remaining instance left for the SSR
`ng_package` integration. This commit cleans up all usages.

* build: remove yarn

* build: avoid duplicated dependencies at top-level

`rules_js` seems to be sensitive if there are similar versions of the same
package installed, but with differently matched peer dependencies. This
is fine because we can (and should long-term) move those dependencies to
their package-local `package.json` files. This commit unblocks the
migration and highlights how we can move deps to the individual packages
in the future.

* build: update checkout github action

This will allow us to use pnpm.

* build: update node to avoid strict-engines error caused by `npm`

Avoids:

```
Lockfile is up to date, resolution step is skipped
 ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)

Your Node version is incompatible with "npm@11.2.0".

Expected version: ^20.17.0 || >=22.9.0
Got: v20.11.1
```

Note that we won't update the WORKSPACE test version as that would mean
we need to update the Node engines for shipped packages; and we can't do
this right now without introducing a breaking change.

* build: fix missing dependency for spec bundling

The beasties JS sources weren't available for bundling in the
`bazel-bin`, and this surfaced in RBE. This commit fixes this.
2025-03-11 10:05:52 +01:00
Alan Agius
3e35167855 fix(@angular/build): handle postcss compilation errors gracefully
Improves error handling in the PostCSS compilation process to prevent crashes and allow recovery.

Closes #29789
2025-03-10 14:41:59 +01:00
Alan Agius
596b9ae60c refactor(@angular/build): remove esbuild sourcemap workarounds
These are no longer requires since 0.25.1
2025-03-10 13:33:16 +01:00
Angular Robot
65a5ff49f1 build: update all non-major dependencies 2025-03-10 08:48:23 +01:00
Alan Agius
beab546bf2 fix(@angular/build): remove duplicate prebundling warning
This warning is already displayed during the normalization of options. See: b5a86709b7/packages/angular/build/src/builders/dev-server/options.ts (L56)
2025-03-07 15:33:19 +01:00
Angular Robot
b5a86709b7 build: update all non-major dependencies 2025-03-07 11:23:08 +01:00
Alan Agius
f0dd60be1e fix(@angular/build): exclude all entrypoints of a library from prebundling
The configuration now ensures that when a package is listed for exclusion, all paths within that package including sub-paths like `@foo/bar/baz`  are marked as external and not prebundled by the development server.

For example, specifying `@foo/bar` in the exclude list will prevent the development server from bundling any files from the `@foo/bar` package, including its sub-paths such as `@foo/bar/baz`.

This aligns with esbuild external option behaviour https://esbuild.github.io/api/#external

Closes #29170
2025-03-06 19:12:05 +01:00
Alan Agius
31c81e9c68 feat(@angular/build): drop support for TypeScript older than 5.8
Narrow down the versions of TypeScript to support.

BREAKING CHANGE: TypeScript versions less than 5.8 are no longer supported.
2025-03-06 10:03:49 +01:00
Alexey Horbunov
b100c71ccd
fix(@angular/build): provide extract-i18n does not respect
`i18nDuplicateTranslation` config value (#29179)

This fixes an issue where the config was not passed.

Closes #23635
2025-03-05 19:18:51 +01:00
Alan Agius
3c9172159c feat(@angular/build): integrate Chrome automatic workspace folders
This commit integrates automatic Chrome DevTools workspace folder connection into the vite dev-server process, leveraging the experimental feature available in Chrome Canary, as described in the Chrome DevTools documentation https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md
2025-03-05 17:14:18 +01:00
Alan Agius
1c10c0e4a9 build: lock file maintenance 2025-03-05 16:21:55 +01:00
Charles Lyding
093c5a3152 feat(@schematics/angular): directly use @angular/build in new projects
The `@angular/build` package is now used directly within all newly created
projects and replaces the previous usage of the `@angular-devkit/build-angular`
package. This has the advantage of removing the need to install all of the
Webpack related transitive dependencies contained within `@angular-devkit/build-angular`
that are used to support the `browser` builder. This results in a significant
reduction in both total dependency count and disk install size for new projects.
New projects that would prefer to use the Webpack-based `browser` builder can still
install the `@angular-devkit/build-angular` package within the workspace.

The `@angular/build@19.2.0-next.2` package currently has a total unpacked size of ~115 MB.
The `@angular-devkit/build-angular@19.2.0-next.2` package currently has a total unpacked size of ~291 MB.
2025-03-05 10:28:07 +01:00
Alan Agius
434198c69b fix(@angular/build): exclude component styles from 'any' and 'all' budget calculations
Previously, component styles were included in the 'any' and 'all' budgets, which could lead to incorrect budget violations. This update ensures that component styles are excluded from these budget calculations.

Closes #29609
2025-03-04 18:20:52 +01:00
Charles Lyding
c2bef38332 fix(@angular/build): allow component HMR with a service worker
When the service worker option is enabled, each code update will cause
the `ngsw.json` configuration file to change due to the different hashes
of the updated output. This is problematic for component HMR usage with
the development server since the full reload fallback logic would be triggered
due to the changed `ngsw.json` file.  To avoid this problem, the `ngsw.json`
configuration file is now special cased within the fallback logic.
2025-03-04 09:53:57 +01:00
Angular Robot
39ec21f0ca build: update dependency @vitejs/plugin-basic-ssl to v2 2025-03-04 09:53:02 +01:00
Paul Gschwendtner
5fd1cb56ab build: update dev-infra and rework windows native testing
As part of go/ng:windows-dev-future, we are changing how our
infrastructure supports Windows build & testing. Clearly:

- we will still support contributors on Windows, and we believe we will
  be improving and streamlining the experience here
- we will continue testing the Angular CLI for our Windows users. We are
  aware of the many Windows users using the `ng` CLI.

What is changing? We are no longer actively working towards a Bazel infrastructure
that supports native Windows building and testing. There are currently
two ways to contribute to Angular on Windows. That is via WSL, or via
e.g. native Windows cmd.exe, with Git Bash on top. We acknowledge that
the latter worked sometimes, but we also realize it very often breaks as
nobody on our team uses, verifies it, and it introduces extra complexity
because Bazel on Windows is quite disconnected from Linux/Mac (e.g. no
sandboxing). Going forward, to improve our team's effectiveness, and
improve our stability guarantees for Windows (and Windows contributors),
we are actively discouraging the use of Git Bash for contributing to
Angular; but instead ask for WSL to be used. I can speak as one of the
few long-term team members that have worked on Windows (without WSL) most
of my time, that WSL is great and the contributing experience is much
smoother and also easier to "guide". It's a positive change because we
won't be suggesting "two ways to contribute on Windows", where in
reality one is very brittle and can break at any time!

---

For testing of the Angular CLI: We will continue to maintain the
capability to cross-compile via Bazel with Windows as the target
platform. This allows us to build the e2e tests for Windows, and run
them natively outside WSL to ensure native Windows `ng` CLI testing!
This is what this change mostly does.

Notably, two things are missing here and will be followed up:

- caching of the e2e tests on Windows is not properly functioning yet.
- caching of the WSL node modules + nvm is not working properly yet.

Other than that, we are seeing very similar timing and results of the
Windows tests, so this change unblocks our `rules_js` migration.
2025-03-03 21:44:50 +01:00
Charles Lyding
c8c73185a6 fix(@angular/build): ensure matching coverage excludes with karma on Windows
When on Windows, the coverage exclusion paths need to be made
absolute via the Node.js path builtin to ensure matching
with the files during the build process.
2025-03-03 20:18:01 +01:00
Charles Lyding
c39c3440cf refactor(@angular/build): replace fast-glob usage with tinyglobby
Usage of the `fast-glob` package has been replaced with the `tinyglobby`
package throughout `@angular/build`. The change reduces the number of
transitive dependencies related to these packages from 17 to 2 while
also maintaining equivalent functionality. Additionally, the `tinyglobby`
package is used by other dependencies such as `vite` and `copy-webpack-plugin`
which has the potential to further reduce overall transitive dependencies
for a project.
2025-03-03 16:57:37 +01:00
Alan Agius
337bc3cae6 refactor(@angular/build): remove file: prefix from JIT component resource URLs in sourcemaps
Previously, JIT component resource URLs in sourcemaps included a `file:` prefix (e.g., `file:src/app/app.component.html`). This change removes the `file:` prefix to ensure cleaner source mappings.
2025-03-03 16:57:24 +01:00
Angular Robot
38ef5d7c56 build: update all non-major dependencies 2025-03-03 13:32:31 +01:00
Charles Lyding
25ea0986b1 fix(@angular/build): handle undefined less stylesheet sourcemap values
There can be cases where the `less` stylesheet preprocessor will return
an undefined value for a sourcemap even though sourcemaps have been enabled.
A check is now performed to handle these cases to prevent potential crashes
when processing `less` styles.
2025-02-28 11:06:10 -05:00
Charles Lyding
eb058d0659 fix(@angular/build): always disable JSON stats with dev-server
When using the development server, the `statsJson` option will now
unconditionally be disabled. The output JSON file is not accessible
with the server and the analysis/generation of the JSON file may
increase the rebuild time. Additionally, the JSON file changes during
a rebuild may unexpectedly cause component HMR fallback to a full
reload due to non-component file changes in the build output.
2025-02-25 13:20:18 -05:00
Angular Robot
aa634f9a3a build: update all non-major dependencies 2025-02-25 08:18:52 -08:00
Angular Robot
92aa9e05bb build: update all non-major dependencies 2025-02-24 16:33:08 -08:00
Joey Perrott
c21632c656 refactor(@angular/build): fix dependencies and import paths for strict deps requirements 2025-02-20 14:18:10 -05:00
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
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
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
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