2654 Commits

Author SHA1 Message Date
Angular Robot
4e3c62b6d0 build: update all non-major dependencies 2022-11-21 10:55:10 -05:00
Charles Lyding
67752a4104 fix(@angular-devkit/build-angular): improve package deep import Sass index resolution in esbuild plugin
When resolving Sass imports in the experimental esbuild-based browser application builder's Sass plugin,
previously imported modules are used as the base for resolution attempts to workaround the lack of the
importer file provided by Sass. When attempting to resolve a deep import into a package (including the
potential Sass index files), these previously imported modules also need to be checked. This is
particularly relevant when using the Yarn PnP or pnpm package managers which enforce strict dependency
resolution.

Fixes #24271
2022-11-21 10:54:04 -05:00
Charles Lyding
0c01532cb5 perf(@angular-devkit/build-angular): use worker pool for JavaScript transforms in esbuild builder
When using the experimental esbuild-based browser application builder, the JavaScript transformation
steps of the build process will now be performed within a worker pool to allow for the steps to be
executed in parallel when possible. This also moves the steps off of the main thread which provides
more time for the build orchestration and esbuild integration code to execute.
2022-11-21 10:53:22 -05:00
Alan Agius
012746e759 test: remove target in tsconfig.server.json
This is no longer needed as the CLI uses es2022 internally.
2022-11-18 11:03:15 -08:00
Alan Agius
c29df69546 feat(@angular-devkit/build-angular): add assets option to server builder
This commits adds the `assets` option to the server builder. This can be useful to copy server specific assets such as config files.

Closes #24203
2022-11-18 11:03:15 -08:00
Alan Agius
78ce78cc7e build: remove regenerator-runtime from dependencies
This dependency is no longer needed since we no longer generate es5 output.
2022-11-18 11:03:02 -08:00
Charles Lyding
bc8578cb13 refactor(@angular-devkit/build-angular): preprocess Sass resolve cache entries in esbuild Sass plugin
When performing Sass import resolution within the experimental esbuild-based browser application builder,
the directory cache entries will now be preprocessed during the first directory search operation. This
will allow a more streamlined search operation on later resolution attempts for the same directory.
The caching is still limited to sharing per render request but this change provides for cache entries
that can more easily be serialized and shared between workers in the future.
2022-11-17 16:31:54 -08:00
Angular Robot
69306ddb0e build: update all non-major dependencies 2022-11-16 13:37:03 -08:00
Charles Lyding
2397eed123 refactor(@angular-devkit/build-angular): move esbuild angular compiler host creation to separate function
The creation of the esbuild Angular plugin's Angular compiler host has now been consolidated in a separate
function. This refactor reduces the amount of code within the plugin's main start function as well as centralizing
all initialization of the host into one location.
2022-11-15 10:15:58 -08:00
Alan Agius
11bb8ce26f perf(@angular-devkit/build-angular): add vendor chunking to server builder
With this change we add the `vendorChunk` option in the server builder. This option should only be used in development as it is intended to be used to improve the incremental re-build time.

This improves the rebuild time as Webpack will have less modules to analyse during a change in the application. Below, we can see the impact this change has in a `ng new` application.

Without vendor chunking
```
$ ng run ssr-vendor:server:development --watch --no-vendor-chunk
Build at: 2022-11-14T08:42:27.089Z - Hash: 0325905b63e43ddb - Time: 15357ms
Build at: 2022-11-14T08:42:37.565Z - Hash: 05cb180a02524656 - Time: 2498ms
Build at: 2022-11-14T08:42:40.325Z - Hash: c5a6996ed1924088 - Time: 1862ms
Build at: 2022-11-14T08:42:43.043Z - Hash: 92ce99f38a769c19 - Time: 1516ms
```

With vendor chunking
```
$ ng run ssr-vendor:server:development --watch --vendor-chunk
Build at: 2022-11-14T08:43:13.631Z - Hash: 28bdfea879d01a31 - Time: 15561ms
Build at: 2022-11-14T08:43:19.396Z - Hash: cc95e2b6cb403111 - Time: 1705ms
Build at: 2022-11-14T08:43:21.296Z - Hash: 204138490668a16c - Time: 848ms
Build at: 2022-11-14T08:43:23.835Z - Hash: 4fa294b261917944 - Time: 824ms
```
2022-11-15 10:14:02 -08:00
Charles Lyding
6cc45f69b8 fix(@angular-devkit/build-angular): show file replacement in TS missing file error in esbuild builder
When using the experimental esbuild-based browser application builder with the `fileReplacements` option,
TypeScript missing compilation file errors will now contain a note that the requested file was a
replacement for another file and show the path of the file.
2022-11-14 10:14:28 -08:00
Angular Robot
e333eabef9 build: update all non-major dependencies 2022-11-14 09:30:15 -08:00
Charles Lyding
3f193be775 perf(@angular-devkit/build-angular): add initial global styles incremental rebuilds with esbuild builder
When using the experimental esbuild-based browser application builder in watch mode, global stylesheets
configured with the `styles` option will now use the incremental rebuild mode of esbuild. This allows
for a reduction in processing when rebuilding the global styles. CSS stylesheets benefit the most currently.
Sass stylesheets will benefit more once preprocessor output caching is implemented.
2022-11-14 09:28:55 -08:00
Charles Lyding
4e42261609 refactor(@angular-devkit/build-angular): move internal bundle output processing into esbuild bundle helper
The path adjustments and initial file logic for index file generation are now centralized in the esbuild
build helper function. This allows usage of the functionality in multiple areas of the build system.
2022-11-14 09:28:55 -08:00
Alan Agius
678b0d2c05 fix(@angular-devkit/build-angular): update browerslist package
The `supports` query was added in version `4.13`, while `^4.9.1` does match this version is some cases an older version might be used to the presence of a lock file during the update which would cause the package not to be update.

Closes #24212
2022-11-11 16:40:19 +01:00
Angular Robot
32b1a10305 build: update all non-major dependencies 2022-11-11 08:54:35 +01:00
Angular Robot
363721bc88 build: update all non-major dependencies 2022-11-10 10:10:42 +01:00
Charles Lyding
827feccecc build: remove unused dependency minimatch from @angular-devkit/build-angular
`minimatch` was unused within the `@angular-devkit/build-angular` package.
It is still used in a repository level development script and has been kept
in the root `package.json`.
2022-11-08 19:10:08 +01:00
Alan Agius
c83aaedb29 fix(@angular-devkit/build-angular): warn when components styles sourcemaps are not generated when styles optimization is enabled
With this change we add a warning to inform the users that sourcemaps are not generated when both styles sourcemaps and optimization are enabled. This is because component style sourcemaps are inline which would drastically increase the bundle size.

Closes #22834
2022-11-08 19:09:38 +01:00
Charles Lyding
932a4f4a14 fix(@angular-devkit/build-angular): avoid attempted resolve of external CSS URLs with esbuild builder
When using the experimental esbuild-based browser application builder, `url()` functions within stylesheets
will no longer cause a build failure due to an attempted local file resolution of URLs that do not represent
on-disk resources. This includes absolute, protocol-relative, and root-relative URLs as well as SVG path
identifiers.
2022-11-08 18:15:40 +01:00
Charles Lyding
f7ad20c465 fix(@angular-devkit/build-angular): update sourcemaps when rebasing Sass url() functions in esbuild builder
When using the experimental esbuild-based browser application builder with Sass and sourcemaps, the final
sourcemap for an input Sass stylesheet will now contain the original content for any `url` functions that
were rebased to support bundling. This required generating internal intermediate source maps for each imported
stylesheet that was modified with rebased URLs and then merging these intermediate source maps with the
final Sass generated source map. This process only occurs when stylesheet sourcemaps are enabled.
2022-11-08 09:32:47 +01:00
Angular Robot
0cff3e09cd build: update all non-major dependencies 2022-11-07 19:22:06 +01:00
Alan Agius
d754b72d4e fix(@angular-devkit/build-angular): only add @angular/platform-server/init when package is installed.
This commit fixes an issue where `@angular/platform-server/init` was added as an entry-point during the server build even when this was not installed.

Closes #24188
2022-11-07 19:04:26 +01:00
Charles Lyding
aaad35b0ac fix(@angular-devkit/build-angular): rebase Sass url() values when using esbuild-based builder
When using the experimental esbuild-based browser application builder with Sass, paths contained
in `url()` CSS functions will now be rebased to reflect their final location relative to the
output of the Sass compiler. This allows the bundler to locate and process any resource files
such as images or fonts used within the stylesheet.
The implementation of the rebasing functionality uses a series of custom Sass importers to
transform the input stylesheets (from import or use rules) when they are loaded from the
file system. However, for the Sass compiler to use the load functionality of an importer,
the `canonicalize` function (used to resolve an import) of the same importer must return
a resolved path to the requested stylesheet. To support this requirement, all stylesheet
resolution has been implemented in three new importers: relative, module, and load path.
An additional benefit of these resolvers is that they have been implemented to minimize the
volume of filesystem calls and also cache directory entry information (currently per request)
to further reduce file system access. The reduction in filesystem calls provides a small
performance benefit for projects containing a large amount of Sass file imports.
2022-11-07 14:13:40 +01:00
Angular Robot
7f4c252eb5 build: update all non-major dependencies 2022-11-07 14:07:00 +01:00
Charles Lyding
0662a2e9eb fix(@angular-devkit/build-angular): account for package.json exports with Sass in esbuild builder
When using the experimental esbuild-based browser application builder, Sass module imports will
now resolve using esbuild's resolve methods. This allows for package.json exports and main fields
to be recognized when resolving an import or use rules in Sass files (scss or sass file extensions).
2022-11-04 11:07:07 -07:00
Angular Robot
ab589543b8 build: update all non-major dependencies 2022-11-01 12:28:58 -07:00
Angular Robot
430186706e build: update dependency tslib to v2.4.1 2022-11-01 10:38:32 -07:00
Charles Lyding
942d555cf5 fix(@angular-devkit/build-angular): provide workaround for V8 object spread performance defect
V8 currently has a performance defect involving object spread operations that can cause degradation
in runtime performance. By specifically not supporting the object spread language feature when using
the esbuild-based browser application builder, a downlevel form will be used instead which provides a
workaround for the performance issue. The downlevel form can cause up to a 600 byte increase in file
size if an object spread operation would otherwise be present in an output file.
For more details: https://bugs.chromium.org/p/v8/issues/detail?id=11536
2022-11-01 10:38:01 -07:00
Angular Robot
469ad87499 build: update all non-major dependencies 2022-10-31 10:11:58 -07:00
Charles Lyding
e1ca87890a perf(@angular-devkit/build-angular): use Sass worker pool for Sass support in esbuild builder
When using the experimental esbuild-based browser application builder, Sass stylesheets will
now be processed using a worker pool that is currently also used by the default Webpack-based
builder. This allows up to four stylesheets to be processed in parallel and keeps the main thread
available for other build tasks. On projects with a large amount of Sass stylesheets, this change
provided up to a 25% improvement in build times based on initial testing.
2022-10-31 10:10:32 -07:00
Charles Lyding
7c2b846199 fix(@angular-devkit/build-angular): wait during file watching to improve multi-save rebuilds for esbuild builder
When using the experimental esbuild-based browser application builder in watch mode, the file watcher will now
wait 250ms from a reported file event before triggering a rebuild. The change allows the rebuild to better
capture groups of file changes. This can happen when using an IDE while editing multiple files and would otherwise
result in multiple rebuilds where a single rebuild would be ideal.
2022-10-31 10:10:06 -07:00
Angular Robot
7d5a816087 build: update dependency babel-loader to v9 2022-10-28 09:31:48 -07:00
Charles Lyding
2a6b585d18 fix(@angular-devkit/build-angular): correct escaping of target warning text in esbuild builder
The warning text note for the TypeScript target was incorrectly escaped within a template literal
which resulted in a badly formatted error message.
2022-10-28 09:31:27 -07:00
Angular Robot
503682766f build: update all non-major dependencies 2022-10-27 12:25:33 -07:00
Charles Lyding
e21ee326e0 fix(@angular-devkit/build-angular): ignore cache path when watching with esbuild builder
When using the experimental esbuild-based browser application builder in watch mode,
the base cache path defined within the `angular.json` file will now be ignored when
detecting file changes. While the builder currently does not persist cache to disk, it
may in the future and other builders may currently be run in parallel.
2022-10-26 08:57:48 -07:00
Charles Lyding
0fcc603ae7 fix(@angular-devkit/build-angular): issue dev-server support warning when using esbuild builder
The dev-server builder currently does not support the experimental esbuild-based browser application
builder and will use the Webpack-based builder instead. To better inform users of this behavior, a
warning is now issued upon executing the dev-server.
2022-10-26 08:57:18 -07:00
Charles Lyding
60086dbd01 perf(@angular-devkit/build-angular): avoid template diagnostics for declaration files in esbuild builder
The experimental esbuild-based browser application builder will now avoid trying to query the Angular
Compiler for template diagnostics when a TypeScript source file is a declaration file (`.d.ts`). This
avoids the overhead of the in-memory diagnostics caching logic as well as any Angular Compiler logic
to determine if the file has any template diagnostics.
2022-10-25 10:51:01 -07:00
Alan Agius
de8d846b98 docs: replace browserslist with AIO link
https://angular.io/guide/build#configuring-browser-compatibility will be updated to include additional information.
2022-10-24 15:12:42 -07:00
Charles Lyding
2b27679d9c refactor(@angular-devkit/build-angular): show more cumulative metrics for esbuild perf debug output
When the `NG_BUILD_DEBUG_PERF` environment variable is used to debug performance of the experimental
esbuild-based browser application builder, additional information will be logged for cumulative
profiling actions. This includes the count, minimum, maximum, and average.
2022-10-24 08:00:16 -04:00
Charles Lyding
1c87de6d8b perf(@angular-devkit/build-angular): avoid extra TypeScript emits with esbuild rebuilds
To further improve incremental rebuild performance of the experimental esbuild-based browser
application builder, the output of the TypeScript file loader within the Angular compiler plugin
are now cached in memory by the input file name and invalidated via the file watching events.
This allows an additional TypeScript emit including the associated transformations per input file
to be avoided if the file has not changed or has not been affected by other files within the
TypeScript program.
2022-10-24 08:00:16 -04:00
Alan Agius
b29ae2feda fix(@schematics/angular): add @angular/localize as type when localize package is installed
The `@angular/localize` entrypoint now exposes the global `$localize` method type.

See: https://github.com/angular/angular/pull/47763
2022-10-21 10:32:24 -04:00
Alan Agius
708011ea8e build: update all non-major dependencies 2022-10-21 10:24:39 -04:00
Angular Robot
30ce7435d6 build: update all non-major dependencies to v0.15.11 2022-10-17 10:33:42 +02:00
Alan Agius
c49f1eea62 fix(@angular-devkit/build-angular): resolve transitive dependencies in Sass when using Yarn PNP
Enhanced resolver is unable to resolve transitive dependencies in Sass when using Yarn PNP. The main reason for this is that Sass doesn't provide context on which file is requesting the module. See: sass/sass#3247.

As a workaround for this we store previously resolved paths and when a new request comes in we try to resolve this from the previously resolved files if we are unable to resolve the request from the workspace root.
2022-10-14 16:05:53 +02:00
Alan Agius
96551365e2 fix(@angular-devkit/build-angular): add @angular/platform-server as an optional peer dependency
`@angular/platform-server` is now an optional peer dep due to the recent changes in 1cd53d6be1/packages/angular_devkit/build_angular/src/builders/server/index.ts (L182)
2022-10-14 15:47:02 +02:00
Angular Robot
ef5b40f7e4 build: update all non-major dependencies 2022-10-14 10:01:11 +02:00
Angular Robot
c95bab80d0 build: update dependency cacache to v17 2022-10-14 10:00:42 +02:00
Charles Lyding
717bd03de6 fix(@angular-devkit/build-angular): account for package.json exports fields with CSS import statements
The `postcss-imports` package was previously used to support `@import` within CSS files. Unfortunately,
the package does not account for `package.json` exports fields. This prevents imports defined within that
field from working when used within a build.  The `css-loader` package does provide this functionality and
is now used to provide support for CSS `@import` instead of `postcss-imports`. This change does not affect
preprocessors that provide their own import behavior.
2022-10-14 09:36:08 +02:00
Alan Agius
5954d240fa fix(@angular-devkit/build-angular): only import karma when running karma builder
Karma is an optional peer dependency, but with the recent changes we broke this as we imported karma outside of the execution method, which made this package to be always imported even when the Karma builder was not invoked.
2022-10-13 15:25:20 +02:00