With this change we replace all usage of `compilation.errors `and `compilation.warnings.push` with `addError` and `addWarning` respectively.
Also, we update the helpers in build-angular to use `WebpackError` from the current compilation to avoid mismatching instances.
To support AOT compilation the Angular bootstrap call needs to be converted from
using `platform-browser-dynamic` to `platform-browser`. This transform was previously
being executed against every source file within the program regardless of the presence of
`platformBrowserDynamic`. An initial check is now performed that can avoid AST traversal
when the bootstrapping call is not present in a file.
Updates to the TypeScript 4.8 RC and adds some code to account for a breaking change where the decorators and modifiers of an AST node have been combined into a single array.
With this change we fix an issue where type only named imports were being emitted. As a result webpack failed to resolve such symbols as they don't exist in JavaScript.
Closes#23667
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.
Prior to this change the CLI would fail with an error when ngcc could not
be run due to a missing `node_modules` directory, as is the case with Yarn
Plug'n'Play for example. The workaround was to create an empty `node_modules`
directory, but this is inconvenient and shouldn't make any difference.
This commit removes the error and simply skips ngcc processing.
A TypeScript version mismatch with the Angular compiler will no longer cause an
exception to propagate up through the Webpack system. In Node.js v14, this resulted
in an unhandled promise rejection warning and the build command never completing.
This can also be reproduced in newer versions of Node.js by using the Node.js
option `--unhandled-rejections=warn`. To correct this issue, the version mismatch
is now treated as a compilation error and added to the list of errors that are
displayed at the end of the build. This also has the benefit of avoiding the stack
trace of the exception from being shown which previously drew attention away from
the actual error message.
Prepares the `@ngtools/webpack` package for the eventual change of enabling the
TypeScript `useUnknownInCatchVariables` option. This option provides additional
code safety by ensuring that the catch clause variable is the proper type before
attempting to access its properties. Similar changes will be needed in the other
packages in the repository prior to enabling `useUnknownInCatchVariables`.
Locally-built APF v14 libraries should be resolved properly. Webpack
currently does not resolve them (in e.g. `dist/`) because the local
distribution folders are not marked as module roots, causing Webpack
to never hit the `module`/`raw-module` resolution hooks and therefore
skipping package exports resolution and breaking secondary entry-points
from being resolved properly (when bundling).
We fix this by also attempting to resolve path mappings as modules,
allowing for Webpacks `resolve-in-package` hooks to be activated. These
hooks support the `exports` field and therefore APF v14 secondary
entry-points which are not necessarily inside a Webpack resolve
`modules:` root (but e.g. in `dist/`)
Webpack provides built-in support for creating hashes using the xxhash64 algorithm via a WebAssembly module.
This can be significantly faster than the previously used md5 algorithm.
The Webpack peer dependency has also been update to a minimum of 5.54.0 to ensure xxhash64 supported is available.