75 Commits

Author SHA1 Message Date
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
Alan Agius
f5b2d7e031 refactor: remove no longer needed caniuse-lite dependency 2021-11-09 13:03:34 -05:00
Charles Lyding
b6fa4adc0d build: add all used babel plugins to bazel BUILD file 2021-11-01 18:44:03 +01:00
Alan Agius
0c44ab3058 fix(@angular-devkit/build-angular): improve sourcemaps fidelity when code coverage is enabled
With this change we replace `@jsdevtools/coverage-istanbul-loader` webpack loader with [`babel-plugin-istanbul`](https://github.com/istanbuljs/babel-plugin-istanbul) which is an official Babel plugin by the istanbuljs team.

Previously, when code coverage was enabled we had multiple Babel runs on the same file. This is because istanbuljs' `instrumentSync` and `instrument` APIs which are used by the Webpack plugin invokes Babel directly 66bc39b3c7/packages/istanbul-lib-instrument/src/instrumenter.js (L98)

By using the babel plugin directly, we avoid this which also improves the sourcemaps correctness and test performance.

Closes #22010
2021-10-27 11:17:17 -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
Charles Lyding
0d76bf04bc fix(@angular-devkit/build-angular): support WASM-based esbuild optimizer fallback
In the event that the Angular CLI is executed on a platform that does not yet have native support for esbuild, the WASM-based variant of esbuild will now be used. If the first attempt to optimize a file fails to execute the native variant of esbuild, future executions will instead use the WASM-based variant instead which will execute regardless of the native platform. The WASM-based variant, unfortunately, can be significantly slower than the native version (some cases can be several times slower). For install time concerns regarding the esbuild post-install step, esbuild is now listed as an optional dependency which will allow the post-install step to fail but allow the full npm install to pass. This install scenario should only occur in the event that the esbuild native binary cannot be installed or is otherwise unavailable.
2021-09-22 16:09:57 +02:00
Charles Lyding
a7de97e485 build: add Bazel ts_library rule package_name properties to all packages
rules_nodejs 4 requires that a package_name property be specified within a ts_library rule for the output to be linked into the package repository. Failing to add the property can cause test failures due to unresolved packages.
2021-08-26 07:30:44 +02:00
Charles Lyding
8e82263c5e perf(@angular-devkit/build-angular): use esbuild/terser combination to optimize global scripts
`esbuild` and `terser` are now used to optimize global scripts in addition to the previous performance enhancement of optimizing application bundles. This change removes the need for the `terser-webpack-plugin` as a direct dependency and provides further production build time improvements for applications which use global scripts (`scripts` option in the `angular.json` file).
Since `esbuild` does not support optimizing a script with ES2015+ syntax when targetting ES5, the JavaScript optimizer will fallback to only using terser in the event that such a situation occurs. This will only happen if ES5 is the output target for an application and a global script contains ES2015+ syntax. In that case, the global script is technically already invalid for the target environment and may fail at runtime but this is and has been considered a configuration issue. Global scripts must be compatible with the target environment/browsers.
2021-08-11 09:15:49 +02:00
Alan Agius
cb7d156c23 perf(@angular-devkit/build-angular): use esbuild as a CSS optimizer for global styles
Esbuild now support CSS sourcemaps which now makes it possible to be used to optimize global CSS.

With this change we also reduce the amount of dependencies by removing `css-minimizer-webpack-plugin` which brings in a number of transitive depedencies which we no longer use.
2021-08-10 19:16:14 +02:00
Charles Lyding
1e142cd29a refactor(@angular-devkit/build-angular): remove legacy ES5 build optimizer usage
The legacy standalone build optimizer was still used when targetting ES5 due to the new babel-based build optimizer only supporting the analysis of ES2015+ code. Mainly due to the presence of native classes, the new build optimizer is faster and significantly less complex. To fully remove the legacy build optimizer, ES5 downleveling of application code is now also performed by babel when the TypeScript configuration specifies an ES5 target. TypeScript will now internally emit ES2015 in this configuration and ES2015 code will be used as the input to the remainder of the build pipeline. This has been the behavior for third-party packages and now all code will be consistently downleveled to ES5 using the same tooling.
2021-08-09 16:50:49 +02:00
Charles Lyding
8499cfe1d4 test(@angular-devkit/build-angular): properly discover Bazel units tests
The unit tests for builders are now within the `src/builders/...` path.
2021-08-05 18:41:58 +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
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
Alan Agius
e78f6ab5d8 feat(@angular-devkit/build-angular): remove deprecated tslint builder
BREAKING CHANGE:

Deprecated `@angular-devkit/build-angular:tslint` builder has been removed. Use https://github.com/angular-eslint/angular-eslint instead.
2021-08-02 16:57:56 +01:00
Charles Lyding
1cb07caddc build: transition from ts-api-guardian to dev-infra api-golden utility
The dev-infra tooling now directly provides public API change testing capabilities that leverage the `api-extractor` utility. These new testing capabilities are shared with framework and components.
`ts-api-guardian` has been removed as a dependency as a result.
2021-07-21 14:55:18 -07:00
Charles Lyding
6eca86b817 refactor(@angular-devkit/build-angular): replace raw-loader with Webpack 5 asset modules
With Webpack 5, the `raw-loader` is no longer needed and its functionality is provided via configuration options within the Webpack configuration via asset modules.  Asset modules (https://webpack.js.org/guides/asset-modules/) provide a built-in way to provide `raw-loader`, `url-loader`, and `file-loader` functionality without additional dependencies.
2021-07-07 15:51:19 -04: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
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
Alan Agius
6a9c7ffd97 ci: increase shards for karma tests
This should help to reduce heap out of memory errors during Karma tests.
2021-06-25 07:45:37 +02:00
Charles Lyding
da32daa75d perf(@angular-devkit/build-angular): use combination of esbuild and terser as a JavaScript optimizer
The javascript optimization pipeline is now a two-phase process.  `esbuild` is used in the first phase to remove the majority of the unused code and shorten identifiers in each output bundle script.  `esbuild` can accomplish this in a fraction of the time that `terser` previously required.  However, `esbuild` does not yet implement all of the optimizations that `terser` performs.  As a result, `terser` is used as a second phase to further optimize and reduce the size of the output bundle scripts.  Since `terser` is operating on a smaller input size, the time required for `terser` to complete is significantly reduced.  To further improve performance when source maps are enabled, the source map merging is now performed within the optimization workers. A maximum of four (4) optimization workers are currently used and this value can be adjusted via the `NG_BUILD_MAX_WORKERS` environment variable.
2021-06-25 07:44:57 +02:00
Alan Agius
06181c2fbf fix(@angular-devkit/build-angular): parse web-workers in tests when webWorkerTsConfig is defined
The logic was inverted which caused workers not to be parsed when `webWorkerTsConfig` is defined.
2021-06-22 17:39:12 +01:00
Alan Agius
1dd3bda57f test: fix failing tests which were not shown
Previously when an unhandled error occured Bazel would mark the suit as passed instead of failed.

See: https://togithub.com/bazelbuild/rules_nodejs/commit/3c4ef58
2021-06-10 16:25:19 +02:00
Charles Lyding
f277d951ed refactor(@angular-devkit/build-angular): convert build optimizer passes to babel plugins
The build optimizer passes that are still relevant for Ivy are now implemented as babel plugins.  Using babel has several advantages.  The `babel-loader` is already present within the build pipeline and many packages will already need to be processed by it.  The `babel-loader` also provides the necessary infrastructure to setup babel and link it to the Webpack build system.  This removes the need for the infrastructure code within the build optimizer loader and reduces the build optimizer to only a set of transformation plugins for babel to consume.  The babel plugin architecture also allows for less code to represent similar transformations and provides a variety of helper utilities which further reduces the amount code needed.
The passes are now implemented to be safer when transforming code.  Enum values which contain potential side effects are also no longer altered.  Enums are wrapped in less destructive manner which reduces the likelihood of incorrectly emitting the transformed enum. Class static fields which contain potential side effects are no longer wrapped in pure annotated IIFEs.  Known safe Angular static fields are also wrapped and Angular static fields which are not required in production code are also dropped.
The conversion of the passes not only reduces the amount of code to maintain but also provides a noticeable performance improvement.  Initial tests of a production build of AIO resulted in a ~10% total build time reduction.

Closes #12160
2021-06-04 21:10:06 +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
Alan Agius
0ebf7569f6 perf(@angular-devkit/build-angular): use CSS optimization plugin that leverages workers
With this change we use `css-minimizer-webpack-plugin` which leverages workers and also webpack cache.
2021-05-14 08:29:35 +02:00
Charles Lyding
cc7f75f25b perf(@angular-devkit/build-angular): execute dart-sass in a worker
The dart-sass Sass implementation will now be executed in a separate worker thread. The wrapper worker implementation provides an interface that can be directly used by Webpack's `sass-loader`.
The worker implementation allows dart-sass to be executed in its synchronous mode which can be up to two times faster than its asynchronous mode. The worker thread also allows Webpack to continue other bundling tasks while the Sass stylesheets are being processed.
2021-05-13 12:30:42 +02:00
Charles Lyding
330235230c refactor(@angular-devkit/build-angular): remove redundant webpack-sources dependency
The `webpack` package now exports the `Source` based classes directly.
2021-04-13 15:34:54 -04:00
Alan Agius
dee6b79489 refactor: remove @types/webpack 2021-04-12 10:02:07 -04:00
Alan Agius
0f4bbb58d4 refactor(@angular-devkit/build-angular): remove webpack 4 checks
These are no longer needed as we don't support Webpack 4 any longer
2021-04-12 10:02:07 -04:00
Charles Lyding
d883ce5d7e feat(@angular-devkit/build-angular): upgrade to Webpack 5 throughout the build system
With this change Webpack 5 is now used by the Angular tooling to build applications. Webpack 4 usage and support has been removed.
No project level configuration changes are required to take advantage of the upgraded Webpack version when using the official Angular builders.
Custom builders based on this package that use the experimental programmatic APIs may need to be updated to become compatible with Webpack 5.

BREAKING CHANGE: Webpack 5 lazy loaded file name changes
Webpack 5 generates similar but differently named files for lazy loaded JavaScript files in development configurations (when the `namedChunks` option is enabled).
For the majority of users this change should have no effect on the application and/or build process. Production builds should also not be affected as the `namedChunks` option is disabled by default in production configurations.
However, if a project's post-build process makes assumptions as to the file names then adjustments may need to be made to account for the new naming paradigm.
Such post-build processes could include custom file transformations after the build, integration into service-side frameworks, or deployment procedures.
Example development file name change: `lazy-lazy-module.js` --> `src_app_lazy_lazy_module_ts.js`

BREAKING CHANGE: Webpack 5 web worker support
Webpack 5 now includes web worker support. However, the structure of the URL within the `Worker` constructor must be in a specific format that differs from the current requirement.
Web worker usage should be updated as shown below (where `./app.worker` should be replaced with the actual worker name):
Before: `new Worker('./app.worker', ...)`
After:  `new Worker(new URL('./app.worker', import.meta.url), ...)`
2021-04-08 09:42:47 -04:00
Charles Lyding
e607d4482e test(@angular-devkit/build-angular): increase bazel shards for dev-server tests
With recent improvements to the dev-server builder unit tests, additional parallel testing should now be possible.
The unused `express` dependencies are also removed.
2021-04-07 19:16:07 -04:00
Charles Lyding
649de5d016 test(@angular-devkit/build-angular): remove View Engine related unit tests
With the upcoming removal of View Engine support for applications in version 12, the View Engine related unit tests are no longer needed.
2021-03-29 08:18:39 -06:00
Charles Lyding
d5645675fd fix(@angular-devkit/build-angular): support writing large Webpack stat outputs
When using the `statsJson` browser builder option, the resulting JSON data is now streamed into a file instead of written in one large block.  This mitigates crashes due to the generated string exceeded the Node.js limit.
2021-03-17 11:27:27 +01:00
Charles Lyding
b98d969a92 refactor(@angular-devkit/build-angular): remove speed-measure-plugin usage
The plugin was only used when the `NG_BUILD_PROFILING` environment variable was used.  The environment variable also enabled the Webpack builtin `ProfilingPlugin` which is retained.
The builtin plugin provides a chrome events JSON output which can be loaded in Chrome DevTools and allows for graphical timeline views of the build.
The `speed-measure-plugin` is also currently incompatible with Webpack 5 which would prevent the CLI profiling support from working with Webpack 5.
2021-03-10 08:19:56 -06:00
Charles Lyding
a09000cbe6 test(@angular-devkit/build-angular): remove unneeded nobazel_patch_module_resolver option
As of rules_nodejs 3.0.0, the `bazel_patch_module_resolver` option defaults to off.
2021-03-10 08:17:31 -06:00
Charles Lyding
a51eb6e864 test(@angular-devkit/build-angular): add dev-server execute and fetch unit test helper
This change extracts common test code into a helper function to reduce complexity of the dev-server builder unit tests.
2021-03-10 08:17:10 -06:00
Charles Lyding
d3ea61f7fe build: remove unused development dependencies
Several dependencies were no longer used within the project but still present in the `package.json`
2021-03-03 07:02:51 -05:00
Alan Agius
9337617723 feat(@angular-devkit/build-angular): add postcss-preset-env with stage 3 features
With this change we add `postcss-preset-env` with stage 3 features. This stage includes support for:

 - all property
 - break properties
 - custom properties
 - font-variant property
 - gap properties
 - media query ranges

See https://preset-env.cssdb.org/features#stage-3
2021-02-09 10:30:42 -05:00
Alan Agius
fb2d7ee903 refactor(@angular-devkit/build-angular): remove experimental rollup pass
The experimental rollup pass has significant issues with the new Ivy webpack plugin. It also, didn't produce as well as we hoped in real world scenarios infact in many cases this caused build to fail.

REAKING CHANGE:

The experimental rollup pass `--experimental-rollup-pass` option has been removed.

Closes #15836
2021-02-09 08:50:00 -05:00
Alan Agius
6732294ff3 refactor(@angular-devkit/build-angular): remove file-loader dependency
`file-loader` resolves `import/require()` on a file into a url. This is non standard, undocumented, unsupported Webpack specific functionality. This was introduced in the Angular CLI  before `postcss-cli-resources` existed and was never removed.

Using `file-loader` and `postcss-cli-resources` are no longer needed with Webpack 5, because of the introduction of [Assets Modules](https://webpack.js.org/guides/asset-modules/).

BREAKING CHANGE:

The unsupported/undocumented, Webpack specific functionality to `import`/`require()` a non-module file has been removed.

Before
```js
import img from './images/asset.png';
```

After
```html
<img src="images/asset.png">
```
2021-02-04 08:42:57 +01:00
Alan Agius
9af0942e69 fix(@angular-devkit/build-angular): inlining fonts behind proxy
With this change users can now their proxy server via the `HTTPS_PROXY` environment variable. The specified proxy will be used when making requests to inline fonts.

Closes #19401
2021-01-25 09:17:03 -06:00
Charles Lyding
faf7b26ef9 test(@angular-devkit/build-angular): add browser builder option test for main 2020-12-18 10:37:26 +01:00
Charles Lyding
bcac38331e test(@angular-devkit/build-angular): add builder test harness 2020-12-18 10:37:26 +01:00