1330 Commits

Author SHA1 Message Date
Alan Agius
f16fbd82ad build: update all non-major dependencies 2024-07-01 13:44:11 +02:00
Angular Robot
9c26db46d7 build: update dependency https-proxy-agent to v7.0.5 2024-06-28 11:38:05 -07:00
Alan Agius
b5af8b59be refactor(@angular/build): move Vite middlewares into separate files
As the number of middlewares has increased over time, this commit enhances code health by relocating them into individual files.
2024-06-28 17:23:46 +02:00
Alan Agius
9a1c059f7c fix(@angular/build): redirect to path with trailing slash for asset directories
Prior to this commit, accessing a static asset directory without a trailing slash resulted in a 404 error. With this change, we now redirect to the path with a trailing slash, aligning with the behavior of express static.

Closes #27949
2024-06-28 15:37:52 +02:00
Charles Lyding
a5f1b918fd refactor(@angular/build): add experimental chunk optimizer for production application builds
An experimental chunk optimizer is now available for initial usage.
To enable the optimization, script optimization must be enabled as well as
an environment variable `NG_BUILD_OPTIMIZE_CHUNKS=1`. This build step uses
`rollup` internally to process the build files directly in memory. The main
bundling performs all resolution, bundling, and tree-shaking of the application.
The chunk optimizer step then only needs to access the in-memory built files and does not
need to perform any disk access or module resolution. This allows the step to be
performed fairly quickly but it does add time to the overall production build.
The `NG_BUILD_DEBUG_PERF=1` environment variable can be used to view how long the step
takes within a build via the `OPTIMIZE_CHUNKS` entry. In the future, this optimization
step may be automatically enabled based on initial file entry count and size.
There are several current known issues:
1) Bundle budgets for named lazy chunks may not work as expected.
2) The console output may not show names (files will be present) for lazy chunk files.
3) The stats file (`--stats-json` option) will not exactly reflect the final written application files. This is similar to the current behavior of the `browser` builder with Webpack's stat file.
2024-06-28 08:59:12 -04:00
Angular Robot
7c4e0918d9 build: update all non-major dependencies 2024-06-27 10:09:22 -07:00
ddereszkiewicz
4947f29cfa fix(@angular/cli): make ng update to keep newline at the end of package.json
As stated in https://github.com/angular/angular-cli/issues/11744,
`ng update` command removed the newline at the end of the package.json file.
This commit makes `ng update` to preserve newline, if it was present before running the command.

Fixes #11744
2024-06-27 10:08:29 -07:00
Charles Lyding
75abe2cc52 refactor(@angular/build): use build output files directly in stats and budgets
The bundle budget calculators and the console build stats output are now
calculated directly from the build output file information instead of the
esbuild metafile where possible. This provides a more generic method of
accessing the information and can more accurately account for post-processing
steps that may alter the output files. The metafile is still used for
component style budgets and lazy chunk name information.
2024-06-27 12:37:48 -04:00
Alan Agius
f3ba2080f9 fix(@angular/build): correctly name entry points to match budgets
This commit addresses an issue where some lazy entry points were not name correctly to align with specified budgets.

Closes: #27936
2024-06-27 13:45:47 +02:00
Alan Agius
30473f9203 fix(@angular/build): normalize paths during module resolution in Vite
Before this update, the importer path was not normalized, causing mismatches during SSR on Windows.
2024-06-27 13:43:10 +02:00
Charles Lyding
e6d5c7e0b8 refactor(@angular/build): improve BuildOutputFile property access
The `BuildOutputFile` type's helper functions have been adjusted to cache
commonly accessed property values to avoid potentially expensive repeat
processing. This includes encoding/decoding UTF-8 content and calculating
hash values for the output file content. A size property has also been
added to allow consumers to more directly determine the byte size of the
output file. The size property is currently unused but will be leveraged
in forthcoming updates to bundle budgets and console info logging.
2024-06-27 07:28:16 -04:00
Angular Robot
169daf1a2e build: update dependency piscina to v4.6.1 2024-06-26 08:31:48 -07:00
Charles Lyding
d56c8de284 refactor: minor code cleanup to improve code health
Several smaller code changes to improve type information and remove now
unneeded code structures based on improvements to both Node.js, TypeScript,
and underlying dependencies.
2024-06-25 16:57:16 -04:00
Charles Lyding
fa9bce0e9a test: enable @typescript-eslint/no-unnecessary-type-assertion lint rule
The `@typescript-eslint/no-unnecessary-type-assertion` rule is now enabled and all failures
have been addressed within the code.
2024-06-25 16:57:03 -04:00
Charles Lyding
741cf7fe1e test: enable @typescript-eslint/await-thenable lint rule
The `@typescript-eslint/await-thenable` rule is now enabled and all failures
have been addressed within the code.
2024-06-25 16:57:03 -04:00
Alan Agius
0d2d9860fd build: remove @types/browserslist
`browserslist` now ships it's own typings
2024-06-25 21:20:26 +02:00
Alan Agius
aebfde28c7 build: update all non-major dependencies
Closes #27881
2024-06-25 20:53:49 +02:00
Charles Lyding
137949e8ff refactor(@angular/cli): use non-experimental decorators for internal memoize
With standard decorator support now available for use, the memoize decorator
has been updated to be a standard decorator instead of a TypeScript experimental
decorator. This change also removes the only usage of decorators within the
Angular CLI code itself. This change does not affect application code.
2024-06-25 09:31:57 -07:00
Charles Lyding
17e168379e build: additional fixes for tsetse rule compliance
Due to bazel rules_nodejs caching, several additional `JSON.parse` usages were not
caught in the first set of fixes. These have now been addressed. Also,
the `must-use-promises` rule has been patched to match the behavior of the
`@typescript-eslint/no-floating-promises` for consistency.
The bazel option `suppressTsconfigOverrideWarnings` was also removed from the
`tsconfig` as it is a no-op and was previously used for now removed feature.
Test files are currently excluded from the `JSON.parse` rule to avoid large
changes to test code.
2024-06-25 11:17:33 -04:00
Charles Lyding
579f81798f build: remove tsetse rule exclusions
To remove the tsetse rule exclusions, several usages of `JSON.parse` that
did not have type casting where adjusted to add types. This removed the
need for the manual configuration within the tsconfig.
2024-06-24 12:50:55 -04:00
Alan Agius
3e359da8df fix(@angular/build): address rxjs undefined issues during SSR prebundling
Replacing the paths to ESM in Vite can cause prebundling to fail in some cases, resulting in errors similar to the following:

```
12:55:12 PM [vite] Error when evaluating SSR module /chunk-CHB4JJIP.mjs:
|- TypeError: Cannot read properties of undefined (reading 'Subject')
    at eval (//src/app/shared/snackbar/snackbar.service.ts:2:25)
    at async instantiateModule (file:////node_modules/vite/dist/node/chunks/dep-BcXSligG.js:53408:5)

12:55:12 PM [vite] Error when evaluating SSR module /chunk-GQZ5BKXC.mjs:
|- TypeError: Cannot read properties of undefined (reading 'Subject')
    at eval (//src/app/shared/snackbar/snackbar.service.ts:2:25)
    at async instantiateModule (file:////node_modules/vite/dist/node/chunks/dep-BcXSligG.js:53408:5)
```

Closes: #27907
2024-06-24 16:14:08 +02:00
Charles Lyding
39f946a848 build: enabled isolated modules TypeScript option
The TypeScript `isolatedModules` option is now enabled for all TypeScript
code within the repository. As a result, all packages will now be built
with the option enabled. This does not affect projects created with the CLI
and is only related to the building of the actual Angular CLI code.
The `isolatedModules` option ensures that code can be emitted without the
TypeScript typechecker and allows tools other than TypeScript to potentially
be used. Code was updated to correct all errors after the option was enabled.
Additionally, some early code fixes were done to add function and accessor
return types to prepare for future `isolatedDeclarations` usage. More changes
would be needed to consider turning on `isolatedDeclarations`, however.
2024-06-23 15:34:49 +02:00
Charles Lyding
1e8fd70c6f fix(@angular/build): show JavaScript cache store initialization warning
If the persistent cache store for the JavaScript transformations fails
to initialize, a warning will now be shown to better explain the outcome
and to allow the build to continue. The build will still complete without
the cache but may be slower to finish.
2024-06-21 11:44:36 -04:00
Charles Lyding
1a481c55ea refactor(@angular/build): support directly merging bundler results
The bundler context class now has a static helper method to support merging
bundler results outside of a specific bundle action. This will be used in the
future to support more complex bundling hierarchies.
2024-06-21 10:42:24 -04:00
Charles Lyding
db1a6ae55a refactor(@angular/build): move generic Angular tools into separate source directory
The Angular compiler code that is not specific to esbuild has been moved
into a separate `tools` subdirectory. This allows for potential reuse internal
reuse outside of the Angular esbuild plugin.
2024-06-21 16:27:31 +02:00
Charles Lyding
8b6ae4cf24 refactor(@angular/cli): allow tty and color helpers to use a stream
The `isTTY` and `supportColor` helpers can now accept a stream to check
instead of assuming stdout. This is useful if stderr needs to be checked,
for instance. Also, color checking now uses Node.js `hasColors` where
possible which has been available since Node.js v10.
2024-06-21 16:26:45 +02:00
Charles Lyding
438b530750 refactor(@angular/build): include Angular compiler plugin in private API
Add `createCompilerPlugin` function to the private export of the package.
Note that these are not considered part of the public API and
are intended for use only with the `@angular-devkit/build-angular` package.
2024-06-21 10:27:54 +02:00
Angular Robot
a442f8c3a3 build: update all non-major dependencies 2024-06-20 09:15:40 +02:00
Charles Lyding
18226c6f57 refactor(@angular/cli): remove ora spinner dependency from package
The ora package has been removed now that the progress indicator for the
update command is now based on the `listr2` package that is also used
by the `ng add` command.
2024-06-19 09:52:24 +02:00
Charles Lyding
4c96537378 refactor(@angular/cli): remove ora-based spinner from update command
The `listr2` dependency that was recently introduced to improve the console
UI for the `ng add` command is now used for the package installation step
of the `ng update` command process.
2024-06-19 09:52:24 +02:00
Charles Lyding
dd07049277 fix(@angular/build): use Node.js available parallelism for default worker count
The Node.js `os.availableParallelism` API now provides more accurate values
when used within containers such as many CI environments. This provides a
better default when using resource limited CI setups. The value is still
set to a maximum default of four. However, the `NG_BUILD_MAX_WORKERS`
environment variable can be used to set the value to an explicit value
if required.
2024-06-18 16:23:51 +02:00
Alan Agius
c0ceddf78c fix(@angular/build): add CSP nonce to script with src tags
Prior to this change, script tags with the `src` attribute were not being assigned a CSP nonce during the build process. This is useful
strict-dynamic is a Content Security Policy (CSP) directive that simplifies the management of dynamically loaded scripts while maintaining a high level of security. It allows scripts that are initially trusted (through a nonce or hash) to load other scripts without additional restrictions.

Closes #27874
2024-06-18 15:57:00 +02:00
Angular Robot
a1f60f93c4 build: update all non-major dependencies 2024-06-18 09:41:37 +02:00
Charles Lyding
303807aa68 refactor(@angular/cli): remove direct use of ansi-colors package
The newly introduced `listr2` dependency used for the updated `ng add`
console UI provides color support. This removes the need to retain a
direct dependency on a color package within the `@angular/cli`.
2024-06-18 09:38:57 +02:00
Charles Lyding
af1016630f refactor(@angular/cli): improve console status logging for add command
The step-based console UI of the add command has been refactored to use the `listr2` library.
Previously, an `ora` spinner was manually used and needed to handle a
variety of error conditions and could not handle the potential for concurrent
tasks as well as streaming subcommands cleanly while the spinner was in use.
Behavior of the add command has not been changed during this refactor. Further
improvements are possible including the integration of the schematic execution
within the step-based UI.
2024-06-17 09:07:34 -04:00
Alan Agius
1039a6425f build: update all non-major dependencies 2024-06-14 18:25:29 +02:00
Alan Agius
2324d5a2ec fix(@angular/build): automatically resolve .mjs files when using Vite
Previously, ESM file resolution without extensions failed when using Vite, causing issues in module loading. This commit addresses the problem by automatically resolving `.mjs` files, aligning the behavior with the application builder and ensuring consistent module resolution across different build tools.

**NB**:  This is a workaround as valid ESM imports should always have an extension.

Closes #27841
2024-06-13 22:00:13 +02:00
Alan Agius
8c379269e0 fix(@angular/build): do not reference sourcemaps in web workers and global stylesheet bundles when hidden setting is enabled
This commit addresses an issue where sourcemaps in web workers and global stylesheets were referenced despite the hidden setting being enabled.

Closes: #27833
2024-06-13 08:17:42 -04:00
Angular Robot
a4d81759b8 build: update all non-major dependencies 2024-06-13 08:15:35 -04:00
Alan Agius
6d266c146c fix(@angular/cli): add fallbacks for migration package resolution
Before this commit, running `ng update @angular/cli` would fail when using the PNPM package manager. This update resolves the issue by implementing fallbacks in the migration package resolution logic, similar to the approach used in `NodeWorkflow`.
2024-06-12 18:32:54 +02:00
Charles Lyding
9e35d174cb refactor(@angular/cli): use Node.js builtin ANSI escape removal helper
Node.js contains a helper function within the `util` builtin that will
remove any ANSI escape codes from a string. This removes the need for
a custom utility function.
2024-06-11 08:20:20 -04:00
Charles Lyding
ce850da171 build: update yarn version to v4.2.2 2024-06-10 18:17:03 -04:00
Alan Agius
f102f815e4 fix(@angular/build): Initiate PostCSS only once
Previously, PostCSS was initialized three times (once for each preprocessor), resulting in plugins being applied multiple times to each instance. This issue occured due to a race condition triggered by multiple esbuild plugins.

Fixes #27804
2024-06-10 12:02:26 -04:00
Angular Robot
26c36a119d build: update all non-major dependencies 2024-06-10 11:32:16 -04:00
Charles Lyding
4ff914a165 fix(@angular/build): allow additional module preloads up to limit
If the module preload limit is not met by shallow (depth 1) initial
scripts, deeper initial scripts can now be added. This allows for
deeper import graphs to take advantage of the browser's module preloading.
Additionally, the limit has been increased to ten now that the module
preloads are added at the end of the body along with the actual script elements.
2024-06-10 11:22:49 -04:00
Charles Lyding
461e78f3ee fix(@angular/build): generate module preloads next to script elements in index HTML
The `modulepreload` link elements for initial scripts are now generated next to the
actual script elements that require the referenced preloaded scripts. This better
represents the fetch priorities to the browser and also allows easier visual discovery
of the relevant script related elements inside the index HTML.
2024-06-08 13:55:54 -04:00
Alan Agius
fbc6eb3225 fix(@angular/build): issue warning when auto adding @angular/localize/init
This commit introduces a warning for when the application builders automatically add the @angular/localize/init polyfill. The current approach has a drawback: the localize polyfill will always be included if it is found in a monorepo, even if an application does not use i18n.

To address this, we will issue a warning to inform users about this behavior and encourage them to explicitly add the polyfill to their polyfills configuration.

Additionally, this commit fixes an issue where the polyfill was not removed when using the build-time Angular i18n.
2024-06-07 15:30:06 +02:00
Charles Lyding
7e7fe8b6cb refactor(@angular/build): use latest inquirer prompt package
The `inquirer` package has been rewritten with a new set of packages.
The rewrite had a focus on reduced package size and improved performance.
The main prompt package is now `@inquirer/prompts`. However, for `@angular/build`
only the confirm prompt is needed so the `@inquirer/confirm` package can be
used directly to further reduce dependencies.
2024-06-07 08:58:25 -04:00
Charles Lyding
b411b9854e refactor(@angular/cli): use latest inquirer prompt package
The `inquirer` package has been rewritten with a new set of packages.
The rewrite had a focus on reduced package size and improved performance.
The main prompt package is now `@inquirer/prompts`. The API is very similar
but did require some refactoring to adapt to Angular's usage.
2024-06-07 08:58:25 -04:00
Alan Agius
60b7c13bdd refactor: format bazel build files
The formatter does not automatically fix these failures.
2024-06-06 11:12:06 +02:00