2894 Commits

Author SHA1 Message Date
Alan Agius
cc09b701a9 fix(@angular-devkit/build-angular): correctly handle sass imports
Prior to this change nested imports in sass were processed as scss when using the esbuild builder due to an incorrect check.

Closes #25338
2023-06-08 17:27:14 +02:00
Alan Agius
bc48a0db31 build: update all non-major dependencies 2023-06-07 15:26:36 +02:00
Charles Lyding
bc5b7d515b refactor(@angular-devkit/build-angular): improve initial file analysis for esbuild builder
When using the esbuild-based browser application builder, the set of initially loaded files
for the application is now calculated by analyzing potential transitively loading JavaScript
and/or CSS files. This ensures that the full set of bundled files is available for bundle
size calculations as well as further analysis in areas such as link-based hint generation in
the application's index HTML.
This also fixes a bug where non-injected `scripts` where incorrectly shown as initial files.
2023-06-07 10:43:56 +02:00
Romeo Mihalovics
7155cbe5b2 fix(@angular-devkit/build-angular): ignore folders starting with a dot in browser-esbuild watcher
When running the builder in watch mode, and fetching the git repo that the project is contained in, any changes in the .git folder trigger a rebuild. This is especially annoying when the IDE that you use periodically fetches the repository, and the FETCH_HEAD file triggers the rebuild every time. With this change the folders starting with a dot will be ignored in the watcher to avoid similar issues
2023-06-06 15:48:16 +02:00
Romeo Mihalovics
772fe84ed3 fix(@angular-devkit/build-angular): ignore .git folder in browser-esbuild watcher
When running the builder in watch mode, and fetching the git repo that the project is contained in, any changes in the .git folder trigger a rebuild. This is especially annoying when the IDE that you use periodically fetches the repository, and the FETCH_HEAD file triggers the rebuild every time. With this change the .git folder will be ignored in the watcher
2023-06-06 15:48:16 +02:00
Charles Lyding
aaf9ee96bd refactor(@angular-devkit/build-angular): add internal support for index HTML link hints
The index HTML generation functionality for both the Webpack-based and esbuild-based
browser application builder now supports adding link hint elements to the generated output.
This includes `prefetch`, `preload`, `modulepreload`, `preconnect`, and `dns-prefetch` hint
modes. This functionality is not yet used by builds and will be integrated within future
changes.
2023-06-06 12:38:41 +02:00
Angular Robot
52e5cd912d build: update dependency tslib to v2.5.3 2023-06-06 12:37:39 +02:00
Alan Agius
b83dc4463b refactor: create a common plugin to generate virtual modules
This commit adds a new plugin to enable us to create virtual modules more easily.
2023-06-02 09:45:23 -04:00
Charles Lyding
3d1c09b235 feat(@angular-devkit/build-angular): support dev-server package prebundling with esbuild builder
When using the development server with the esbuild-based browser application builder, the underlying
Vite server will now prebundle packages present in an application. During the prebundling process,
the Angular linker will also be invoked to ensure that APF packages are processed for AOT usage.
The Vite prebundling also provides automatic persistent caching of processed packages. This allows
reuse of processed packages across `ng serve` invocations. To support the use of prebundling at the
development server level, all packages are considered external from the build level. The first time
a package is used within an application there may be a short delay upon accessing the page as the
package is processed. Due to the persistent nature of the prebundling, the `ng cache` command is used
to control the use of the feature. Please note, however, disabling the cache will also disable TypeScript
incremental compilation if not otherwise specifically disabled.
2023-06-01 09:36:17 -04:00
Charles Lyding
ee5763dcac refactor(@angular-devkit/build-angular): use fast-glob for file searching support
The file searching within the build system (both Webpack and esbuild) now use the
`fast-glob` package for globbing which provides a small performance improvement.
Since the assets option in particular is within the critical path of the buil pipeline,
the performance benefit from the switch will be most prevalent in asset heavy projects.
As an example, the Angular Material documentation site saw the asset discovery time
reduced by over half with the switch. `fast-glob` is also the package used by Vite
which provides additional benefit by ensuring that the Angular CLI behavior matches
that of the newly integrated Vite development server.
2023-05-31 14:54:13 -04:00
Alan Agius
fc60d22276 fix(@angular-devkit/build-angular): correctly set overridden compiler option
Previously, we set the options of an incorrect variable.
2023-05-31 11:35:58 -04:00
Alan Agius
1225ce4dc4 build: update all non-major dependencies 2023-05-31 10:22:08 -04:00
Charles Lyding
c462d9cb90 fix(@angular-devkit/build-angular): preemptively remove AOT metadata in esbuild builder
The Angular compiler generates two types of metadata calls when it generates AOT code.
This metadata is not used in fully AOT compiled applications and can contain direct references
to components, services, etc. that may affect the output chunk layout of the application.
While this currently has not lead to any problems, it could in the future and the Webpack
bundler already performs a transform that preemptively removes these calls. To remain
consistent, the esbuild-based build system will now also perform this transform.

This also updates the autoprefixer behavior tests to check the actual runtime style text
instead of the style text within the metadata calls.
2023-05-31 07:51:39 -04:00
Charles Lyding
9aa9b5264e feat(@angular-devkit/build-angular): support autoprefixer/tailwind CSS with Less/Sass in esbuild builder
When using the esbuild-based browser application builder, Sass and Less stylesheets will now be post-processed
with autoprefixer and/or Tailwind CSS when applicable. CSS stylesheets were already processed by these tools.
Autoprefixer is queried based on the configured browserslist to determine if any processing is required and
is not added to the build pipeline if no transformations are required. Likewise for Tailwind, if no Tailwind
configuration file is present, Tailwind CSS will also not be added to the build pipeline. If both autoprefixer
and Tailwind are not required, `postcss` (the tool used to post-process the stylesheets) itself is not added
to the build pipeline. This removes the potential for unneeded build time overhead for projects that do not
require these post-processing steps.
The default browserslist currently does require the use of autoprefixer based on autoprefixer's prefix analysis.
2023-05-30 09:54:47 -04:00
Kristiyan Kostadinov
b076a6f4ef build: update to TypeScript 5.1
Bumps up the dev depdencies to TypeScript 5.1-beta and expands the allowed version ranges to prepare for the final release.
2023-05-26 10:34:32 -04:00
Charles Lyding
5cacd34a22 fix(@angular-devkit/build-angular): watch all TypeScript referenced files in esbuild builder
When using the esbuild-based browser application builder in watch mode, all files referenced
by the TypeScript program are now watched in additional to files within the project root.
This allows for more extensive monorepo setups to take advantage of watch mode as TypeScript
files may exist in other library projects within the repository.
2023-05-25 11:26:38 -04:00
Angular Robot
b674bd2c3c build: update all non-major dependencies 2023-05-23 17:42:56 -04:00
Angular Robot
77336f7bcc build: update all non-major dependencies 2023-05-22 09:38:14 -04:00
Alan Agius
6a4ce53857 refactor: disable Webpack topLevelAwait
Webpack enabled top level await by default in version 5.83.0. (See: https://github.com/webpack/webpack/releases/tag/v5.83.0)

This commit restores the previous behaviour, as top level await is not supported due to Zone.js issues.
2023-05-22 09:37:09 -04:00
Alan Agius
b628cff77b build: update all non-major dependencies
(cherry picked from commit 1afbec1e36708737b6ae75277e0649d0e334d1b2)
2023-05-19 17:14:01 +02:00
Charles Lyding
8336ad80da perf(@angular-devkit/build-angular): enable in-memory load result caching for stylesheets in esbuild builder
The stylesheet related plugins for the esbuild-based browser application builder will now cache intermediate
load results when in watch mode. This reduces the potential amount of processing needed during a rebuild for
both `ng build --watch` and `ng serve`.
2023-05-19 12:18:03 +02:00
Charles Lyding
ffea33fc45 refactor(@angular-devkit/build-angular): use helper to setup esbuild plugin load caching
Within the esbuild-based browser application builder, a helper function has been introduced
to streamline the use of the load result cache within the internal plugins. This removes
repeat code that would otherwise be needed. The ability to use a load result cache with the
global script processing has also been added but has not yet been enabled.
2023-05-19 12:18:03 +02:00
Charles Lyding
4c82bb8e81 fix(@angular-devkit/build-angular): percent encode asset URLs in development server for esbuild
When using the esbuild-based browser application builder with the development server, configured
application assets are served directly from disk. The URLs passed to Vite are now percent encoded
to properly handle asset paths that may contain unsupported URL characters.
2023-05-19 10:29:40 +02:00
Angular Robot
541b291cfb build: update dependency tslib to v2.5.2 2023-05-19 10:28:15 +02:00
Angular Robot
cbadb8080f build: update all non-major dependencies 2023-05-17 12:06:49 +00:00
Angular Robot
63f7199a5d build: update all non-major dependencies 2023-05-16 12:33:12 +00:00
Charles Lyding
2d141fe3bc feat(@angular-devkit/build-angular): show estimated transfer size with esbuild builder
When using the esbuild-based browser application builder, the console build stats output
will now show the estimated transfer size of JavaScript and CSS files when optimizations
are enabled. This provides similar behavior to the default Webpack-based builder.
2023-05-16 12:32:56 +00:00
Angular Robot
c2bc6ffc88 build: update all non-major dependencies to v0.17.19 2023-05-15 12:51:20 +00:00
Charles Lyding
141d74d190 fix(@angular-devkit/build-angular): attempt relative global script read first in esbuild builder
When using a global script (`scripts` option) with the esbuild-based browser application builder,
an attempt to read the script as a relative path from the workspace root will be performed first.
This avoids the need to perform a potentially expensive module resolution attempt for files that
are directly available and also ensures the relative paths are given priority over any potential
modules with the same name. This matches prior behavior that also preferred relative paths.
2023-05-15 12:50:59 +00:00
Charles Lyding
ac95732df6 perf(@angular-devkit/build-angular): minor sourcemap ignorelist improvements for esbuild builder
This provides a minor performance benefit for the generation of the Chrome sourcemap ignorelist
generation. Memory is shared were possible and string searching is reduced in certain cases.
2023-05-15 12:50:36 +00:00
Charles Lyding
a9c6b449f6 fix(@angular-devkit/build-angular): normalize Vite dev-server Windows asset paths
When using the esbuild-based browser application builder with the Vite-based development
server on Windows, source asset paths were previously not normalized prior to being included
in request URLs. This could result in invalid asset request URLs due to invalid path
segment separators.
2023-05-15 12:49:28 +00:00
Angular Robot
419cc8282e build: update all non-major dependencies 2023-05-12 15:56:22 -04:00
Charles Lyding
d1f075e732 fix(@angular-devkit/build-angular): correctly generate serviceworker hashes for binary assets
When using the esbuild-based build system with the service worker enabled, binary assets were
unintentionally being hashed with the assumption of UTF-8 encoding. The assets are now hashed
directly to ensure correct output hashes.
2023-05-12 15:41:21 -04:00
Charles Lyding
d8930facc0 feat(@angular-devkit/build-angular): support incremental TypeScript semantic diagnostics in esbuild builder
When using the esbuild-based browser application builder with CLI caching enabled, TypeScript's `incremental`
option will also be enabled by default. A TypeScript build information file will be written after each build and
an attempt to load and use the file will be made during compilation setup. Caching is enabled by default within
the CLI and can be controlled via the `ng cache` command. This is the first use of persistent caching for the
esbuild-based builder. If the TypeScript `incremental` option is manually set to `false`, the build system will
not alter the value. This can be used to disable the behavior, if preferred, by setting the option to `false` in
the application's configured `tsconfig` file.
NOTE: The build information only contains information regarding the TypeScript compilation itself and does not
contain information about the Angular AOT compilation. TypeScript does not have knowledge of the AOT compiler
and it therefore cannot include that information in its build information file. Angular AOT analysis is still
performed for each build.
2023-05-12 11:33:51 -04:00
Charles Lyding
3ede1a2cac feat(@angular-devkit/build-angular): allow forcing esbuild builder with dev-server
To allow lower overhead trial of the developer preview of the esbuild-based builder system,
the development server now has an option to force the usage of the esbuild-based
build system while still retaining the default Webpack-based build system for the
`build` command. The `forceEsbuild`/`--force-esbuild` option can be added to the
`angular.json` options for the `serve` target or used on the command line, respectively.
The `browser-esbuild` builder will be used to build the application using the options
specified by the server configuration's `browserTarget` option. Unsupported build options
will be ignored. If using a third-party builder, a warning will be issued but the build
will still be attempted. Third-party builder usage in this context is considered
unsupported and may result in unexpected behavior or build failures.
2023-05-11 15:43:29 -04:00
Angular Robot
f6c1f088c9 build: update all non-major dependencies 2023-05-10 15:33:55 +00:00
Charles Lyding
1333a4e8c0 refactor(@angular-devkit/build-angular): emit affected files as a group in esbuild builder
The internal emit strategy for the TypeScript/Angular compiler has been adjusted to prefill
the memory cache during the initial phase of the build. Previously each file was emitted
during the bundling process as requested by the bundler. This change has no immediate effect
on the build process but enables future build performance improvements.
2023-05-10 11:20:43 +00:00
Charles Lyding
82bdc9e460 fix(@angular-devkit/build-angular): avoid CommonJS warnings for relative imports with esbuild builders
When using the esbuild-based browser application builder, CommonJS file warnings were incorrectly being
issued for relative file imports. The CommonJS warnings are only intended to be generated for node module
imports.
2023-05-09 15:52:38 +00:00
Charles Lyding
45e98a4f5b fix(@angular-devkit/build-angular): clean incoming index URL before processing in esbuild builder
When using the esbuild-based browser application builder with the development server, the incoming
URL for the index HTML may contain search parameters or other URL elements that can cause the index
HTML content to not be found or processed incorrected by the development server. These elements are
cleaned prior to comparison and the original URL is not longer passed to Vite to avoid unneeded
Vite specific processing of the content.
2023-05-09 14:05:20 +00:00
Charles Lyding
ca8e5087fb fix(@angular-devkit/build-angular): show error note for CSS url() tilde usage in esbuild builder
When using the esbuild-based browser application builder with a `url()` in a stylesheet that uses
that Webpack-specific tilde prefix, a note will be added to the resolution error providing additional
information regarding the removal of the tilde.
2023-05-09 14:00:33 +00:00
Angular Robot
c109fb6a16 build: update all non-major dependencies 2023-05-08 15:50:28 +00:00
Charles Lyding
892fcc6892 fix(@angular-devkit/build-angular): convert dev-server glob proxy entries for esbuild builder
When using the esbuild-based browser application builder with the development server, an
underlying Vite server is used. The Vite server currently does not support glob-based entries
for the proxy configuration. They must either be prefix strings or regular expressions. The
Webpack-based development server, however, does support globs. To remove the need to have
different proxy configuration files for the two servers, the entries will now be normalized
to regular expressions when using the Vite server. This allows existing proxy configurations
to work without modification.
2023-05-08 15:45:21 +00:00
Alan Agius
740610a902 Revert "fix(@angular-devkit/build-angular): set public class fields as properties (#24849)"
This reverts commit 04274afc15084ead2916e11055aa8f1d2f61951d.

Closes: #25161
2023-05-08 13:35:05 +00:00
Alan Agius
126b23edea fix(@angular-devkit/build-angular): disable runtime errors from being displayed in overlay
By default now webpack-dev-server adds runtime errors in an overlay. See: aab01b3c4e this commit disables this functionality.

Closes #25151
2023-05-08 13:34:49 +00:00
Angular Robot
0c3da6235a build: update angular 2023-05-08 13:07:27 +00:00
Leosvel Pérez Espinosa
e15100d597 fix(@angular-devkit/build-angular): fix index option const value for browser-esbuild 2023-05-08 13:06:48 +00:00
Charles Lyding
a68ef0bbb4 fix(@angular-devkit/build-angular): properly set base dev-server path with esbuild
When using the esbuild-based browser application builder with the development server,
the `baseHref` build option will now be properly propagated to the underlying Vite
server.
2023-05-08 13:06:01 +00:00
Charles Lyding
3aa1c4ec1a fix(@angular-devkit/build-angular): workaround for esbuild static block AOT generated code
esbuild currently has a defect involving self-referencing a class within a static code block or
static field initializer. This is not an issue for projects that use the default browserslist as these
elements are an ES2022 feature which is not support by all browsers in the default list. However, if a
custom browserslist is used that only has newer browsers than the static code elements may be present.
This issue is compounded by the default usage of the tsconfig `"useDefineForClassFields": false` option
present in generated CLI projects which causes static code blocks to be used instead of static fields.
esbuild currently unconditionally downlevels all static fields in top-level classes so to workaround the
Angular issue only static code blocks are disabled here.

Fixes #25127
2023-05-08 13:05:42 +00:00
Charles Lyding
57f0be7990 fix(@angular-devkit/build-angular): prevent relative import failure with Less in esbuild builder
When using the esbuild-based browser application builder, relative Less imports could cause
a fatal exception. This has now been corrected.
2023-05-04 20:26:54 +00:00
Charles Lyding
2a2817db74 fix(@angular-devkit/build-angular): avoid hash filenames for non-injected global styles/scripts
When using the esbuild-based browser application builder, non-injected global styles and scripts
were unintentionally being output with filenames that contain a hash. This can prevent the filenames
from being discoverable and therefore usable at runtime. The output filenames will now no longer
contain a hash component which matches the behavior of the Webpack-based builder.
2023-05-04 20:26:40 +00:00