164 Commits

Author SHA1 Message Date
Alan Agius
607a97cdeb refactor(@angular/ssr): bundle Critters
This commit bundles the Critters library to ensure compatibility with Nodeless environments. Additionally, all licenses for bundled libraries, including Critters, are now included in the package. This helps maintain compliance with open-source license requirements.
2024-08-24 07:37:36 +02:00
Charles Lyding
4d5af43886 refactor(@angular/build): use Angular compiler CLI private tooling export
The `@angular/compiler-cli/private/tooling` package export is now used instead
of the main package export to allow cleanup of the compiler-cli package. This
secondary export has existed for several major versions.
2024-08-22 17:48:04 +02:00
Alan Agius
e40384e637 refactor(@angular-devkit/build-angular): remove deprecated browserTarget
The `browserTarget` option has been removed as part of the refactoring process. This option was part of a private API and is no longer used. Projects relying on this option should migrate to using the `buildTarget` option.

BREAKING CHANGE: The `browserTarget` option has been removed from the DevServer and ExtractI18n builders. `buildTarget` is to be used instead.
2024-08-21 19:53:04 +02:00
Alan Agius
d6a34034d7 refactor(@angular/build): remove automatic addition of @angular/localize/init polyfill and related warnings
The logic that automatically added the `@angular/localize/init` polyfill has been removed.

BREAKING CHANGE: The `@angular/localize/init` polyfill will no longer be added automatically to projects. To prevent runtime issues, ensure that this polyfill is manually included in the "polyfills" section of your "angular.json" file if your application relies on Angular localization features.
2024-08-21 15:42:21 +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
Angular Robot
91b561d652 build: update dependency watchpack to v2.4.2 2024-08-14 17:04:47 +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
Angular Robot
289ea4cad2 build: update all non-major dependencies 2024-08-12 13:53:07 -04: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
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
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
Angular Robot
9204f625c1 build: update all non-major dependencies 2024-07-09 09:58:59 +02:00
Charles Lyding
fee575e126 fix(@angular/build): read WASM file from script location on Node.js
When using a WASM file on Node.js via SSR/SSG/etc. the path for the `readFile`
call will now be based on the location of the script using the WASM file
instead of the current working directory.
This change also adds a general Node.js WASM E2E test via prerendering.
2024-07-09 09:58:33 +02:00
Charles Lyding
4286bb03b5 refactor(@angular/build): remove direct usage of undici dependency for SSR
The Node.js types (`@types/node`) now contains the information for the `Response`
class and the global `fetch` function. The `Response` object is also globally
accessible in all versions of Node.js supported by the Angular CLI. This removes
the need to depend directly on the `undici` package.
The `undici` package is still used for unit-testing and remains as a development
dependency.
2024-07-08 18:54:18 +02:00
Angular Robot
89aa22a7ba build: update all non-major dependencies 2024-07-08 12:06:20 +02:00
Charles Lyding
aa88e68264 fix(@angular/build): check inlineSourceMap option with isolated modules optimization
The isolated modules transpilation option that was recently introduced is
currently disabled when source maps are enabled. TypeScript has two mutually
exclusive options that can be used to check for source map usage. Both of
these options (`sourceMap` and `inlineSourceMap`) are now checked to determine
if the direct transpilation optimization can be used.
2024-07-03 13:31:43 -04:00
Angular Robot
b0b39b30d3 build: update all non-major dependencies 2024-07-03 09:27:02 -04:00
Charles Lyding
2cb1fb350b feat(@angular/build): support WASM/ES Module integration proposal
Application builds will now support the direct import of WASM files.
The behavior follows the WebAssembly/ES module integration proposal. The usage
of this feature requires the ability to use native async/await and top-level
await. Due to this requirement, applications must be zoneless to use this new
feature. Applications that use Zone.js are currently incompatible and an error
will be generated if the feature is used in a Zone.js application. Manual
setup of a WASM file is, however, possible in a Zone.js application if WASM
usage is required. Further details for manual setup can be found here:
https://developer.mozilla.org/en-US/docs/WebAssembly/Loading_and_running

The following is a brief example of using a WASM file in the new feature
with the integration proposal behavior:
```
import { multiply } from './example.wasm';

console.log(multiply(4, 5));
```

NOTE: TypeScript will not automatically understand the types for WASM files.
Type definition files will need to be created for each WASM file to allow
for an error-free build. These type definition files are specific to each
individual WASM file and will either need to be manually created or provided
by library authors.

The feature relies on an active proposal which may change as it progresses
through the standardization process. This may result in behavioral differences
between versions.
Proposal Details: https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration

For more information regarding zoneless applications, you can visit https://angular.dev/guide/experimental/zoneless
2024-07-03 09:26:44 -04:00