Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(angular): remove angular v15 support #23301

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generated/manifests/nx-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"type": "executor"
},
"/nx-api/angular/executors/ng-packagr-lite": {
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but with some key differences:\n- For supported Angular versions lower than v16, it doesn't run `ngcc` automatically (`ngcc` is no longer available from Angular v16 onwards, for lower versions, it needs to be run separately beforehand if needed, this can be done in a `postinstall` hook on `package.json`).\n- It only produces ESM2022 bundles (ESM2020 for supported Angular versions lower than v16).",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but it only produces ESM2022 bundles.",
"file": "generated/packages/angular/executors/ng-packagr-lite.json",
"hidden": false,
"name": "ng-packagr-lite",
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"type": "executor"
},
{
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but with some key differences:\n- For supported Angular versions lower than v16, it doesn't run `ngcc` automatically (`ngcc` is no longer available from Angular v16 onwards, for lower versions, it needs to be run separately beforehand if needed, this can be done in a `postinstall` hook on `package.json`).\n- It only produces ESM2022 bundles (ESM2020 for supported Angular versions lower than v16).",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but it only produces ESM2022 bundles.",
"file": "generated/packages/angular/executors/ng-packagr-lite.json",
"hidden": false,
"name": "ng-packagr-lite",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outputCapture": "direct-nodejs",
"$schema": "https://json-schema.org/schema",
"title": "ng-packagr Target",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but with some key differences:\n- For supported Angular versions lower than v16, it doesn't run `ngcc` automatically (`ngcc` is no longer available from Angular v16 onwards, for lower versions, it needs to be run separately beforehand if needed, this can be done in a `postinstall` hook on `package.json`).\n- It only produces ESM2022 bundles (ESM2020 for supported Angular versions lower than v16).",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but it only produces ESM2022 bundles.",
"cli": "nx",
"type": "object",
"presets": [
Expand Down Expand Up @@ -44,7 +44,7 @@
"additionalProperties": false,
"required": ["project"]
},
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but with some key differences:\n- For supported Angular versions lower than v16, it doesn't run `ngcc` automatically (`ngcc` is no longer available from Angular v16 onwards, for lower versions, it needs to be run separately beforehand if needed, this can be done in a `postinstall` hook on `package.json`).\n- It only produces ESM2022 bundles (ESM2020 for supported Angular versions lower than v16).",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but it only produces ESM2022 bundles.",
"aliases": [],
"hidden": false,
"path": "/packages/angular/src/executors/ng-packagr-lite/schema.json",
Expand Down
6 changes: 3 additions & 3 deletions docs/generated/packages/angular/executors/webpack-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"properties": {
"assets": {
"type": "array",
"description": "List of static application assets. _Note: only supported in Angular versions >= 15.1.0_",
"description": "List of static application assets.",
"default": [],
"items": {
"oneOf": [
Expand Down Expand Up @@ -187,7 +187,7 @@
},
"vendorChunk": {
"type": "boolean",
"description": "Generate a separate bundle containing only vendor libraries. This option should only be used for development to reduce the incremental compilation time. _Note: supported in Angular versions >= 15.1.0_",
"description": "Generate a separate bundle containing only vendor libraries. This option should only be used for development to reduce the incremental compilation time.",
"default": false
},
"verbose": {
Expand Down Expand Up @@ -249,7 +249,7 @@
},
"buildOptimizer": {
"type": "boolean",
"description": "Enables advanced build optimizations. _Note: only supported in Angular versions >= 16.0.0_.",
"description": "Enables advanced build optimizations.",
"default": true
},
"namedChunks": {
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/packages/angular/generators/setup-ssr.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"appId": {
"type": "string",
"format": "html-selector",
"description": "The `appId` to use with `withServerTransition`. _Note: This is only used in Angular versions <16.0.0. It's deprecated since Angular 16 and not supported since Angular 17._",
"description": "The `appId` to use with `withServerTransition`. _Note: This is deprecated and ignored since Angular 16 and not supported since Angular 17._",
"default": "serverApp"
},
"main": {
Expand Down Expand Up @@ -55,7 +55,7 @@
},
"hydration": {
"type": "boolean",
"description": "Set up Hydration for the SSR application. It defaults to `true` for Angular versions >= 17.0.0. Otherwise, it defaults to `false`. _Note: This is only supported in Angular versions >= 16.0.0_."
"description": "Set up Hydration for the SSR application. It defaults to `true` for Angular versions >= 17.0.0. Otherwise, it defaults to `false`."
},
"skipFormat": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ng-packagr-lite": {
"implementation": "./src/executors/ng-packagr-lite/ng-packagr-lite.impl",
"schema": "./src/executors/ng-packagr-lite/schema.json",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but with some key differences:\n- For supported Angular versions lower than v16, it doesn't run `ngcc` automatically (`ngcc` is no longer available from Angular v16 onwards, for lower versions, it needs to be run separately beforehand if needed, this can be done in a `postinstall` hook on `package.json`).\n- It only produces ESM2022 bundles (ESM2020 for supported Angular versions lower than v16)."
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but it only produces ESM2022 bundles."
},
"package": {
"implementation": "./src/executors/package/package.impl",
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
"piscina": "^4.4.0"
},
"peerDependencies": {
"@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
"@angular-devkit/core": ">= 15.0.0 < 18.0.0",
"@angular-devkit/schematics": ">= 15.0.0 < 18.0.0",
"@schematics/angular": ">= 15.0.0 < 18.0.0",
"@angular-devkit/build-angular": ">= 16.0.0 < 19.0.0",
"@angular-devkit/core": ">= 16.0.0 < 19.0.0",
"@angular-devkit/schematics": ">= 16.0.0 < 19.0.0",
"@schematics/angular": ">= 16.0.0 < 19.0.0",
"esbuild": "^0.19.2",
"rxjs": "^6.5.3 || ^7.5.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/src/builders/webpack-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"properties": {
"assets": {
"type": "array",
"description": "List of static application assets. _Note: only supported in Angular versions >= 15.1.0_",
"description": "List of static application assets.",
"default": [],
"items": {
"$ref": "#/definitions/assetPattern"
Expand Down Expand Up @@ -127,7 +127,7 @@
},
"vendorChunk": {
"type": "boolean",
"description": "Generate a separate bundle containing only vendor libraries. This option should only be used for development to reduce the incremental compilation time. _Note: supported in Angular versions >= 15.1.0_",
"description": "Generate a separate bundle containing only vendor libraries. This option should only be used for development to reduce the incremental compilation time.",
"default": false
},
"verbose": {
Expand Down Expand Up @@ -192,7 +192,7 @@
},
"buildOptimizer": {
"type": "boolean",
"description": "Enables advanced build optimizations. _Note: only supported in Angular versions >= 16.0.0_.",
"description": "Enables advanced build optimizations.",
"default": true
},
"namedChunks": {
Expand Down
40 changes: 0 additions & 40 deletions packages/angular/src/builders/webpack-server/validate-options.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { switchMap } from 'rxjs/operators';
import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
import { mergeCustomWebpackConfig } from '../utilities/webpack';
import { Schema } from './schema';
import { validateOptions } from './validate-options';

function buildServerApp(
options: Schema,
Expand Down Expand Up @@ -55,7 +54,7 @@ function buildServerAppWithCustomWebpackConfiguration(
switchMap(({ executeServerBuilder }) =>
executeServerBuilder(options, context as any, {
webpackConfiguration: async (baseWebpackConfig) => {
// Angular 15 auto includes code from @angular/platform-server
// Angular auto includes code from @angular/platform-server
// This includes the code outside the shared scope created by ModuleFederation
// This code will be included in the generated code from our generators,
// maintaining it within the shared scope.
Expand Down Expand Up @@ -96,8 +95,6 @@ export function executeWebpackServerBuilder(
options: Schema,
context: import('@angular-devkit/architect').BuilderContext
): Observable<import('@angular-devkit/build-angular').ServerBuilderOutput> {
validateOptions(options);

options.buildLibsFromSource ??= true;

process.env.NX_BUILD_LIBS_FROM_SOURCE = `${options.buildLibsFromSource}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,6 @@ type ConditionalExport = {
esm2022?: string;
esm?: string;
default?: string;

// backward compat for Angular < 16
node?: string;
esm2020?: string;
es2020?: string;
es2015?: string;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/executors/ng-packagr-lite/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"outputCapture": "direct-nodejs",
"$schema": "https://json-schema.org/schema",
"title": "ng-packagr Target",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but with some key differences:\n- For supported Angular versions lower than v16, it doesn't run `ngcc` automatically (`ngcc` is no longer available from Angular v16 onwards, for lower versions, it needs to be run separately beforehand if needed, this can be done in a `postinstall` hook on `package.json`).\n- It only produces ESM2022 bundles (ESM2020 for supported Angular versions lower than v16).",
"description": "Builds an Angular library with support for incremental builds.\n\nThis executor is meant to be used with buildable libraries in an incremental build scenario. It is similar to the `@nx/angular:package` executor but it only produces ESM2022 bundles.",
"cli": "nx",
"type": "object",
"presets": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ exports[`app --strict should enable strict type checking: e2e tsconfig.json 1`]
`;

exports[`app angular compat support should import "ApplicationConfig" from "@angular/platform-browser" 1`] = `
"import { ApplicationConfig } from '@angular/platform-browser';
"import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { appRoutes } from './app.routes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ describe('app', () => {
...json,
dependencies: {
...json.dependencies,
'@angular/core': '~15.2.0',
'@angular/core': '~16.2.0',
},
}));
});
Expand All @@ -1241,13 +1241,13 @@ describe('app', () => {

const { devDependencies } = readJson(appTree, 'package.json');
expect(devDependencies['@angular-devkit/build-angular']).toEqual(
backwardCompatibleVersions.angularV15.angularDevkitVersion
backwardCompatibleVersions.angularV16.angularDevkitVersion
);
expect(devDependencies['@angular-devkit/schematics']).toEqual(
backwardCompatibleVersions.angularV15.angularDevkitVersion
backwardCompatibleVersions.angularV16.angularDevkitVersion
);
expect(devDependencies['@schematics/angular']).toEqual(
backwardCompatibleVersions.angularV15.angularDevkitVersion
backwardCompatibleVersions.angularV16.angularDevkitVersion
);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApplicationConfig<% if (useEventCoalescing) { %>, provideZoneChangeDetection<% } %> } from <% if (angularMajorVersion >= 16) { %>'@angular/core';<% } else { %>'@angular/platform-browser';<% } %><% if (routing) { %>
import { ApplicationConfig<% if (useEventCoalescing) { %>, provideZoneChangeDetection<% } %> } from '@angular/core';<% if (routing) { %>
import { provideRouter } from '@angular/router';
import { appRoutes } from './app.routes';<% } %>

Expand Down
18 changes: 9 additions & 9 deletions packages/angular/src/generators/ngrx/ngrx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,35 +674,35 @@ export const appRoutes: Routes = [{ path: 'home', component: NxWelcomeComponent
...json,
dependencies: {
...json.dependencies,
'@angular/core': '15.0.0',
'@angular/core': '16.0.0',
},
}));
});

it('should install the ngrx 15 packages', async () => {
it('should install the ngrx 16 packages', async () => {
await ngrxGenerator(tree, defaultOptions);

const packageJson = devkit.readJson(tree, 'package.json');
expect(packageJson.dependencies['@ngrx/store']).toEqual(
backwardCompatibleVersions.angularV15.ngrxVersion
backwardCompatibleVersions.angularV16.ngrxVersion
);
expect(packageJson.dependencies['@ngrx/effects']).toEqual(
backwardCompatibleVersions.angularV15.ngrxVersion
backwardCompatibleVersions.angularV16.ngrxVersion
);
expect(packageJson.dependencies['@ngrx/entity']).toEqual(
backwardCompatibleVersions.angularV15.ngrxVersion
backwardCompatibleVersions.angularV16.ngrxVersion
);
expect(packageJson.dependencies['@ngrx/router-store']).toEqual(
backwardCompatibleVersions.angularV15.ngrxVersion
backwardCompatibleVersions.angularV16.ngrxVersion
);
expect(packageJson.dependencies['@ngrx/component-store']).toEqual(
backwardCompatibleVersions.angularV15.ngrxVersion
backwardCompatibleVersions.angularV16.ngrxVersion
);
expect(packageJson.devDependencies['@ngrx/schematics']).toEqual(
backwardCompatibleVersions.angularV15.ngrxVersion
backwardCompatibleVersions.angularV16.ngrxVersion
);
expect(packageJson.devDependencies['@ngrx/store-devtools']).toEqual(
backwardCompatibleVersions.angularV15.ngrxVersion
backwardCompatibleVersions.angularV16.ngrxVersion
);
expect(packageJson.devDependencies['jasmine-marbles']).toBeDefined();
});
Expand Down

This file was deleted.

14 changes: 1 addition & 13 deletions packages/angular/src/generators/setup-ssr/lib/generate-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
joinPathFragments,
readProjectConfiguration,
} from '@nx/devkit';
import { lt } from 'semver';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { Schema } from '../schema';

export function generateSSRFiles(
Expand All @@ -27,7 +25,6 @@ export function generateSSRFiles(
}

const pathToFiles = joinPathFragments(__dirname, '..', 'files');
const { version: angularVersion } = getInstalledAngularVersionInfo(tree);

if (schema.standalone) {
generateFiles(
Expand All @@ -39,18 +36,9 @@ export function generateSSRFiles(
} else {
generateFiles(
tree,
joinPathFragments(pathToFiles, 'ngmodule', 'base'),
joinPathFragments(pathToFiles, 'ngmodule'),
projectRoot,
{ ...schema, tpl: '' }
);

if (lt(angularVersion, '15.2.0')) {
generateFiles(
tree,
joinPathFragments(pathToFiles, 'ngmodule', 'pre-v15-2'),
projectRoot,
{ ...schema, tpl: '' }
);
}
}
}
1 change: 0 additions & 1 deletion packages/angular/src/generators/setup-ssr/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export * from './add-server-file';
export * from './generate-files';
export * from './generate-server-ts-config';
export * from './normalize-options';
export * from './update-app-module';
export * from './update-project-config';
export * from './validate-options';
export * from './add-hydration';
Expand Down
Loading