3659 Commits

Author SHA1 Message Date
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
Charles Lyding
11e0a51b17 build: minor cleanup of bazel build rules
BUILD files for each package have had outdated glob excludes removed.
Additionally, some src args have been reduced to a single file where possible.
The root bazel ignore file has also been expanded to include all node module
directories in each package. The ignore file does not appear to currently support
globs so each path has been individually specified.
2023-05-22 09:36:44 -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
Alan Agius
77f21c1ba1 build: update @types/node to 16.11.7
Node.js 14 is no longer supported.
2023-05-17 16:35:01 +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
Alan Agius
a70e7a42f1 refactor(@angular-devkit/core): update stringToFileBuffer and fileBufferToString to use TextDecoder and TextEncoder
`TextDecoder` and `TextEncoder` can now be used on Node.js
2023-05-10 15:33:35 +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
Alan Agius
22c1cb66c5 fix(@angular-devkit/schematics): do not generate an UpdateBuffer for created and overridden files
`UpdateBuffer` only supports UTF-8 encoded files, which causes schematics to emit corrupted binary like files such as images.

This commit also introduce an errors when the `UpdateRecorder` is used for non UTF-8 files.

Closes #25174
2023-05-10 11:20:29 +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
Angular Robot
67e940635c build: update all non-major dependencies 2023-05-04 20:26:09 +00:00
Doug Parker
d160856958 refactor: widen peer dependencies to ^16.0.0 || ^16.1.0-next.0 2023-05-03 19:38:47 +00:00
Alan Agius
2fabeabf7f fix(@angular-devkit/build-angular): JIT support for standalone applications
This commit fixes and issue were standalone applications would fail during runtime because the `@angular/compiler` is not available.

We now add the `@angular/compiler` as part of the bundle when JIT mode is enabled.
2023-04-28 18:00:36 +00:00
Charles Lyding
3dd584a21d refactor(@angular-devkit/build-angular): update esbuild builder option status messages
The status of the esbuild-based browser application builder has been changed to developer
preview. Warning messages for unsupported options are now updated to reflect this change.
2023-04-28 17:51:39 +00:00
Angular Robot
17112a38a0 build: update all non-major dependencies 2023-04-28 07:33:11 +00:00
Alan Agius
4a38e8ab35 refactor(@angular-devkit/build-angular): exclude @angular/platform-server/init from unsafe optimizations in esbuild
While currently esbuild is not use to bundle server bundles, it will in the future. This commit adds a check for the `@angular/platform-server/init` entry-point to be excluded from advanced optimizations.
2023-04-27 14:44:27 +00:00
Alan Agius
bf4229da22 fix(@angular-devkit/build-angular): always enable looseEnums build optimizer rule
With this change TypeScript enums are always processing in "loose" mode. Previously, this was only done for `@angular/` packages.
2023-04-27 14:44:27 +00:00
Alan Agius
24a6501ec6 refactor: replace node with process.execPath
This is ensure that the same node executable is used to spawn Jest
2023-04-27 12:52:38 +00:00
Alan Agius
3ec88270ba perf(@angular-devkit/build-angular): do not inline sourcemap when using vite dev-server
Vite inlines the source map as part of content (ba62be40b4/packages/vite/src/node/server/send.ts (L59-L63)) with no option to disable this behaviour. While this is improves performances when Vite is used without prebundling. When using prebundling this is causes an overhead as the response can grow drastically, in some cases over 50mb.
2023-04-27 12:26:35 +00:00
Alan Agius
621d0885b6 fix(@angular-devkit/build-angular): exclude @angular/platform-server/init from unsafe optimizations
`@angular/platform-server/init` entry-point is side-effectful and thus it's not safe to perform advanced optimizations.
2023-04-27 12:26:14 +00:00
Angular Robot
ae54da2990 build: update all non-major dependencies 2023-04-27 10:07:18 +00:00
Angular Robot
367ddabed0 build: update dependency rxjs to v7.8.1 2023-04-27 10:01:39 +00:00
Doug Parker
210b613334 refactor: configure Zone.js for Jest tests
This configures polyfills to set up the environment before executing Jest tests. We need to do three things:
1. Set the global `jest` symbol. Jest executing in ESM does not provide the `jest` global and users are expected to import from `@jest/globals` or `import.meta.jest`. Zone.js is not compatible with this yet, so we need to manually define the `jest` global for Zone to read it.
2. Run user polyfills, (typically including `zone.js` and `zone.js/testing`). Zone reads the `jest` global to recognize the environment it is in and patch the relevant functions to load fake async properly. Users can override this part if they are building a Zoneless application or have custom polyfills for other browser functionality.
3. Initalize `TestBed`. This configures the `TestBed` environment so users don't have to manually configure it for each test file.

Ordering is very important for these operations, which complicates the implementation somewhat. `zone.js/testing` does not include an import on `zone.js`, meaning there was no guarnatee the bundler would sort their executions in the correct order. Similarly, `zone.js` does not import anything from Jest, so it is not trivial to inject the `globalThis.jest = import.meta.jest;` line before Zone loads. Even setting polyfills to `[jestGlobal, 'zone.js, 'zone.js/testing', initTestBed]` doesn't work because code splitting rearranges the order of operations in an incompatible way. Instead, these are implemented as distinct entry points in `browser-esbuild` with Jest's `--setupFilesAfterEnv` option executing them in the correct order.

Ideally, we could drop the global initialization altogether once Zone.js knows to look for `import.meta.jest` in an ESM context. Also we might be able to reduce down to a single polyfills entry point if `zone.js/testing` had an import on `zone.js` to apply correct ordering.
2023-04-26 22:41:47 +00:00