1390 Commits

Author SHA1 Message Date
Alan Agius
e58c585295 refactor(@angular/ssr): remove duplicate resetAngularServerApp method
The `resetAngularServerApp` method was identical to `destroyAngularServerApp` and was mistakenly retained due to an incorrect merge. This commit removes the redundant method.
2024-08-21 15:42:13 +02:00
Alan Agius
1c185183c3 refactor(@angular/ssr): expose private APIs for build system integration and refactor app management
- Exposed several utility functions as private APIs to support the integration with the build system.
- Removed `isDevMode` and caching logic from `AngularAppEngine`. This was necessary to better handle updates when using Vite. Instead, `AngularServerApp` is now treated as a singleton to simplify management.
- Switched asset storage from an `Object` to a `Map` in the manifest for improved efficiency and consistency.

This refactor sets the groundwork for seamless wiring with the build system.
2024-08-21 09:30:01 +02:00
Angular Robot
4df3cef1f5 build: update all non-major dependencies 2024-08-21 07:44:07 +02:00
Charles Lyding
e72eb05cc6 refactor(@angular/build): template style elements should always be CSS
Now that style elements within templates are processed as inline component
styles, the style contents should only be considered CSS. This ensures
consistent behavior prior to when style elements were processed. It also ensures
that the styles will function as expected in JIT mode where template styles
cannot be preprocessed and must be written in a browser supported language.
2024-08-20 19:54:04 +02:00
Charles Lyding
6b544f70e7 fix(@angular/build): support reading on-disk files during i18n extraction
If an application has JavaScript files that are sourced directly from disk,
the extraction would previously fail due to the i18n extractor only able
to access the in-memory generated JavaScript files. The extractor can now
access both memory and disk-based JavaScript files.
2024-08-20 17:05:27 +02:00
Angular Robot
212034bab3 build: update all non-major dependencies 2024-08-19 13:24:50 +02:00
Alan Agius
71c06c69f6 fix(@angular/build): improve error message when an unhandled exception occurs during prerendering
This change enhances the error messaging when an unhandled exception occurs during the prerendering process. The updated error message provides more context and clarity.

**Previous Behavior**

```
ng b
An unhandled exception occurred: Some error!!!
See "/tmp/ng-S2ABKF/angular-errors.log" for further details.
```

**Updated Behavior:**
```
ng b
Browser bundles
Initial chunk files     | Names               |  Raw size | Estimated transfer size
main-AFPIPGGK.js        | main                | 218.00 kB |                59.48 kB
polyfills-Z2GOM3BN.js   | polyfills           |  35.82 kB |                11.80 kB
styles-5INURTSO.css     | styles              |   0 bytes |                 0 bytes

                        | Initial total       | 253.82 kB |                71.28 kB

Server bundles
Initial chunk files     | Names               |  Raw size
server.mjs              | server              |   1.11 MB |
chunk-HZL5H5M5.mjs      | -                   | 526.77 kB |
polyfills.server.mjs    | polyfills.server    | 269.91 kB |
chunk-GFWAPST7.mjs      | -                   |  19.16 kB |
chunk-5XUXGTUW.mjs      | -                   |   2.55 kB |
render-utils.server.mjs | render-utils.server |   1.46 kB |
main.server.mjs         | main.server         | 149 bytes |

Lazy chunk files        | Names               |  Raw size
chunk-7YC4RJ5P.mjs      | xhr2                |  12.08 kB |

Prerendered 1 static route.
Application bundle generation failed. [4.923 seconds]

✘ [ERROR] An error occurred while prerendering route '/'.

Error: Some error!!!
    at render (node_modules/@angular/build/src/utils/server-rendering/render-worker.js:20:20)
    at /angular-cli/abc/node_modules/piscina/dist/worker.js:146:32
```

Closes #28212
2024-08-15 15:52:31 +02:00
Charles Lyding
618fdea00b build: update Angular versions to 19.0.0-next.0 2024-08-14 16:15:35 -04:00
Alan Agius
474571f087 build: remove Bazel typings workaround
The workaround is no longer necessary since the bug has been resolved upstream.
2024-08-14 19:12:27 +02:00
Angular Robot
91b561d652 build: update dependency watchpack to v2.4.2 2024-08-14 17:04:47 +02:00
Alan Agius
650aeec286 build: add missing pkg_deps for @angular/create
Included missing `@angular/cli` in `pkg_deps`.
2024-08-14 16:42:42 +02:00
Alan Agius
e9b057b39d refactor(@angular/build): remove route extractor and use version from @angular/ssr
Removed the route extractor from `@angular/build` and replaced it with the one from `@angular/ssr` for consistency and improved maintenance.
2024-08-14 16:42:24 +02:00
Alan Agius
bca5683893 feat(@angular/ssr): dynamic route resolution using Angular router
This enhancement eliminates the dependency on file extensions for server-side rendering (SSR) route handling, leveraging Angular's router configuration for more dynamic and flexible route determination. Additionally, configured redirectTo routes now correctly respond with a 302 redirect status.

The new router uses a radix tree for storing routes. This data structure allows for efficient prefix-based lookups and insertions, which is particularly crucial when dealing with nested and parameterized routes.

This change also lays the groundwork for potential future server-side routing configurations, further enhancing the capabilities of Angular's SSR functionality.
2024-08-14 11:05:12 +02:00
Angular Robot
289ea4cad2 build: update all non-major dependencies 2024-08-12 13:53:07 -04:00
Alan Agius
c5ed0b1248 fix(@angular/cli): prevent bypassing select/checkbox prompts on validation failure
Previously, when a select or checkbox prompt failed validation, it was bypassed, preventing users from correcting their input. This commit ensures that when validation fails, the prompts are re-displayed, allowing users to make the necessary corrections. This improves the user experience and helps avoid unintended selections.

Closes #28189
2024-08-12 15:42:17 +02:00
Alan Agius
3c9697a8c3 feat(@angular/ssr): introduce new hybrid rendering API
This commit introduces the new hybrid rendering API for Angular's Server-Side Rendering (SSR). The API aims to enhance the flexibility of SSR as discussed in https://github.com/angular/angular/discussions/56785

- This API is currently not accessible.
- Additional work is required in the Angular CLI to:
  - Wire up the manifest.
  - Integrate other necessary components.
2024-08-09 09:36:54 +02:00
Charles Lyding
34908a3fcb fix(@angular/build): lazy load Node.js inspector for dev server
The Node.js inspector will now only be imported if SSR is enabled and
the `inspect` option is used. This prevents potential failures when a
custom Node.js binary build is used that has not enabled inspector usage.
While this is not common, loading the inspector on demand is a minimal
change that also avoids loading code that will not be used for the majority
of development server usage.
2024-08-07 11:44:35 -04:00
Angular Robot
3e1f952536 build: update all non-major dependencies 2024-08-07 11:00:03 -04:00
Charles Lyding
42438302d8 refactor(@angular/build): avoid write file logic for internal application build action
The internal "buildApplicationInternal" function is only used by several consumers that
require writing the output files to disk. One, `browser-esbuild`, directly writes
to the disk. The two experimental unit test builders also have unique requirements
and also directly write. This leaves only the main `application` builder that relies on the
internal file writing functionality of `buildApplicationInternal`. To avoid unneeded
logic for the other usages (`dev-server`, `extract-i18n`, unit testing, etc.), the
disk writing logic is now elevated to the `application` build itself. The internal
function will now always provide the output files within the result objects generated
from a successful build. This also removes the need for the other usages to specify
that files should not be written to disk.
2024-08-06 08:23:18 -04:00
Angular Robot
349e052f41 build: update all non-major dependencies 2024-08-05 15:43:13 -04:00
Charles Lyding
182ecbd188 fix(@angular/build): allow explicitly disabling TypeScript incremental mode
If the TypeScript `incremental` option is explicitly set to `false`, the
`application` builder will no longer attempt to enable and use incremental
compilation mode via stored TypeScript build file information. This prevents
an potential build time error that would otherwise occur due to the `tsBuildInfoFile`
option being set without the `incremental` option.
Behavior remains the same if the option is not present or set to `true`.
2024-08-05 15:19:53 -04:00
Angular Robot
2bf8e7f296 build: update all non-major dependencies 2024-07-30 12:40:39 +02:00
Alan Agius
7d52941a2e fix(@angular/build): prevent build failures with remote CSS imports when Tailwind is configured
This addresses a bug where `@import url()` statements with remote CSS files (ending in .css) caused build errors when Tailwind was present. The issue arised from incorrect handling of remote URLs by the stylesheet plugin, which treated them as local files. This fix ensures proper handling of remote CSS imports.

Closes #28113
2024-07-29 16:40:55 +02:00
Angular Robot
22938486c5 build: update all non-major dependencies 2024-07-29 14:39:15 +02:00
Alan Agius
636cb69324 fix(@angular/build): add CSP nonce attribute to script tags when inline critical CSS is disabled
Prior to this change when inline critical CSS is disabled CSP `nonce` was not added to script tags.

Closes #28102
2024-07-29 10:30:19 +02:00
Alan Agius
0466fb74a2 fix(@angular/build): resolve error with extract-i18n builder for libraries
The `extract-i18n` builder is only intended to be used with application projects.

Closes #28109
2024-07-29 09:06:42 +02:00
Angular Robot
790835162c build: update all non-major dependencies 2024-07-25 09:42:23 -07:00
Angular Robot
048df34ccb build: update dependency @inquirer/prompts to v5.3.2 2024-07-23 18:14:59 -07:00
Angular Robot
94b331e667 build: update all non-major dependencies 2024-07-22 12:53:59 -07:00
Charles Lyding
8ff687d036 fix(@angular/build): correctly detect comma in Sass URL lexer
The Sass rebasing lexer was incorrectly checking for a comma in certain
cases previously. This has now been corrected and url usage that immediately
follows a comma within a rule will now be extracted as expected.
2024-07-19 12:52:32 -04:00
Alan Agius
11a140babb fix(@angular/build): serve HTML files directly
Ensure direct requests to HTML files result in them being served.

Closes #28063
2024-07-19 12:52:18 -04:00
Charles Lyding
421b6e75b4 refactor(@angular/build): provide structured application builder result types
The application builder now provides structured output types to its internal
consumers. The architect builders themselves and the programmatic API is
not changed. These output result types allow for the development server to
receive additional information regarding the build and update the active
browser appropriately. This functionality is not yet implemented but the
additional result types provide the base infrastructure to enable future
features. The result types also allow for reduced complexity inside other
builders such as i18n extraction and the browser compatibility builder.
The usage is not yet fully optimized and will be refined in future changes.
2024-07-19 10:08:38 -04:00
Charles Lyding
37a2138cb4 fix(@angular/build): account for HTML base HREF for dev-server externals
When adjusting URLs to support explicit external dependencies when using Vite,
the workaround will now account for the presence of a base HREF value within
the specifier. Vite will automatically add the base HREF as a prefix to the
path when specified. This previously resulted in invalid specifiers due to
the partial removal of the Vite specific `@id` path prefix.
2024-07-19 09:29:27 -04:00
Angular Robot
64b50815e1 build: update all non-major dependencies 2024-07-18 10:04:45 -07:00
Alan Agius
6d6937587f fix(@angular/build): prevent redirection loop
Added handling to ensure trailing slashes on static files do not disregard query strings.

Closes #28071
2024-07-18 15:51:31 +02:00
Angular Robot
e21e9867f0 build: update all non-major dependencies 2024-07-17 09:34:41 -07:00
Bayyr Oorjak
855a4b8412 fix(@angular/build): resolve only ".wasm" files 2024-07-17 09:33:37 -07:00
Alan Agius
f5c250ab48 refactor: rename internal vite plugin name.
Follow convention.
2024-07-16 15:47:07 +02:00
Angular Robot
346ad54a58 build: update all non-major dependencies 2024-07-15 09:29:51 -07:00
Karel Frederix
394f9ce35f fix(@angular/build): remove Vite "/@id/" prefix for explicit external dependencies
Adds a Vite plugin which will remove the /@id/ prefix (which gets inserted by Vite during import-analysis) for explicit externalDependencies.
2024-07-15 09:29:04 -07:00
Charles Lyding
24aaf1e37f feat(@angular/build): support import attribute based loader configuration
When using the application builder, a `loader` import attribute is now available
for use with import statements and expressions. The presence of the import
attribute takes precedence over all other loading behavior including JS/TS and
any `loader` build option values. This allows per file control over loading
behavior. For general loading for all files of an otherwise unsupported file
type, the `loader` build option is recommended.

For the import attribute, the following loader values are supported:
* `text` - inlines the content as a string
* `binary` - inlines the content as a Uint8Array
* `file` - emits the file and provides the runtime location of the file

Unfortunately, at this time, TypeScript does not support type definitions
that are based on import attribute values. The use of `@ts-expect-error`
or the use of individual type definition files (assuming the file is only
imported with the same loader attribute) is currently required.

Additionally, the TypeScript `module` option must be set to `esnext` to
allow TypeScript to successfully build the application code.

As an example, an SVG file can be imported as text via:
```
// @ts-expect-error TypeScript cannot provide types based on attributes yet
import contents from './some-file.svg' with { loader: 'text' };
```

When using the development server and a file that is referenced from a Node.js
package with a loader attribute, the package must be excluded from prebundling
via the development server `prebundle` option. This does not apply to relative
file references.
2024-07-15 08:08:35 -04:00
Angular Robot
81a3563b6f build: update all non-major dependencies 2024-07-12 11:19:35 +02:00
Mickaël Depardon
9baae6e22c fix(@angular-devkit/build-angular): skip undefined files when generating budget stats
When the sourceMaps are enabled they are generating some files that are computed by the budget stats. Now the method `generateBudgetStats` skip when the file is undefined.
2024-07-12 10:13:53 +02:00
Charles Lyding
5895e9fb01 test: enable no-case-declarations lint rule
The `no-case-declarations` rule is now enabled and all failures
in have been addressed within the published code. Unit tests
have been excluded.
2024-07-11 08:19:56 +02:00
Charles Lyding
eced3a8ecc test: enable no-fallthrough lint rule
The `no-fallthrough` rule is now enabled and all failures
have been addressed within the code.
2024-07-11 08:19:56 +02:00
Charles Lyding
1271e4a0e5 refactor(@angular/build): use listr2 for spinner and color support
The `ansi-color` and `ora` dependencies have been replaced with `listr2`.
This package provides both color and spinner capabilities and further
reduces the dependency count. This also aligns the dependencies with
the `@angular/cli` package with already uses `listr2`. The spinner also
now will not overwrite console output that happens to be written while
the spinner is active. Instead, the output will be written after the
spinner task is complete.
2024-07-11 08:19:19 +02:00
Alan Agius
01c1ec087e build: update Angular dependencies to version 18.2.0-next.0 2024-07-10 16:00:13 +02:00
Angular Robot
22d9369aef build: update all non-major dependencies 2024-07-10 09:07:48 +02:00
Charles Lyding
10f882c562 refactor(@angular/cli): use Node.js CommonJS wrapping for schematic encapsulation
The schematics encapsulation process now uses a similar wrapping setup to
Node.js itself. This removes some custom code and also provides a more
comprehensive global object which should provide improved compatibility
for third-party packages used within schematics.
2024-07-10 08:40:11 +02:00
Angular Robot
9204f625c1 build: update all non-major dependencies 2024-07-09 09:58:59 +02:00