2917 Commits

Author SHA1 Message Date
Charles Lyding
a6c06c4d7c fix(@angular-devkit/build-angular): allow linker JIT support with prebundling with esbuild builder
When using prebundling with the Vite-based development server, the Angular linker will now
correctly emit JIT module scope information. This information is required in JIT mode for
NgModules to successfully be used in an application.
2023-06-23 08:21:35 -04:00
Alan Agius
f3f618f206 build: update critters to 0.19.0
Update critters to the latest version.

Closes #25388
2023-06-22 11:27:18 -04:00
Charles Lyding
5c6e3ec48d fix(@angular-devkit/build-angular): track postcss provided file dependencies in esbuild builder
Postcss plugins may provide result messages that contain stylesheet dependencies that should
be watched and should trigger a rebuild of the stylesheet being processed. These files will
now be linked to the stylesheet and will allow the provided file dependencies to be
watched and in-memory caches to be invalidated. Both the `dependency` and `dir-dependency`
postcss messages are supported.
2023-06-22 10:59:30 -04:00
Charles Lyding
518149d451 refactor(@angular-devkit/build-angular): use direct fs caching for font inlining
The `cacache` package was only minimally used within the font inlining post-build
processing. The usage has now been replaced with direct filesystem access and key
hashing to cache any font files. This not only lowers the overall dependency count
but also provides a small performance improvement by removing the need to resolve,
load, and evaluate additional JavaScript at build time.
2023-06-22 10:47:25 -04:00
Charles Lyding
e827c69234 fix(@angular-devkit/build-angular): watch all bundler provided inputs with esbuild builder
When using the esbuild-based browser application builder in watch mode (including `ng serve`),
all input files provided by the bundler via the internal metafile information will now be
watched and will trigger rebuilds if changed. This allows for files outside of the TypeScript
compilation that are also outside of the project source root to be watched. This situation
can be encountered in monorepo setups where library code is directly referenced within an application.
2023-06-22 10:42:32 -04:00
Paul Gschwendtner
9d9a668453 fix(@angular-devkit/build-angular): experimental esbuild pipeline, add es2015 to main fields for RxJS v6 compatibility
Currently, for RxJS v6, no conditions are available, and the ESBuild
pipeline will select the ES5 distribution based on the `module` main
field. This is fine in most cases, but applications could benefit from
better optimization with the use of the ES2015 output + there are
certain code differences that currently would cause runtime breakages
when e.g. `rxjs/testing` is used.

See: https://github.com/angular/angular-cli/issues/25405 for more details.

Fixes #25405.
2023-06-20 12:16:17 -04:00
Charles Lyding
02bf9f2b78 refactor(@angular-devkit/build-angular): remove unneeded static block workaround
esbuild 0.18.2 contains a fix that removes the need for the workaround of disabling
support for static class blocks.
Related issue: https://github.com/evanw/esbuild/issues/2950
2023-06-16 12:28:58 -04:00
Charles Lyding
de5c731a3c test: update autoprefixer behavior tests to not use metadata emit 2023-06-16 10:20:27 -04:00
Charles Lyding
b4aa4abe74 Revert "fix(@angular-devkit/build-angular): preemptively remove AOT metadata in esbuild builder"
These changes are causing imported types to be incorrectly retained.

This reverts commit c462d9cb90377342980384c6bccb3ddfef533282.
2023-06-16 10:20:27 -04:00
Charles Lyding
480bd4e30e fix(@angular-devkit/build-angular): actually disable Vite prebundling file discovery
The `entries` option should be used instead of the `includes` option to disable the
file entry based discovery for Vite's prebundling. This discovery is unneeded due
to the built application files existing only in memory.
2023-06-16 10:13:52 -04:00
Angular Robot
56d27a4505 build: update dependency piscina to v4 2023-06-16 10:13:09 -04:00
Alan Agius
3d271132ae fix(@angular-devkit/build-angular): unpin and downgrade browserslist
This is in an effort to reduce errors like `"Unknown version 114 of edge (While processing: "base$0$0")"` which are caused by mismatching versions.

Closes #25377
2023-06-16 10:12:41 -04:00
Angular Robot
bb4c9c82e8 build: update all non-major dependencies 2023-06-15 09:59:43 -04:00
aanchal
a4e3f53083 refactor: remove unused constructor method 2023-06-14 11:25:05 +02:00
Doug Parker
d4a2849010 build: bump versions for minor release 2023-06-13 09:22:39 -07:00
Alan Agius
6bebc45776 refactor: move esbuild index generator, code bundle option and execution results
This commit extracts code in separate files.
2023-06-09 16:58:23 +02:00
Alan Agius
466d86dc8d refactor(@angular-devkit/build-angular): update code base structure to facilitate future builders
This commit updates the code base structure in preparation for future works.
2023-06-09 16:02:14 +02:00
Charles Lyding
779c969f31 fix(@angular-devkit/build-angular): support proxy configuration array-form in esbuild builder
When using the Webpack-based browser application builder with the development server, the
proxy configuration can be in an array form when using the `proxyConfig` option. This is unfortunately
not natively supported by the Vite development server used when building with the esbuild-based
browser application builder. However, the array form can be transformed into the object form.
This transformation allows for the array form of the proxy configuration to be used by both
development server implementations.
2023-06-09 15:03:06 +02:00
alkavats1
76a12277f7 refactor: removed unused import statements 2023-06-09 13:39:32 +02:00
alkavats1
ab9adea057 refactor: replaced the String wrapper object with primitive type string 2023-06-09 13:39:18 +02:00
Angular Robot
dac0f25dfb build: update all non-major dependencies 2023-06-09 13:20:53 +02:00
Charles Lyding
2a3fc68460 feat(@angular-devkit/build-angular): add preload hints based on transitive initial files
When using the esbuild-based browser application builder, the pre-existing initial file
analysis is now used to generate preload hints for any transitive initial files required
by the application. These hints are generated for both the initial JavaScript chunks and
any initial global stylesheets that may be present. These hints provide additional
information to the browser so that it can start and better prioritize fetching of files
needed to start the application.
2023-06-09 11:00:00 +02:00
Alan Agius
051998c908 build: update all non-major dependencies
(cherry picked from commit 310fef6e9028dbc95dc1456e37e294201fc247c3)
2023-06-08 17:27:38 +02:00
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