415 Commits

Author SHA1 Message Date
Alan Agius
f5b2d7e031 refactor: remove no longer needed caniuse-lite dependency 2021-11-09 13:03:34 -05:00
Charles Lyding
d9e819313a fix(@angular-devkit/build-angular): remove potential race condition in i18n worker execution
There was previously the potential for two workers to complete quickly at the same time which could result in one of the results not being propagated to the remainder of the system. This situation has now been corrected by removing the worker execution at a later point in the process.

(cherry picked from commit 802b1b0378c1816dbfd8f4320b5d69e82f0c7aa6)
2021-11-02 16:58:32 +01:00
Alan Agius
5a2a2fc297 refactor(@angular-devkit/build-angular): unify webpack configurations
With this change we unify most of the webpack configuration into the common configuration. A number of lengthy functions and code portions have been moved into a seperate file to make the configuration easier to follow.
2021-10-28 18:04:57 +02:00
Alan Agius
9171fc087a fix(@angular-devkit/build-angular): update critters to version 0.0.12
This change brings in a security fix causes was causes by an outdated dependency. See https://github.com/GoogleChromeLabs/critters/pull/82 for more information.

Also, remote stylesheets are excluded from processing, were previously this caused build failures.

Closes #20794
2021-10-26 04:45:59 -05:00
Alan Agius
2764915724 test(@angular-devkit/build-angular): update tests to match critters 0.0.11 output 2021-10-21 03:25:33 -05:00
Alan Agius
f3c0c98fbd Revert "feat(@angular-devkit/build-angular): disable critical CSS inlining by default"
This reverts commit bf0709b14c1f0d47af77a64e586a5d4564b75766.
2021-10-21 03:24:36 -05:00
Charles Lyding
f44cb908c3 refactor(@angular-devkit/build-angular): eagerly remove used i18n temporary files
Temporary JavaScript application files that have been queued for i18n processing are now removed immediately after reading their content. This reduces the on-disk size of temporary files as well as reduces the needed disk access during the final asset copy phase of the i18n inlining process. Additional debug logging has also been added to the i18n inlining process which can be enabled via the `NG_DEBUG=1` environment variable.
2021-10-19 10:09:10 -04:00
Alan Agius
1dac761f56 fix(@angular-devkit/build-angular): generate unique webpack runtimes
Currently, using 2 Angular applications from the same workspace on the same page causes a conflict because both of the webpack runtime chunks naming are the same.

With this change we configure the runtime chunk name to be inferred from the project name. This also results in reducing unnecessary file reads which Webpack needs to do to infer the name from the workspace package.json.

For more information about this option see: https://webpack.js.org/configuration/output/#outputuniquename

Closes #21957
2021-10-19 09:30:07 -04:00
Alan Agius
9a3b63766a refactor(@angular-devkit/build-angular): remove redundant require.resolve for @angular/service-worker
This was mainly done prior to the introduction of optional peer dependencies.
2021-10-07 17:34:19 +02:00
Alan Agius
bf0709b14c feat(@angular-devkit/build-angular): disable critical CSS inlining by default
With this change we disable critical css inline by default. The main motivations are the following issues #20760 and #20864.

BREAKING CHANGE:

Inlining of critical CSS is no longer enable by default. Users already on Angular CLI version 12 and have not opted-out from using this feature are encouraged to opt-in using the browser builder `inlineCritical` option.

The motivation behind this change is that the package used to parse the CSS has a number of defects which can lead to unactionable error messages when updating to Angular 13 from versions priors to 12. Such errors can be seen in the following issue #20760.

```json
"configurations": {
  "production": {
    "optimization": {
      "styles": {
        "inlineCritical": true,
      }
    },
    ...
  }
```
2021-10-06 14:34:11 -05:00
Alan Agius
5904afd1de feat(@angular-devkit/build-angular): enable disk cache by default and provide configurable options
Persistent disk build cache is now enabled by default. A number of options have been added to allow fine tuning of the cache.

The options can be configuration in `cli.cache` section in the `angular.json` as shown below.

- `enabled`: Configure whether disk caching is enabled. Defaults to `true`
- `environment`: Configure in which environment disk cache is enabled. Valid values `ci`, `local` or `all`. Defaults to: `local`
- `path`: cache base path. Defaults to `.angular/cache`

DEPRECATED: `NG_BUILD_CACHE` environment variable option will be removed in the next major version. Configure `cli.cache` in the workspace configuration instead.

BREAKING CHANGE:  `NG_PERSISTENT_BUILD_CACHE` environment variable option no longer  have effect. Configure `cli.cache` in the workspace configuration instead.

```json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "cli": {
    "cache": {
      "enabled": true,
      "path": ".custom-cache-path",
      "environment": "all"
    }
  }
  ...
}
```
2021-10-06 08:02:22 -05:00
Alan Agius
e11209591a refactor(@angular-devkit/build-angular): use @angular/localize/tools entry-point 2021-10-05 11:38:20 -04:00
Paul Gschwendtner
f383f3201b fix(@angular-devkit/build-angular): ESM-interop loaded plugin creators of @angular/localize/tools not respected
This is a follow-up to fb210e5b747ce0351dd9ee7d482770b9cfa71133 which
added support for the ESM-variant of the `@angular/localize` package,
and also prepared for the `tools/` secondary entry-point we will expose
as of v13.

Unfortunately this change currently does not pass-through the ESM-loaded
plugin creators as the option (which is passed to the Babel plugin) is
incorrect. This was hidden due to a type cast. This commit fixes the
issue and also ensures TS would complain in the future if the option
names differ.
2021-09-30 06:57:01 -04:00
Charles Lyding
47bf88e10f refactor(@angular-devkit/build-angular): use module resolution to search for i18n locale data
Previously, the search for a locale's data when using i18n was performed by a series of file system accesses that searched through the `@angular/common` package. The search is now conducted via Node.js module resolution which has several advantages. The internal structure of the package is no longer assumed and allows the `@angular/common` package to change its internal implementation without affecting the locale data search. File extensions of the locale data files are also not hard-coded as only the name of the locale data is needed to perform a search. There are also less direct file system access calls and the search can leverage whatever internal caching Node.js performs during module resolution.
2021-09-28 04:58:10 -04:00
Charles Lyding
fb210e5b74 refactor(@angular-devkit/build-angular): support ESM @angular/localize usage
With the Angular CLI currently being a CommonJS package, this change uses a dynamic import to load `@angular/localize` which may be ESM. CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript will currently, unconditionally downlevel dynamic import into a require call. require calls cannot load ESM code and will result in a runtime error. To workaround this, a Function constructor is used to prevent TypeScript from changing the dynamic import. Once TypeScript provides support for keeping the dynamic import this workaround can be dropped and replaced with a standard dynamic import.
2021-09-27 06:45:24 -04:00
Charles Lyding
13cceab8e7 fix(@angular-devkit/build-angular): use URLs for absolute import paths with ESM
Absolute import paths, especially on Windows, must be `file://` URLs when using ESM. Otherwise, Windows drive letters (e.g., `C:`) would be interpreted as a protocol instead of a drive letter when performing the import.
2021-09-23 13:59:31 -04:00
Charles Lyding
9b207bddac refactor(@angular-devkit/build-angular): support ESM @angular/service-worker usage
With the Angular CLI currently being a CommonJS package, this change uses a dynamic import to load `@angular/service-worker/config` which may be ESM. CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript will currently, unconditionally downlevel dynamic import into a require call. require calls cannot load ESM code and will result in a runtime error. To workaround this, a Function constructor is used to prevent TypeScript from changing the dynamic import. Once TypeScript provides support for keeping the dynamic import this workaround can be dropped and replaced with a standard dynamic import.
2021-09-23 06:52:06 -04:00
Charles Lyding
77561e796a refactor(@angular-devkit/build-angular): support ESM @angular/compiler-cli linker usage
This is a followup PR for #21771 that addresses partial compilation linker usage.
With the Angular CLI currently being a CommonJS package, this change uses a dynamic import to load `@angular/compiler-cli/linker[/babel]` which may be ESM. CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript will currently, unconditionally downlevel dynamic import into a require call. require calls cannot load ESM code and will result in a runtime error. To workaround this, a Function constructor is used to prevent TypeScript from changing the dynamic import. Once TypeScript provides support for keeping the dynamic import this workaround can be dropped and replaced with a standard dynamic import.
2021-09-23 06:52:06 -04:00
Charles Lyding
3e6324f7c7 refactor(@angular-devkit/build-angular): support an ESM-only @angular/compiler-cli package
This uses a dynamic import to load `@angular/compiler-cli` which may be ESM. CommonJS code can load ESM code via a dynamic import. Unfortunately, TypeScript will currently, unconditionally downlevel dynamic import into a require call. require calls cannot load ESM code and will result in a runtime error. To workaround this, a Function constructor is used to prevent TypeScript from changing the dynamic import. Once TypeScript provides support for keeping the dynamic import this workaround can be dropped and replaced with a standard dynamic import.
2021-09-20 10:31:59 +02:00
Charles Lyding
b87771061c refactor(@angular-devkit/build-angular): support async partial Webpack configuration generators
Partial Webpack configuration generators are used to create the various aspects of the final Webpack configuration for build, testing, and serving. They previously could only be synchronous but may need to perform asynchronous actions to setup the Webpack configuration in the future. This is particularly relevant as the CLI transitions from CommonJS to ESM wherein synchronous require calls need to be replaced with asynchronous dynamic imports. For dynamic imports to be successfully used the configuration generators need to support asynchronous operations.
2021-09-20 10:31:59 +02:00
Charles Lyding
19eb5cb425 refactor(@angular-devkit/build-angular): use type imports for @angular/compiler-cli peer dependency
The `@angular/compiler-cli` is used as a peer dependency and has the potential to not be present. As a result static imports should only be used for types and value imports should be dynamic so that they can be guarded in the event of package absence. There are still several instances of static imports for values but these will be corrected in follow-ups.
2021-09-20 10:31:59 +02:00
Alan Agius
df8f909d80 fix(@angular-devkit/build-angular): handle FORCE_COLOR when stdout is not instance of WriteStream
In some cases, custom implementation of stdout, don't extend `WriteStream` which causes colors not to be included in the output.

Closes #21732
2021-09-14 09:00:24 +01:00
Alan Agius
76d6d8826f fix(@angular-devkit/build-angular): set browserslist defaults
By default, browserslist defaults are too inclusive: 83764ea81f/index.js (L516-L522)

We change the default query to browsers that Angular support: https://angular.io/guide/browser-support
2021-08-27 15:57:57 +02:00
Charles Lyding
51f89d633f test: enable no-useless-escape lint rule
The `no-useless-escape` eslint rule has now been enabled which removes unneeded characters and complexity from string literals and regular expressions. All files that were in violation of this rule have also been corrected.
2021-08-24 10:51:14 +01:00
Charles Lyding
c4baba4459 refactor(@angular-devkit/build-angular): reduce repeat TypeScript configuration loading
An application's TypeScript configuration was previously being loaded multiple times in several different aspects of the build setup process. These aspects need to access specific compiler options relevant to that particular area of the setup. However, loading the configuration can be expensive due to the process also calculating the root files for the TypeScript compilation which can result in a large amount of file access. To improve the setup performance, the number of times the TypeScript configuration will be loaded has now been reduced with further reductions possible with additional refactorings.
2021-08-09 14:15:13 +02:00
Alan Agius
f53bf9dc21 feat(@angular-devkit/build-angular): add type=module to all scripts tags
With this change we add `type=module` to all script tags. This is now possible since IE is no longer supported.

More information about modules can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
2021-08-05 08:34:13 +02:00
Charles Lyding
0afdff028c refactor(@angular-devkit/build-angular): move all builders into a builders subdirectory
All Angular builders are now located within one subdirectory of the `src` directory. This organization provides better discovery of the builders and will allow builder specific code to be stored in a single area.
2021-08-05 06:49:55 +02:00
Charles Lyding
f0987ee088 refactor(@angular-devkit/build-angular): remove unused rxjs version discovery
In the Angular version check, the rxjs version was acquired by resolving and reading the rxjs package's package.json file. However, the rxjs version checks were removed in a previous major.
2021-08-05 06:48:55 +02:00
Charles Lyding
a2bc175dbf refactor(@angular-devkit/build-angular): remove Webpack loader resolve custom setting
The Webpack configuration setup previously walked up the directory structure to find all `node_modules` directories and then pass this list to Webpack's `resolverLoader.modules` option. This was previously done to ensure that hoisted packages were properly resolved. However, all loader paths are now fully resolved prior to being added to the Webpack configuration. Since loader paths will now be absolute, Webpack no longer needs to resolve them which makes the resolve settings no longer necessary.
2021-08-05 06:48:55 +02:00
Charles Lyding
734d61df3f refactor(@angular-devkit/build-angular): remove empty.js Webpack alias file
Webpack 5 supports setting a module's alias to `false` to signify that a module should be ignored. This option removes the need for the `empty.js` file as an alias option value.
2021-08-05 06:48:55 +02:00
Charles Lyding
28f302855f refactor(@angular-devkit/build-angular): remove Node.js 10 copyfile workaround
The workaround code was gated on the presence of Node.js 10 but the CLI no longer supports Node.js 10 and will execute with an error if attempted. As a result, the workaround code would never be executed.
2021-08-05 06:48:55 +02:00
Alan Agius
20e48a33c1 feat(@angular-devkit/build-angular): remove deprecated options
BREAKING CHANGE:

With this change we removed several deprecated builder options
- `extractCss` has been removed from the browser builder. CSS is now always extracted.
- `servePathDefaultWarning` and `hmrWarning` have been removed from the dev-server builder. These options had no effect.
2021-08-03 15:07:04 +01:00
Charles Lyding
7576136b2f feat(@angular-devkit/build-angular): remove automatic inclusion of ES5 browser polyfills
BREAKING CHANGE:
The automatic inclusion of Angular-required ES2015 polyfills to support ES5 browsers has been removed. Previously when targetting ES5 within the application's TypeScript configuration or listing an ES5 requiring browser in the browserslist file, Angular-required polyfills were included in the built application. However, with Angular no longer supporting IE11, there are now no browsers officially supported by Angular that would require these polyfills. As a result, the automatic inclusion of these ES2015 polyfills has been removed. Any polyfills manually added to an application's code are not affected by this change.
2021-08-03 11:07:16 +01:00
Charles Lyding
701214d174 feat(@angular-devkit/build-angular): remove differential loading support
BREAKING CHANGE:
Differential loading support has been removed. With Angular no longer supporting IE11, there are now no browsers officially supported by Angular that require ES5 code. As a result, differential loading's functionality for creating and conditionally loading ES5 and ES2015+ variants of an application is no longer required.
2021-08-02 16:59:48 +01:00
Alan Agius
e82eef924e refactor(@angular-devkit/build-angular): remove WOFF handling from inline-fonts processor
BREAKING CHANGE:

We remove inlining of Google fonts in WOFF format since IE 11 is no longer supported. Other supported browsers use WOFF2.
2021-07-30 14:27:07 +01:00
Alan Agius
c1efaa17fe fix(@angular-devkit/build-angular): calculate valid Angular versions from peerDependencies
With this change we update the `assertCompatibleAngularVersion` logic to use `peerDependencies` on `@angular/compiler-cli` listed in the `package.json` to determine if the installed Angular version is supported or not.

This is a fix for:
https://github.com/angular/angular-cli/pull/21449
https://circleci.com/gh/angular/angular-cli/259835?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link
2021-07-30 12:42:10 +01:00
Alan Agius
2ac8e9c0e1 fix(@angular-devkit/build-angular): display incompatibility errors
The logger API writes logs in an async fasion which previously caused messages not to be printed in the terminal when `process.exit` was invoked.

Closes #21322
2021-07-12 16:40:35 +01:00
Charles Lyding
3c2fb5c9c1 refactor(@angular-devkit/build-angular): avoid loading Webpack for differential loading sourcemaps
The `@ampproject/remapping` package is now used for source map processing instead of Webpack for differential loading and i18n processing. This dependency is already used within the recently added JavaScript optimizer refactoring and reduces the amount of code that needs to be loaded into each worker to support differential loading sourcemaps.
2021-07-02 11:54:24 -04:00
Alan Agius
18cfa04317 feat(@angular-devkit/build-angular): add support to inline Adobe Fonts
With this change we add support to inline external Adobe fonts into the index html, we also add a `preconnect` hint which helps improve page load speed.

Closes #21186
2021-06-28 20:22:29 +02:00
Alan Agius
9a751f0f81 fix(@angular-devkit/build-angular): handle ENOENT and ENOTDIR errors when deleting outputs
Closes #21202
2021-06-28 17:15:19 +02:00
Charles Lyding
fd4ae0fb16 refactor(@angular-devkit/build-angular): lazy load Webpack in differential loading processor
Webpack is a large dependency with a large dependency graph. By only loading Webpack when needed in the differential loading and i18n processors, initial startup time can be improved and memory usage can be reduced.
2021-06-28 14:42:12 +02:00
Charles Lyding
e49079d971 refactor(@angular-devkit/build-angular): remove jest-worker direct dependency
The worker pool for differential loading and i18n processing is now managed by the `piscina` dependency. This dependency is already used within the recently added JavaScript optimizer refactoring and reduces both the number of direct dependencies and amount of code to setup the worker pools.
2021-06-28 14:42:12 +02:00
Charles Lyding
b3d7080147 build: enable esModuleInterop TypeScript option
The `esModuleInterop` option is recommended to be enable by TypeScript and corrects several assumptions TypeScript would otherwise make when importing CommonJS files.
This option change helps ensure compatibility as packages move towards ESM.
Reference: https://www.typescriptlang.org/tsconfig#esModuleInterop
2021-06-13 11:45:55 -04:00
Alan Agius
f90a8324b4 perf(@angular-devkit/build-angular): enable opt-in usage of file system cache
With this change we enable Webpack's filesystem cache, this important because `terser-webpack-plugin`, `css-minimizer-webpack-plugin` and `copy-webpack-plugin` all use Webpacks' caching API to avoid additional processing during the 2nd cold build.

This changes causes `node_modules` to be treated as immutable. Webpack will avoid hashing and timestamping them, assume the version is unique and will use it as a snapshot.

To opt-in using the experimental persistent build cache use the`NG_PERSISTENT_BUILD_CACHE` environment variable.

```
NG_PERSISTENT_BUILD_CACHE=1 ng serve
```
2021-06-11 12:11:49 -04:00
Alan Agius
bd82967523 fix(@angular-devkit/build-angular): show progress during re-builds
With the recent changes in https://github.com/angular/angular-cli/pull/20960 we moved the spinner to be started outside of the progress callback, this causes a side-effect that after `succeed` is called the spinner will stop reporting progress unless it is started again.
2021-06-04 17:55:41 +02:00
Alan Agius
c0106f6e3a refactor(@angular-devkit/build-angular): remove usage of rimraf package
Use Node.JS `rmdirSync` instead.
2021-06-04 15:37:10 +02:00
Renovate Bot
6e2c292365 build: update dependency jest-worker to v27 2021-05-26 11:26:07 -04:00
George Kalpakas
d1953bf1aa fix(@angular-devkit/build-angular): correctly generate ServiceWorker config on Windows
Since #20518, the generation of the ServiceWorker configuration has been
broken on Windows. The reason is the use of `path.posix.*` methods on
non-POSIX paths, resulting in broken paths. I.e. we ended up with
something like the following:

```js
path.posix.relative('C:\\foo', 'C:\\foo\\bar/baz');
// Expected result: `bar/baz`
// Actual result:   `../C:\\foo\\bar/baz`
```

This caused the config generator to fail to find any files and thus fail
to populate the config with cacheable assets.

This commit fixes this by using platform-specific `path.*` methods for
path manipulation and manually normalizing the path separators before
returning the results.

Fixes #20894
2021-05-24 09:28:55 -04:00
Alan Agius
4367c3a562 fix(@angular-devkit/build-angular): add NG_BUILD_MAX_WORKERS settimgs to control maximum number of workers 2021-05-14 08:29:35 +02:00
Alan Agius
e992c9a70b build: update files to be fix eslint header/header failures 2021-05-04 09:59:40 -04:00