2709 Commits

Author SHA1 Message Date
Angular Robot
4164a09b28 build: update all non-major dependencies 2023-01-25 14:52:53 +00:00
Alan Agius
97907addfc fix(@angular-devkit/build-angular): update browserslist config to include last 2 Chrome versions
https://github.com/angular/angular/pull/48669 added support for the last 2 Chrome versions
2023-01-20 18:37:22 +00:00
Angular Robot
a9aa004db6 build: update all non-major dependencies 2023-01-19 22:14:08 +00:00
Charles Lyding
d19f260baa fix(@angular-devkit/build-angular): avoid undefined module path for Sass imports in esbuild
When using Sass with the experimental esbuild-based browser application builder, bare imports
without a path segment that were available via included paths but also happen to be a node module
could cause an exception. An example of such an import would be `@import "globals";`. The deep
import node module logic would previously attempt to join an undefined path segment to the resolved
path for the `globals` package which would raise a argument type exception. This case has now been
fixed by only joining if there is actually a path segment present such as `@import "globals/x"`.
With this fix in place, the node module case can then continue and if no stylesheet is found, the
include paths will then be searched.
2023-01-19 22:13:01 +00:00
Charles Lyding
7b9d99cb37 refactor(@angular-devkit/build-angular): use esbuild 0.17 incremental API in esbuild builder
Due to the update of the experimental esbuild-based browser application builder to use esbuild 0.17,
the watch mode has been changed to use the new incremental API. The previous API has been removed
from esbuild. The new API involves creating a build context object that can then be used to perform
rebuilds of the configured application bundler as needed. All watch mode usage has been updated to
use this new approach. An effort was made to minimize the amount of changes made to support this API
update and limit the changeset. However, further refactoring will be possible as additional capabilities
are added in the future.
esbuild API reference: https://esbuild.github.io/api/#rebuild
2023-01-18 17:13:09 +00:00
Charles Lyding
c3447e3640 fix(@angular-devkit/build-angular): prevent hanging initial build during exception with esbuild
When using the experimental esbuild-based browser application builder and an exception is thrown
during the initial build, the process may hang indefinitely due to the Sass worker pool not
shutting down fully. This does not happen for rebuilds after the initial.  To remedy this
situation, The initial build is now wrapped in a try block to ensure that a full shutdown
of the Sass worker pool occurs.
2023-01-17 17:30:10 +00:00
Charles Lyding
bbc1a4f0dc feat(@angular-devkit/build-angular): support CommonJS dependency checking in esbuild
When using the experimental esbuild-based browser application builder, input files
for the build will now be checked to determine if they are non-ESM modules. This
behavior is comparable to the existing behavior within the default Webpack-based browser.
Warnings will now be issued for any non-ESM modules (for example, CommonJS or UMD) when
script optimizations are enabled (typically production builds). ESM files can be tree-
shaken and otherwise optimized in ways that CommonJS files cannot which allows for
more optimized and smaller output bundle files.
If any allowed dependencies are provided via the `allowedCommonJsDependencies`
option, both the direct import and any deep imports of the dependency will be ignored
during the checks and no diagnostic will be generated for the dependency.
2023-01-13 12:48:08 +00:00
Charles Lyding
d05eb00161 refactor(@angular-devkit/build-angular): remove direct import of i18n worker code
The i18n inlining worker code was previously imported in several locations to allow
reuse of the options object used to configure the worker. To prevent the worker
code from being used outside of an actual worker, the options object definition is
now located in a separate file and imported in both the worker and any other files
that need to use the inlining options.
2023-01-13 08:29:12 +00:00
Alan Agius
871e687ac4 build: update eslint-plugin-import to 2.27.4 2023-01-12 12:25:12 +00:00
Alan Agius
b68467f8d0 fix(@angular-devkit/build-angular): update esbuild to 0.16.17
This release contains a fix for `SyntaxError: Unexpected token: punc (()`

Closes #24526
2023-01-12 12:24:28 +00:00
Alan Agius
ef39987e59 build: update Angular peer deps to support ^15.2.0-next.0 2023-01-12 12:24:11 +00:00
Charles Lyding
84d2d8b378 fix(@angular-devkit/build-angular): use relative css resource paths in esbuild JSON stats
When using the experimental esbuild-based browser application builder with the `--stats-json`
option, all referenced CSS resources will now use paths relative to the workspace root within
the output JSON file. Previously, the resource paths within the stats JSON file were absolute
and were inconsistent with the other JavaScript and CSS paths within the file. CSS resources
include files that have been referenced in a bundled stylesheet `url()` such as images or fonts.
2023-01-09 15:56:31 +00:00
Alan Agius
e9987cfdd6 fix(@angular-devkit/build-angular): provide an option to exclude specs in Karma builder
With this change we add an `exclude` option to the Karma builder to provide a way to exclude certain specs from the compilation.

This is useful, when having integration, e2e and unit tests with the same suffix.

Closes #24472
2023-01-09 15:55:41 +00:00
Charles Lyding
09af707438 feat(@angular-devkit/build-angular): implement node module license extraction for esbuild builder
When using the experimental esbuild-based browser application builder, the `--extract-licenses`
option will now generate an output licenses file when enabled. This option extracts license
information for each node module package included in the output files of the built code. This
includes JavaScript and CSS output files. The esbuild metafile information generated during the
bundling steps is used as the source of information regarding what input files where included and
where they are located. A path segment of `node_modules` is used to indicate that a file belongs
to a package and its license should be include in the output licenses file.

The package name and license field are extracted from the `package.json` file for the
package. If a license file (e.g., `LICENSE`) is present in the root of the package, it
will also be included in the output licenses file. Custom licenses as defined by the recommended
npm custom license text (`SEE LICENSE IN <filename>`) will also be extracted and included in the
output license file. For additional information regarding the license field in a `package.json`,
see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#license.
2023-01-09 14:43:20 +00:00
Charles Lyding
64b66280e2 refactor(@angular-devkit/build-angular): remove duplicate namespaces in esbuild metafile paths
Within the experimental esbuild-based browser application builder, the internal paths for angular
component stylesheets were being displayed in the esbuild metafile with a duplicate namespace prefix.
This had no functional difference to the build output but it did make the paths in the metafile
unnecessarily long and potentially confusing. The paths now only contain the prefix a single time.
This also has the benefit of reducing the length of the filter regular expressions for the stylesheet
plugins used for Angular component styles by not needing to match the namespace in the path in addition
to the namespace option.
2023-01-09 14:42:17 +00:00
Angular Robot
38ea09d3b3 build: update all non-major dependencies 2023-01-09 14:41:32 +00:00
Angular Robot
df5ca315a6 build: update all non-major dependencies 2023-01-06 15:04:14 +00:00
Charles Lyding
7f93735e98 build: use bazel to perform release builds
When performing a release via the dev-infra `ng-dev` tooling, the release
builds for the packages that will be published are now performed using bazel.
Prior to this, the release builds were performed using a custom build script
that programmatically invoked TypeScript APIs. The Bazel build and discovery
process for the releasable packages is performed by a script that is based on
the scripts from components and framework repositories. Several small modifications
were performed to match the behavior and structure of the cli repository:
* Use of `packages` as the source root in the bazel query
* Use of `pkg_npm` rule in the bazel query
* Partial transition to native Node.js `fs` APIs instead of `shelljs`
* Directory creation per package when copying output (supports multiple package scopes)
* Copying of archives (tgz) for each package

The snapshot and local build capabilities are not modified as part of this change
but will be merged in a followup as part of a larger transition to use bazel
throughout the package build process.
2023-01-05 03:21:58 +00:00
Kristiyan Kostadinov
ba895b1af6 build: update to TypeScript 4.9
Updates the project to TypeScript 4.9.
2023-01-03 16:46:36 +00:00
Alan Agius
67773bd66d refactor(@angular-devkit/build-angular): remove unneeded defaults from built-in karma config
Remove options that match the Karma defaults from the built-in karma config
2023-01-03 14:53:44 +00:00
Alan Agius
dd2b65943d feat(@schematics/angular): add configuration files generation schematic
This commits add a schematic to generate Karma and Browserlist files which since version 15 are no longer generated by default. This schematic should be used to generate these files when further customisation is needed.

Usage
```
ng generate config karma
ng generate config browserlist
```

Closes #24294
2023-01-03 14:53:44 +00:00
Charles Lyding
7c87ce47c6 fix(@angular-devkit/build-angular): ensure Sass load paths are resolved from workspace root
When using the esbuild-based browser application builder, the Sass compiler will attempt to
resolve any relative load paths from the current working directory. However, the load paths
from the `angular.json` file should always be relative to the location of the `angular.json`
which is considered the workspace root. While the current working directory is typically
also the workspace root, it is not required nor always the same. To resolve this potential
mismatch, the load paths are now resolved from the workspace root prior to being passed to
the Sass compiler.
2023-01-03 14:52:33 +00:00
Alan Agius
e91734ff89 fix(@angular-devkit/build-angular): format esbuild error messages to include more information
Prior to this change esbuild errors during the javascript optimization phase in the Webpack builder were not being formatting properly which caused meaningful information to be lost.

Closes #24457
2023-01-03 14:52:15 +00:00
aanchal
dd322b6240 test: removed empty methods 2023-01-03 14:51:42 +00:00
Charles Lyding
839d0cb57a feat(@angular-devkit/build-angular): implement stats-json option for esbuild builder
When using the experimental esbuild-based browser application builder, the `--stats-json`
option can now be used to create an esbuild metafile named `stats.json` in the output
directory of the application. The metafile contents will contain information about the
application JavaScript, global stylesheets, and the component stylesheets used by the
Angular compiler. While the `--stats-json` option controls the output of the file onto
the filesystem, the metafile data is internally always created to support the future
integration of the bundle budget and console build stat output capabilities.
The metafile format follows the structure of the esbuild metafile format. Information
regarding the file format can be found here: https://esbuild.github.io/api/#metafile
2023-01-03 14:50:09 +00:00
Angular Robot
a9c0982f3a build: update all non-major dependencies 2022-12-15 20:48:46 +00:00
Angular Robot
320d072aac build: update all non-major dependencies 2022-12-14 16:25:55 +00:00
Charles Lyding
20376649c5 fix(@angular-devkit/build-angular): transform async generator class methods for Zone.js support
When using the experimental esbuild-based browser application builder, async generator class
methods will now be transformed to a downlevel form based on promise objects. This transformation
is performed by babel and was previously (and still is) performed on async generator functions.
This transformation is necessary to ensure Zone.js can hook async code via the Promise objects.
Only async generator transformation is currently performed via babel as esbuild can handle all other
native async syntax that requires transformation for Zone.js support.
2022-12-14 15:02:25 +00:00
Charles Lyding
310144d324 fix(@angular-devkit/build-angular): only set ngDevMode when script optimizations are enabled
When using the experimental esbuild-based browser application builder, the `ngDevMode` global
runtime variable was unintentionally always being set to false due to a previous bug fix that stopped
the variable from being replaced with the value of true when script optimizations were disabled.
By doing so, the fix caused the imported compiler-cli `GLOBAL_DEFS_FOR_TERSER_WITH_AOT` constant
to take precedence which contains an `ngDevMode` value of false. To prevent this situation for
development builds where a non-false `ngDevMode` is helpful to surface potential runtime problems,
`GLOBAL_DEFS_FOR_TERSER_WITH_AOT` will no longer change the value of `ngDevMode`. This fix does not
have any effect on production builds since `ngDevMode` would have been set to false regardless.
2022-12-13 14:28:24 +00:00
Charles Lyding
216991b9d9 feat(@angular-devkit/build-angular): support inline component Sass styles with esbuild builder
When using the experimental esbuild-based browser application builder, the `inlineStyleLanguage`
option and the usage of inline Angular component styles that contain Sass are now supported. The
`inlineStyleLanguage` option values of `css`, `sass`, and `scss` can be used and will behave as
they would with the default Webpack-based builder. The less stylesheet preprocessor is not yet
supported in general with the esbuild-based builder. However, when support is added for less,
the `inlineStyleLanguage` option will also be able to be used with the `less` option value.
2022-12-13 14:28:05 +00:00
Angular Robot
5f718fdebd build: update all non-major dependencies 2022-12-12 18:46:05 +00:00
Alan Agius
8fd08491a8 fix(@angular-devkit/build-angular): display actionable error when a style does not exist in Karma builder
Prior to this change the the error was not displayed correctly due to compilation being undefined.

Closes #24416
2022-12-12 17:21:06 +00:00
Alan Agius
97373016cf fix(@angular-devkit/build-angular): downlevel class private methods when targeting Safari <=v15
This commits enables `@babel/plugin-proposal-private-methods` when targeting Safari <=v15 as this is needed to handle private class methods when using `@babel/plugin-proposal-class-properties`.

Closes #24411
2022-12-12 14:48:09 +00:00
Alan Agius
afe9feaa45 fix(@angular-devkit/build-angular): update locale setting snippet to use globalThis.
This commit changes how we set the `LOCALE_ID` when using the `localize` option

- We now include the locale setting snippet only in the main bundle.
- We use `globalThis` to set the the value globally and be accessible across module boundaries. This is important as in some causes such as when using MF `@angular/core` can be located in a bundles others than `main` and `vendor`.
2022-12-09 13:52:28 -08:00
Alan Agius
27b22b02dc fix(@angular-devkit/build-angular): include sources in generated
Sass source maps

This commits enables `sourceMapIncludeSources` when using the modern Sass API so that sources are included in generated
source map.

Closes #24394
2022-12-08 14:49:55 -08:00
Alan Agius
207358afb8 feat(@angular-devkit/schematics): add runSchematic and runExternalSchematic methods
These async methods are a replacement for the Observable based `runSchematicAsync` and `runExternalSchematicAsync` methods.

DEPRECATED:
The Observable based `SchematicTestRunner.runSchematicAsync` and `SchematicTestRunner.runExternalSchematicAsync` method have been deprecated in favor of the Promise based `SchematicTestRunner.runSchematic` and `SchematicTestRunner.runExternalSchematic`.
2022-12-08 14:49:43 -08:00
Angular Robot
3d885fbb21 build: update all non-major dependencies 2022-12-08 12:09:04 -08:00
Charles Lyding
7a063238b8 fix(@angular-devkit/build-angular): explicitly send options to JS transformer workers
When using the experimental esbuild-based browser application builder, the JavaScript
transformation workers will now only receive the explicit options expected. Previously,
additional Angular compiler plugin options could have been serialized and sent as well.
While these would be unused, there was no need to serialize/deserialize these option values.
2022-12-06 14:33:32 -08:00
Charles Lyding
97716969c2 fix(@angular-devkit/build-angular): default preserve symlinks to Node.js value for esbuild
When using the experimental esbuild-based browser application builder, the `preserveSymlinks`
option will now default to the value of the Node.js `--preserve-symlinks` argument. This removes
the need to manually specify the option in two places if executing the build manually with Node.js
or via the `NODE_OPTIONS` environment variable. This behavior mimics that of the default Webpack-based
builder.
2022-12-05 11:08:35 -08:00
Charles Lyding
cf2f30afc0 fix(@angular-devkit/build-angular): downlevel class fields with Safari <= v15 for esbuild
To provide a workaround for a Safari bug involving class fields and variable scoping,
the esbuild-based browser application builder will now downlevel class fields if Safari
(desktop or iOS) v15.x or earlier is within the target browsers for an application.
This is an esbuild variant of the fix for the Webpack-based builder. For more details
regarding the issue, please see: #24357
2022-12-02 18:39:12 +00:00
Charles Lyding
a0f9db8f2e refactor(@angular-devkit/build-angular): update browserslist conversion to latest esbuild browsers
The conversion of browserslist targets to esbuild targets has been updated to reflect additions
to esbuild. Additional browsers are now supported and the major/minor versions have been normalized.
The later of which ensures that `.0` major versions are not misinterpreted as ranges rather than
specific versions.
2022-12-02 18:39:12 +00:00
Dominic Elm
65f78be267 refactor(@angular-devkit/build-angular): convert into a function to give more control when the readable stream is initialized 2022-12-02 10:20:35 +00:00
Paul Gschwendtner
25eaaa24b5 fix(@angular-devkit/build-angular): downlevel class properties when targeting Safari <=v15
The Angular compiler is dependent on static fields being attached to
user-defined classes. e.g. `static ecmp = defineComponent`.

These static fields sometimes rely on variables from outside of the
class. e.g. the Angular compiler generates constants for content
projection that are then accessed in the static field initializer.

Surprisingly such access to these variables may break in Safari <=v15
when a page is loaded without devtools open. The bug (already solved in
v16 of Safari)- is very subtle, hard to re-reproduce but basically
variable scope tracking is broken. This bug is triggered by additional
parenthesis in the initializer expression. See:
https://bugs.webkit.org/show_bug.cgi?id=236843.

The TypeScript compiler may generate such additional parenthesis when
it tries to adjust the `this` context when invoking methods, such as for
defining animations in the `ecmp` definition.

More details can be found here:
https://github.com/angular/angular-cli/issues/24355#issuecomment-1333477033

To ensure Angular applications are not subject to this bug when
targeting Safari <=v15. v15 Safari, both for iOS and Mac is still part of
the default CLI browserslist with `last 2 Safari majors` (at time of
writing).

Note that it is important that the Babel plugin properly handles the
downleveling of static block-defined members. TypeScript will transform
static fields, like `static ecmp` into `static { this.ecmp = X }` when
`useDefineForClassFields = false` (which is the case for CLI apps). The
class properties plugin from Babel seems to handle this in an acceptable
way. Unlike actual static fields, Babel will not use helpers like
`defineProperty` for such extracted static blocks though. e.g.

See repro: https://gist.github.com/devversion/dec0dea26e348c509921bf62079b60be

```js
class Test {
  x = true;

  static b = true;
  static {
    this.a = true;
  }
}

// into

class X {
  constructor() {
    _defineProperty(this, "x", true);
  }
}
_defineProperty(X, "b", true);
X.a = true;
```

note that in practice TypeScript with `useDefineForClassFields = false`
will put non-static members into the constructor as normal assignments
regardless- so there would be no change by the Babel plugin.

Fixes #24355.
2022-12-02 09:05:29 +00:00
Charles Lyding
ef99a68b46 fix(@angular-devkit/build-angular): prevent optimization adding unsupported ECMASCript features
When optimization is enabled with the `@angular-devkit/build-angular:browser` builder, terser
is used as a second phase optimizer. The terser configuration previously set its `ecma` option
to `es2020` due to all officially supported browsers supporting the version. However, it is
possible to add browsers to the browserslist configuration that are not officially supported
that still may work but do not support es2020 syntax features. By setting the terser `ecma`
option to `es2015`, terser will not turn existing syntax into newer syntax features that might
be unsupported. Terser will also not downlevel any code based on this option.

Fixes #24347
2022-12-01 10:18:47 +00:00
Angular Robot
64c89439dc build: update all non-major dependencies 2022-11-30 14:19:37 +00:00
Angular Robot
80a7887883 build: update all non-major dependencies 2022-11-29 13:31:54 +00:00
Alan Agius
a07d701280 build: update all non-major dependencies
(cherry picked from commit 2dad0e7829325a69747fb702fa614bd73281ceb0)
2022-11-28 16:04:17 +00:00
Alan Agius
c9608f5ec9 Revert "fixup! test: run legacy-cli e2e tests via bazel"
This reverts commit 9e5777052d7436b879e3c8f64c123fd0f70a3c9a.
2022-11-28 15:25:48 +00:00
Jason Bedard
9e5777052d fixup! test: run legacy-cli e2e tests via bazel
fixup: add ChromeHeadlessNoSandbox browser to to karma builder
2022-11-28 13:39:15 +00:00
Juuso Valkeejärvi
012393d379 fix(@angular-devkit/build-angular): correctly set Sass quietDeps and verbose options
The logic to set these options was flipped which caused the warnings to
be displayed when verbose was disabled.
2022-11-28 13:17:05 +00:00