In the CLI `UpdateRecorder` methods such as `insertLeft`, `remove` etc.. accepts positions which are not offset by a BOM. This is because when a file has a BOM a different recorder will be used https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/schematics/src/tree/recorder.ts#L72 which caters for an addition offset/delta.
The main reason for this is that when a developer is writing a schematic they shouldn't need to compute the offset based if a file has a BOM or not and is handled out of the box.
Example
```ts
recorder.insertLeft(5, 'true');
```
However this is unfortunate in the case if a ts SourceFile is used and one uses `getWidth` and `getStart` method they will already be offset by 1, which at the end it results in a double offset and hence the problem.
Fixes#14551
Replacment of line endings should only happen to increase the hash matches as otherwise the recorder will fail to update the correct positions
Fixes#14443
Differential loading migration should run only when the project is using `@angular-devkit/build-angular:browser` as it's browser builder. Otherwise we might break applications that are using different builders.
Fixes#14389
By using a pure schematic based implementation the overhead of running tslint can be removed. This also has the benefit of allowing direct control over the files loaded and to modify files only within the schematic tree context.
For a hello world application, there was a ~20% performance improvement for the CLI migration from 7.0 to 8.0 as well as a ~10% reduction in memory usage.
Replaces the usage of the tsquery package with a conditional based on TypeScript helper functions. Since a TypeScript-subset is vendored within the package, a TypeScript peer dependency cannot be met even though the functionality is present.
Fixes#14270
If a polyfills file is original, then replace completely with latest version of the file. This removes the need to deeply analyze the file as well as ensuring all comments are up to date. Also skips analysis if there is no mention of `core-js` of any form in the file.
The header re-addition check is also reduced in scope to account for varying versions of the header content.
The package group format required to automatically update the builder packages was not supported until CLI 7.2. For older CLI versions performing the update, this new migration will update the builders instead. Once the CLI is updated to at least 7.2, the update algorithm itself will handle the update.
We don't know yet if we are going to separate zone.js in a separate file. Hence, we should remove this for the time being and include it only when we remove zone.js from the main polyfills files
1. Remove imports of es6 polyfills introduced by the CLI.
2. Refactor the migrations for version 8 by moving the codelyzer and
polyfill transforms into different files.
The PR drops all `core-js/es6` polyfills that we've introduced with the
CLI, except the commented ones. We do not remove commented imports,
since they are not part of the internal es6 polyfills.
The migration automatically drops the
associated comments with the removed imports since they are part of the node - under its
`jsDoc` property.