117 Commits

Author SHA1 Message Date
Charles Lyding
5bf7022c47 fix(@angular-devkit/build-angular): remove support for Node.js v16
BREAKING CHANGE: Node.js v16 support has been removed

Node.js v16 is planned to be End-of-Life on 2023-09-11. Angular will stop supporting Node.js v16 in Angular v17.
For Node.js release schedule details, please see: https://github.com/nodejs/release#release-schedule
2023-08-14 10:57:54 +02:00
Charles Lyding
96ff17b4d1 ci: reduce bazel test shards for browser builder test
Reduce the number of test shards for the browser builder from 50 to 10.
50 is more than needed and can cause excessive resource usage.
2023-08-03 10:13:24 -04:00
Alan Agius
cb165a75dc feat(@angular-devkit/build-angular): add pre-rendering (SSG) and App-shell support generation to application builder
This commit introduces experimental support to pre-render (SSG) and app-shell generation to the new application builder.

- `appShell`: option which can have a value of `true` or `false` has been added to support generating an app-shell.
- `prerender`: option which can have a value of `true`, `false` or an object with the below listed properties can be used to static render pages;
  - `routes`: Array of routes to render.
  - `discoverRoutes`: Whether the builder should statically discover routes.
  - `routesFile`: The path to a file containing routes separated by newlines.
2023-07-07 11:15:09 -07:00
Alan Agius
c05c83be7c feat(@angular-devkit/build-angular): add initial application builder implementation
This commits add the initial application builder schema and build configuration and refactors several files.
2023-06-23 15:36:06 -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
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
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
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
Doug Parker
7fe6570c27 refactor: add experimental jest builder
For now this just runs ESBuild-er to build test code, Jest is not actually invoked yet.

This uses `glob` to find test files matching the given pattern. I went out of my way to limit `glob` functionality as much as possible in case we change the implementation later.
2023-04-26 22:41:47 +00:00
Charles Lyding
26c67f92a8 fix(@angular-devkit/build-angular): ensure all build resources are served in esbuild dev server
Previously when using the esbuild-based browser application builder with the new dev server,
resource files referenced via stylesheets may not have been served by the development server.
The development server has now been adjusted to properly prioritize and serve files that were
generated during the build process.
Global stylesheets are also currently considered resource files as well to workaround issues
with development sourcemaps within the development server itself. Global stylesheets are already
fully processed by the build system prior to being passed to the development server.
2023-04-12 17:35:11 +00:00
Charles Lyding
e4883b0ee1 feat(@angular-devkit/build-angular): support SSL options with esbuild development server
When using the esbuild-based browser application builder and its newly supported development
server, the SSL related `dev-server` builder options can now be used. These include the existing
`ssl`, `sslCert`, and `sslKey` options. Additionally, if no certificate and key are provided
the `@vitejs/plugin-basic-ssl` plugin will be used to provide an auto-generated one.
2023-04-05 16:07:33 +00:00
Charles Lyding
4822b3ba55 fix(@angular-devkit/build-angular): keep esbuild server active until builder fully stops
Use the now working builder teardown functionality to ensure that the development server
is properly closed when the builder is stopped.
2023-04-05 09:25:37 +00:00
Charles Lyding
8c550302cc feat(@angular-devkit/build-angular): initial development server for esbuild-based builder
When using the experimental esbuild-based browser application builder, the preexisting `dev-server` builder
can now be used to execute the `ng serve` command with an esbuild bundled application. The `dev-server` builder
provides an alternate development server that will execute the `browser-esbuild` builder to build the application
and then serve the output files within a development server with live reload capabilities.
This is an initial integration of the development server. It is not yet fully optimized and all features
may not yet be supported. SSL, in particular, does not yet work.

If already using the esbuild-based builder, no additional changes to the Angular configuration are required.
The `dev-server` builder will automatically detect the application builder and use the relevent development
server implementation. As the esbuild-based browser application builders is currently experimental, using
the development server in this mode is also considered experimental.
2023-04-04 08:22:36 +00:00
Alan Agius
d9fed6a517 build: update parse5-html-rewriting-stream to version 7
This fixes an issue were the HTML is truncated if it's 128Kb or greater.

Closes #24707
2023-02-14 15:23:09 +00:00
Charles Lyding
421417a36b fix(@angular-devkit/build-angular): avoid CommonJS warning for zone.js in esbuild
The `zone.js` package is currently built into a module structure form that resembles
UMD-like output. This causes the CommonJS checker within the experimental esbuild-based
browser application builder to issue a warning for `zone.js` usage. Until the packaging
of `zone.js` is updated to become fully ESM, the `zone.js` package is automatically allowed
when performing the CommonJS module check.
2023-02-13 14:14:41 +00:00
Charles Lyding
8356240dda fix(@angular-devkit/build-angular): use babel default export helper in build optimizer
Within the build optimizer's static member optimization pass, a class that is directly
default exported must be split into two statements: the class declaration and the
default export. This is because the pass can wrap classes in a pure annotated IIFE which
results in a variable declaration replacement and variable declarations can not be directly
default exported. Previously, the pass did this splitting manually but this was causing
later babel plugins to fail. In addition to updating the AST in this case, scoping information
also needed to be updated. To support this, a babel helper package is now used that handles
the details of the statement split operation.
2023-02-10 20:16:20 +00:00
Charles Lyding
01b3bcf898 feat(@angular-devkit/build-angular): add Less stylesheet support to experimental esbuild-based builder
When using the experimental esbuild-based browser application builder, stylesheets written in the Less
stylesheet language can now be used throughout an application. The support allows Less stylesheets to
be used in all locations where CSS and/or Sass can be used. This includes global stylesheets and both
inline and external component styles. When using inline component styles, the `inlineLanguageStyle`
build option must be set to `less`.
Currently, import resolution within a Less stylesheet is limited to default Less behavior which does not
include full node package resolution. Full resolution behavior will be added in a future change.
2023-02-08 19:10:30 +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
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
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
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
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
3d253e3b4a test: remove node16-broken from app-shell unit test
This is no longer the case and thus this test can be enabled.
2022-10-12 15:32:13 +02:00
Charles Lyding
3d94ca21bb feat(@angular-devkit/build-angular): add initial watch support to esbuild-based builder
The experimental esbuild-based browser application builder now contains initial support for
watching input files and rebuilding the application via the `--watch` option. This initial
implemention is not yet optimized for incremental rebuilds and will perform a full rebuild
upon detection of a change. Incremental rebuild support will be added in followup changes
and will significantly improve the rebuild speed.
The `chokidar` npm package is used to perform the file watching which allows for native file-
system event based watching. Polling is also support via the `--poll` option for environments
that require it.
2022-10-03 10:42:08 -04:00
Alan Agius
4ead45caba feat(@angular-devkit/build-angular): add ng-server-context when using app-shell builder
With this change we configure the app-shell builder to set the `ɵSERVER_CONTEXT` private provider.
2022-09-23 14:46:59 -04:00
Alan Agius
2ba44a433c refactor(@angular-devkit/build-angular): remove support for Stylus
The usage of Stylus in the CLI is minimal and this package never reached version 1.

BREAKING CHANGE:

Deprecated support for Stylus has been removed. The Stylus package has never reached a stable version and its usage in the Angular CLI is minimal. It's recommended to migrate to another CSS preprocessor that the Angular CLI supports.
2022-09-16 11:39:19 -07:00
Alan Agius
fdc315d335 test(@angular-devkit/build-angular): rewrite app-shell unit test into e2e
This particular unit tests was really an e2e test.
2022-09-15 08:26:11 -07:00
Jason Bedard
4de9045de8 test: unit test multiple node versions in separate jobs 2022-09-14 10:43:17 -07:00
Charles Lyding
b2add316e7 build: remove unneeded BUILD file licenses rule comments 2022-09-13 10:33:49 -07:00
Alan Agius
98bde526b4 refactor(@angular-devkit/build-angular): remove postcss-preset-env
This change removes the usage of `postcss-preset-env` as this is no longer needed since Angular no longer supports browsers that require polyfills for CSS stage 3 features https://preset-env.cssdb.org/features/#stage-3.

We replace this and use autoprefixer directly which is still needed.

```
npx autoprefixer --info
Browsers:
  Chrome: 105
  Edge: 105, 104
  Firefox: 104, 102, 91
  iOS Safari: 15.6, 15.5, 15.4, 15.2-15.3, 15.0-15.1, 14.5-14.8, 14.0-14.4
  Safari: 15.6, 15.5, 15.4, 15.2-15.3, 15.1, 15, 14.1, 14

These browsers account for 20.38% of all users globally

At-Rules:
  @resolution: webkit

Selectors:
  ::backdrop: webkit
  ::file-selector-button: webkit
  :autofill: webkit
  :fullscreen: webkit

Properties:
  appearance: webkit
  backdrop-filter: webkit
  backface-visibility: webkit
  background-clip: webkit
  box-decoration-break: webkit
  color-adjust: webkit, moz
  hyphens: webkit
  mask-border-outset: webkit
  mask-border-repeat: webkit
  mask-border-slice: webkit
  mask-border-source: webkit
  mask-border-width: webkit
  mask-border: webkit
  mask-clip: webkit
  mask-composite: webkit
  mask-image: webkit
  mask-origin: webkit
  mask-position: webkit
  mask-repeat: webkit
  mask-size: webkit
  mask: webkit
  print-color-adjust: webkit, moz
  text-decoration-color: webkit
  text-decoration-line: webkit
  text-decoration-skip-ink: webkit
  text-decoration-skip: webkit
  text-decoration-style: webkit
  text-decoration: webkit
  text-size-adjust: webkit
  user-select: webkit

Values:
  cross-fade: webkit
  element: moz
  fill-available: webkit
  fill: webkit
  fit-content: moz
  image-set: webkit
  isolate: webkit
  stretch: webkit, moz
```
2022-09-08 18:50:47 +02:00
Charles Lyding
e402c2358c build: adjust BUILD file external comment markers
Improvements to the syncing process allow for reduced usage of the comment markers.
2022-08-31 08:37:19 -04:00
Charles Lyding
504e9678ed Revert "test: enable rbe on all unit tests"
This reverts commit 1193886df5e8110de20ba534e2b4572da72b5e4a.
2022-08-29 13:58:19 -04:00
Jason Bedard
1193886df5 test: enable rbe on all unit tests 2022-08-29 08:19:46 -04:00
Jason Bedard
db5c1fc13c test: run tests on multiple node versions 2022-08-03 10:33:46 -07:00
Alan Agius
173823d772 build: remove dependency on font-awesome
This dependency is only used to valid that node packages are resolved correctly.

With this change we mock the structure of font-awesome to avoid having to install it.
2022-08-03 09:20:29 -07:00
Paul Gschwendtner
087ab46ca9 build: update dev-infra packages and account for build-tooling split from ng-dev
The dev-infra build tooling is now decoupled from `ng-dev`. This will
make it easier to update `ng-dev` without necessarily needing to upgrade
the whole build system, Bazel etc. This is useful when e.g. new release
tool features have been added and should also be ported to active LTS
branches.
2022-07-27 12:35:15 +02:00
Alan Agius
a7709b718c feat(@angular-devkit/build-angular): add externalDependencies to the esbuild browser builder
This commit add a new `externalDependencies` option to the experimental browser builder.

Dependencies listed in this option will not be included in the final bundle, instead the user would need to provide them at runtime using import maps or another method.

Closes #23322
2022-06-21 12:21:53 -07:00
Alan Agius
0d50661fe6 build: add browser-esbuild test infra
This commit adds browser-esbuild infra.
2022-06-21 12:21:53 -07:00
Charles Lyding
0e4e490448 build(@angular-devkit/build-angular): add missing @babel/generator dep to BUILD file 2022-05-04 10:13:18 -07:00
Alan Agius
af8dd62b74 refactor(@angular-devkit/build-angular): remove esbuild-check workaround
This check is no longer needed as of `0.14.29` as now esbuild correctly propagates errors.

See: https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#01429
2022-03-30 17:17:15 +02:00
Alan Agius
cea83b2289 build: update build_angular_test_lib to include all non builders spec files 2022-03-24 14:41:26 +01:00
Charles Lyding
966d25b55e fix(@angular-devkit/build-angular): remove unneeded JIT reflect metadata polyfill
Since Angular 8, the CLI has transformed decorator metadata to a form that can be used by the Angular dependency injector without the TDZ limitations of Typescript's decorator metadata emit feature.
As a result, a JIT application compiled with the CLI no longer requires the reflect metadata polyfill that was provided by `core-js`.
This polyfill was also the last remaining usage of the `core-js` package within `@angular-devkit/build-angular` which allows the `core-js` package to also be removed.

Refs: https://github.com/angular/angular-cli/pull/14473 & https://github.com/angular/angular/pull/37382

BREAKING CHANGE: Reflect metadata polyfill is no longer automatically provided in JIT mode
Reflect metadata support is not required by Angular in JIT applications compiled by the CLI.
Applications built in AOT mode did not and will continue to not provide the polyfill.
For the majority of applications, the reflect metadata polyfill removal should have no effect.
However, if an application uses JIT mode and also uses the previously polyfilled reflect metadata JavaScript APIs, the polyfill will need to be manually added to the application after updating.
To replicate the previous behavior, the `core-js` package should be manually installed and the `import 'core-js/proposals/reflect-metadata';` statement should be added to the application's `polyfills.ts` file.
2022-03-23 12:58:55 -07:00
Derek Cormier
94f7ed3b38 build: add missing dependency for tar/repo substitution 2022-02-01 17:17:42 -08:00
Alan Agius
0a1cd584d8 refactor(@angular-devkit/build-angular): remove deprecated showCircularDependencies browser and server builder option
BREAKING CHANGE:

The deprecated `showCircularDependencies` browser and server builder option has been removed. The recommended method to detect circular dependencies in project code is to use either a lint rule or other external tools.
2022-01-31 11:34:58 -08:00
Alan Agius
2b789b3ad0 refactor: remove @types/webpack-dev-server
This package is no longer needed since `webpack-dev-server` now has it's own typings.
2022-01-10 11:32:40 -08:00
Derek Cormier
4b5c52b0d8 build: perform package.json substitutions in bazel build 2022-01-10 10:25:49 -08:00
Alan Agius
e15aee65b5 build: refactor code to use types from sass and copy-webpack-plugin instead of @types
These packages now ship their own type decleration files.
2021-12-14 20:20:59 +01:00
Derek Cormier
31801c1a1a build: reproduce original package structure using bazel 2021-12-10 11:06:41 +01:00
Alan Agius
3c681b68d7 feat(@angular-devkit/build-angular): set dir attribute when using localization
We add the `dir` (direction) HTML attribute when using localization.

Closes #16047
2021-11-23 08:31:25 +01:00
Charles Lyding
6d0f99a2de feat(@angular-devkit/build-angular): support JSON comments in dev-server proxy configuration file
The `proxyConfig` option for the `dev-server` builder now supports JSON files containing comments and trailing commas.
Several additional tests regarding the use of ESM and CommonJS JavaScript configuration files were also added to reduce the likelihood of future regressions.

Closes: #21862
2021-11-16 10:50:39 +00:00