257 Commits

Author SHA1 Message Date
Alan Agius
65e5331740 fix(@schematics/angular): add missing express REQUEST and RESPONSE tokens
This commit updates the nguniversal migration to add `REQUEST` and `RESPONSE` tokens.

Closes #26110
2023-10-31 08:59:15 +01:00
Alan Agius
f6a088bc18 fix(@angular/ssr): correctly set config URL
When calling `renderApplication` or `renderModule` the URL would be overridden to undefined as the `url` option was not provided as an option.
2023-10-24 16:11:45 +02:00
Alan Agius
c07cbd5073 fix(@schematics/angular): do not add unnecessary dependency on @angular/ssr during migration
Prior to this change the Universal migration ran and added `@angular/ssr` even the workspace did not depend on `@nguniversal/` packages.

Closes #26083
2023-10-23 15:17:08 +02:00
Alan Agius
53f93b93bb fix(@schematics/angular): noop workspace config migration when already executed
Prior to this change there was a missing check that causes the migration to remove valid config when it was executed multiple times or on configs that do not contain the deprecated option.

Closes #26063
2023-10-19 13:16:03 +02:00
Alan Agius
62aa7393c8 test: ensure to use the correct version for @angular/ssr packages
This commit fixes an issue that causes update tests to fail when we are in feature freeze
2023-10-12 15:54:24 +02:00
Alan Agius
3938863b99 feat(@schematics/angular): add migration to migrate from @nguniversal to @angular/ssr
This commit adds a migration to migrate usages of `@nguniversal` to `@angular/ssr`.
2023-10-11 15:58:21 +02:00
Alan Agius
c48982dc1d feat(@angular-devkit/build-angular): add buildTarget option to dev-server and extract-i18n builders
This is to better match the nature of the application builder where the target can be both browser and server.

DEPRECATED: The `browserTarget` in the dev-server and extract-i18n builders have been deprecated in favor of `buildTarget`.
2023-10-10 19:43:11 +02:00
Alan Agius
dc6b6eaf6f feat(@schematics/angular): add migration to replace usages of @nguniversal/builders
This migration replaces usages of `@nguniversal/builders` with `@angular-devkit/build-angular`.
2023-10-02 15:30:03 +02:00
Alan Agius
2e0a6fed35 refactor(@schematics/angular): remove version 16 migrations
This migrations are no longer needed
2023-10-02 15:30:03 +02:00
Alan Agius
873272f644 fix(@schematics/angular): provide migration that disables build optimizer on dev server builds
In https://github.com/angular/angular-cli/pull/25070 we turned on `buildOptimizer` by default for server builds. This causes existing projects development builds to always run build-optimizer. This migration will set `buildOptimizer` to false, when `optimization` is disabled.
2023-04-27 12:25:54 +00:00
Alan Agius
68024234ed feat(@angular/cli): remove deprecated defaultCollection from workspace configuration
The deprecated 'defaultCollection' workspace option has been removed

BREAKING CHANGE:

The deprecated `defaultCollection` workspace option has been removed. Use `schematicCollections` instead.

Before
```json
"defaultCollection": "@angular/material"
```

After
```json
"schematicCollections": ["@angular/material"]
```
2023-02-17 16:10:21 +00:00
Alan Agius
d58428d3db feat(@angular/cli): remove deprecated defaultProject from workspace configuration
The deprecated 'defaultProject' workspace option has been removed

BREAKING CHANGE: The deprecated `defaultProject` workspace option has been removed. The project to use will be determined from the current working directory.
2023-02-17 16:10:21 +00:00
Alan Agius
ada4d694c3 refactor(@schematics/angular): remove version 15 migrations
These are no longer used.
2023-02-17 16:10:21 +00:00
Alan Agius
207358afb8 feat(@angular-devkit/schematics): add runSchematic and runExternalSchematic methods
These async methods are a replacement for the Observable based `runSchematicAsync` and `runExternalSchematicAsync` methods.

DEPRECATED:
The Observable based `SchematicTestRunner.runSchematicAsync` and `SchematicTestRunner.runExternalSchematicAsync` method have been deprecated in favor of the Promise based `SchematicTestRunner.runSchematic` and `SchematicTestRunner.runExternalSchematic`.
2022-12-08 14:49:43 -08:00
Alan Agius
5a123a61ea fix(@schematics/angular): show warning when a TS Config is not found during migrations
Prior to this change an error was shown when a non existing tsconfig was referenced in the angular.json. This causes the update to fail.

Closes #24264
2022-11-17 16:32:11 -08:00
Alan Agius
11bb8ce26f perf(@angular-devkit/build-angular): add vendor chunking to server builder
With this change we add the `vendorChunk` option in the server builder. This option should only be used in development as it is intended to be used to improve the incremental re-build time.

This improves the rebuild time as Webpack will have less modules to analyse during a change in the application. Below, we can see the impact this change has in a `ng new` application.

Without vendor chunking
```
$ ng run ssr-vendor:server:development --watch --no-vendor-chunk
Build at: 2022-11-14T08:42:27.089Z - Hash: 0325905b63e43ddb - Time: 15357ms
Build at: 2022-11-14T08:42:37.565Z - Hash: 05cb180a02524656 - Time: 2498ms
Build at: 2022-11-14T08:42:40.325Z - Hash: c5a6996ed1924088 - Time: 1862ms
Build at: 2022-11-14T08:42:43.043Z - Hash: 92ce99f38a769c19 - Time: 1516ms
```

With vendor chunking
```
$ ng run ssr-vendor:server:development --watch --vendor-chunk
Build at: 2022-11-14T08:43:13.631Z - Hash: 28bdfea879d01a31 - Time: 15561ms
Build at: 2022-11-14T08:43:19.396Z - Hash: cc95e2b6cb403111 - Time: 1705ms
Build at: 2022-11-14T08:43:21.296Z - Hash: 204138490668a16c - Time: 848ms
Build at: 2022-11-14T08:43:23.835Z - Hash: 4fa294b261917944 - Time: 824ms
```
2022-11-15 10:14:02 -08:00
Alan Agius
766d4a0895 feat(@schematics/angular): add migration to remove require calls from karma builder main file
With the recent changes in build-angular the `require.context` calls have become unneeded.
2022-09-26 17:39:55 +02:00
Alan Agius
9c13fce162 feat(@angular-devkit/build-angular): remove bundleDependencies from server builder
This commit removes the usages of `bundleDependencies` which does not correctly work as webpack will use `require` to import ESM module since we configure the server bundle to be outputted in CJS. Migrating fully to ESM is also currently not viable due to the lack of support from Domino.
Even if full ESM was possible, using this option would have resulted in a runtime overhead as Angular libraries would be linked during runtime instead of compile time.

BREAKING CHANGE:
The server builder `bundleDependencies` option has been removed. This option was used pre Ivy. Currently, using this option is unlikely to produce working server bundles.

The `externalDependencies` option can be used instead to exclude specific node_module packages from the final bundle.

Closes #23905
2022-09-23 15:41:30 -04:00
Alan Agius
1e5d4a7508 feat(@angular-devkit/build-angular): use Browserslist to determine ECMA output
With this change we reduce the reliance on the TypeScript target compiler option to output a certain ECMA version. Instead we now use the browsers that are configured in the Browserslist configuration to determine which ECMA features and version are needed. This is done by passing the transpiled TypeScript to Babel preset-env.

**Note about useDefineForClassFields**: while setting this to `false` will output JavaScript which is not spec compliant, this is needed because TypeScript introduced class fields many years before it was ratified in TC39. The latest version of the spec have a different runtime behavior to TypeScript’s implementation but the same syntax. Therefore, we opt-out from using upcoming ECMA runtime behavior to better support the ECO system and libraries that depend on the non spec compliant output. One of biggest case is usages of the deprecated `@Effect` decorator by NGRX and potentially other existing code as well which otherwise would cause runtime failures. Dropping `useDefineForClassFields` will be considered in a future major releases. For more information see: https://github.com/microsoft/TypeScript/issues/45995.

BREAKING CHANGE: Internally the Angular CLI now always set the TypeScript `target` to `ES2022` and `useDefineForClassFields` to `false` unless the target is set to `ES2022` or later in the TypeScript configuration. To control ECMA version and features use the Browerslist configuration.
2022-09-21 11:23:35 -04:00
Alan Agius
15d3fc6dc3 feat(@angular-devkit/build-angular): export @angular/platform-server symbols in server bundle
This commit adds an internal file to export needed symbols from `@angular/platform-server` when building a server bundle. This is needed.  This is needed so that DI tokens can be referenced and set at runtime outside of the bundle.

Also, it adds a migration to remove these exports from the users files as otherwise an export collision would occur due to the same symbol being exported multiple times.
2022-09-20 10:24:29 -04:00
Alan Agius
9beb878e2e feat(@schematics/angular): remove Browserslist configuration files from projects
The Browserslist configuration file is redundant as we set the defaults directly in @angular-devkit/build-angular. 8da926966e/packages/angular_devkit/build_angular/src/utils/supported-browsers.ts (L12-L19)

With this commit, we remove the `.browserlistrc` configuration file from the schematics application template and through a migration in existing projects when the Browserslist query result matches the default.

Users needing a finer grain support should still create a `.browserlistrc` in the root directory of the project.
2022-09-14 10:43:41 -07:00
Alan Agius
71ff22cc0c refactor(@schematics/angular): remove migrations for version 14
This migrations are no longer needed as multiple versions update is not allowed.
2022-09-14 10:43:41 -07:00
Alan Agius
32281c2109 fix(@schematics/angular): add migration to remove package.json in libraries secondary entrypoints
`package.json` files have been remove from secondary entrypoints in version 14 of Angular package format (APF).

With this change we delete the now redundant files and in case these contained the deprecated way of how to configure secondary entrypoints in ng-packagr we migrate these as well.
2022-05-09 10:51:56 -07:00
Alan Agius
366cabc66c feat(@angular/cli): add support for multiple schematics collections
The `schematicCollections` can be placed under the `cli` option in the global `.angular.json` configuration, at the root or at project level in `angular.json` .

```jsonc
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "cli": {
    "schematicCollections": ["@schematics/angular", "@angular/material"]
  }
  // ...
}
```

**Rationale**
When this option is not configured and a user would like to run a schematic which is not part of `@schematics/angular`,
the collection name needs to be provided to `ng generate` command in the form of `[collection-name:schematic-name]`. This make the `ng generate` command too verbose for repeated usages.

This is where `schematicCollections` comes handle. When adding `@angular/material` to the list of `schematicCollections`, the generate command will try to locate the schematic in the specified collections.

```
ng generate navigation
```

is equivalent to:

```
ng generate @angular/material:navigation
```

**Conflicting schematic names**
When multiple collections have a schematic with the same name. Both `ng generate` and `ng new` will run the first schematic matched based on the ordering (as specified) of `schematicCollections`.

DEPRECATED:

The `defaultCollection` workspace option has been deprecated in favor of `schematicCollections`.

Before
```json
"defaultCollection": "@angular/material"
```

After
```json
"schematicCollections": ["@angular/material"]
```

Closes #12157
2022-03-22 09:37:57 -07:00
Alan Agius
e49220fba0 feat(@schematics/angular): add migratiom to remove defaultProject in workspace config
This option is deprecated in Angular CLI and will be removed in a future major version.
2022-03-21 12:28:15 -07:00
Alan Agius
90a5a4c284 build: update @types/node to ^14.15.0
Version 12 is no longer supported.
2022-03-07 19:04:35 +01: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
69ecddaa7d feat(@schematics/angular): update new and existing projects compilation target to ES2020
With this change we update the TypeScript compilation target to `ES2020` for both new and existing projects. This is because all browsers that Angular supports (https://angular.io/guide/browser-support) support `ES2020` features without the need for polyfills.
2022-01-28 11:01:09 -08:00
Alan Agius
7e7de6858d feat(@schematics/angular): update Angular dependencies to use ^ as version prefix
With this change we update Angular dependencies to use `^` instead of `~` as version prefix.

Closes #21925
2022-01-27 11:07:13 -08:00
Alan Agius
28b0cdc966 refactor(@schematics/angular): remove version 13 migrations
These migrations cannot be used with version Angular CLI 14, since `ng update` will not allow updating multiple versions at once.
2022-01-27 11:07:13 -08:00
Alan Agius
e9d2d98e89 fix(@schematics/angular): migrate ng-packagr configurations in package.json
Currently ng-packagr, can be configured used in package.json. Previously, the migration didn't handle this case.

Closes #22129
2021-11-10 10:24:24 -05:00
Alan Agius
950b430c01 fix(@schematics/angular): show warning when migrating ng-packagr JS configurations
Our migrations only handle JSON configs.

Closes #22107
2021-11-08 10:25:51 -05:00
Alan Agius
b45f9a0a37 refactor(@schematics/angular): remove no longer used migrations
Previously, we introduced a change to show an error message when users try to update `@angular/` and `@nguniversal/` packages across multiple major versions.

 The mentioned change makes these migrations no longer used.
2021-10-26 04:45:18 -05:00
Alan Agius
57d7eb5b16 fix(@angular/cli): error when updating Angular packages across multi-major migrations
With this change we show an error message when users try to update `@angular/` and `@nguniversal/` packages across multiple major versions.
2021-10-26 04:45:18 -05:00
Alan Agius
7ff8c5350e feat(@schematics/angular): add /.angular/cache to .gitignore
With this change we add `/.angular/cache` to `.gitignore`. This folder will primary be used to store the build disk cache artifacts.
2021-10-06 08:02:22 -05:00
Doug Parker
eac18aed78 feat(@schematics/angular): drop polyfills required only for Internet Explorer now that support has been dropped for it
Removes the `classlist.js` and `web-animations-js` polyfills from any polyfills files in a workspace. Specifically, it looks for `import 'classlist.js';` and `import 'web-animations-js';`, then removes those them along with any preceeding comments (aside from the file overview and browser polyfills header comment).

Previous versions of `ng new` generated a polyfills file with commented out imports for both modules, to avoid including them by default while giving users an easy way to enable them. This migration also looks for these commented out imports and removes them along with associated descriptive comments. This has no effect on the application, but cleans up unnecessary noise from the polyfills file.

BREAKING CHANGE:

`classlist.js` and `web-animations-js` are removed from application polyfills and uninstalled from the package. These were only needed for compatibility with Internet Explorer, which is no longer needed now that Angular only supports evergreen browsers. See: https://angular.io/guide/browser-support.

Add the following to the polyfills file for an app to re-add these packages:

```typescript
import 'classlist.js';
import 'web-animations-js';
```

And then run:

```sh
npm install classlist.js web-animations-js --save
```
2021-10-06 06:11:23 -05:00
Alan Agius
000b0e51c1 feat(@angular-devkit/build-angular): remove deprecated dev-server options
BREAKING CHANGE: With this change a number of deprecated dev-server builder options which proxied to the browser builder have been removed. These options should be configured in the browser builder instead.

The removed options are:
- `aot`
- `sourceMap`
- `deployUrl`
- `baseHref`
- `vendorChunk`
- `commonChunk`
- `optimization`
- `progress`
2021-10-01 14:07:42 -05:00
Alan Agius
31ec09c111 refactor(@schematics/angular): remove migrations for unsupported versions 2021-09-24 15:38:33 -04:00
Alan Agius
4f91816b29 feat(@schematics/angular): migrate libraries to be published from ViewEngine to Ivy Partial compilation
This migration updates libraries to be published in partial mode instead of view engine. Also, it removed deprecated options from ng-packagr configuration.
2021-08-23 11:06:07 +01:00
Alan Agius
268a03b630 feat(@schematics/angular): add migration to update the workspace config
With this change we add a migration to update the workspace configuration to version 13 by removed deprecated options and builders.
2021-08-03 15:07:04 +01:00
Alan Agius
5986befcdc feat(@schematics/angular): remove deprecated options
With this change we removed several deprecated `@schematics/angular` deprecated options.

BREAKING CHANGE:

We removed several deprecated `@schematics/angular` deprecated options.
- `lintFix` have been removed from all schematics. `ng lint --fix` should be used instead.
- `legacyBrowsers` have been removed from the `application` schematics since IE 11 is no longer supported.
- `configuration` has been removed from the `web-worker` as it was unused.
- `target` has been removed from the `service-worker` as it was unused.
2021-07-30 14:26:53 +01:00
Alan Agius
14df2aaef9 refactor(@schematics/angular): sync schematics dependencies using Renovate
With this change we sync workspace and library schematic dependencies using Renovate. We do this to avoid having to keep these in sync by hand.

We could have used TypeScripts' `resolveJsonModule` to make the `latestVersion` object typesafe. But `ts_library` doesn't support JSON inputs.
2021-07-20 18:58:29 +02:00
Alan Agius
e5ba29c7d5 fix(@schematics/angular): display warning during migrations when using third-party builders 2021-06-21 11:10:51 +01:00
Alan Agius
c9f531d703 feat(@schematics/angular): add migration to replace deprecated --prod
With this change we add migration to replace the deprecated `--prod` with `--configuration production` in the scripts section of the package.json.

Closes #21036
2021-06-16 08:00:33 -04: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
afc9d10688 fix(@schematics/angular): make version 12 workspace config migration idempotent
With this change we ensure that `update-angular-config-v12` migration is idempotent

Closes #20979
2021-05-31 12:49:24 +01:00
Alan Agius
1080a52c96 fix(@schematics/angular): add migration to remove skipTests from @schematics/angular:module
Migration for #20842

Closes #20848
2021-05-19 17:28:14 +02:00
Alan Agius
4ed1c4f42d fix(@schematics/angular): replace clientProject with project 2021-05-05 11:49:22 -04:00
Alan Agius
7521a8727c fix(@schematics/angular): only run emitDecoratorMetadata removal migration in safe workspaces
Removal of `emitDecoratorMetadata` might cause runtime errors on projects which don't use the Angular Compiler to compile TypeScript code and therefore dependent on Decorators metadata during runtime.  One such example of these builders is `@nrwl/jest`.
2021-05-04 10:33:58 -04:00
Alan Agius
e992c9a70b build: update files to be fix eslint header/header failures 2021-05-04 09:59:40 -04:00