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

fix(angular): do not use ngcc for new workspaces and projects #12386 #12504

Merged
merged 1 commit into from Oct 11, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions docs/generated/packages/angular.json
Expand Up @@ -170,11 +170,6 @@
"default": false,
"description": "Do not add dependencies to `package.json`."
},
"skipPostInstall": {
"type": "boolean",
"default": false,
"description": "Do not add or append `ngcc` to the `postinstall` script in `package.json`."
},
"unitTestRunner": {
"type": "string",
"enum": ["karma", "jest", "none"],
Expand Down Expand Up @@ -718,11 +713,6 @@
"type": "boolean",
"default": false,
"description": "Do not add dependencies to `package.json`."
},
"skipPostInstall": {
"type": "boolean",
"default": false,
"description": "Do not add or append `ngcc` to the `postinstall` script in `package.json`."
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -863,11 +853,6 @@
"default": false,
"description": "Do not add dependencies to `package.json`."
},
"skipPostInstall": {
"type": "boolean",
"default": false,
"description": "Do not add or append `ngcc` to the `postinstall` script in `package.json`."
},
"skipTsConfig": {
"type": "boolean",
"default": false,
Expand Down
1 change: 0 additions & 1 deletion packages/angular/src/generators/application/schema.d.ts
Expand Up @@ -24,7 +24,6 @@ export interface Schema {
port?: number;
setParserOptionsProject?: boolean;
skipPackageJson?: boolean;
skipPostInstall?: boolean;
skipDefaultProject?: boolean;
standalone?: boolean;
}
5 changes: 0 additions & 5 deletions packages/angular/src/generators/application/schema.json
Expand Up @@ -93,11 +93,6 @@
"default": false,
"description": "Do not add dependencies to `package.json`."
},
"skipPostInstall": {
"type": "boolean",
"default": false,
"description": "Do not add or append `ngcc` to the `postinstall` script in `package.json`."
},
"unitTestRunner": {
"type": "string",
"enum": ["karma", "jest", "none"],
Expand Down
32 changes: 0 additions & 32 deletions packages/angular/src/generators/init/init.spec.ts
Expand Up @@ -4,7 +4,6 @@ import { Linter } from '@nrwl/linter';

import init from './init';
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
import { Styles } from '../utils/types';

describe('init', () => {
let host: Tree;
Expand Down Expand Up @@ -42,37 +41,6 @@ describe('init', () => {
expect(devDependencies['codelyzer']).toBeUndefined();
});

it('should add a postinstall script for ngcc by default', async () => {
// ACT
await init(host, {
unitTestRunner: UnitTestRunner.Karma,
linter: Linter.EsLint,
skipFormat: false,
});

const packageJson = readJson(host, 'package.json');

// ASSERT
expect(packageJson.scripts.postinstall).toEqual(
'ngcc --properties es2020 browser module main'
);
});

it('should not add a postinstall script for ngcc if skipPostInstall=true', async () => {
// ACT
await init(host, {
unitTestRunner: UnitTestRunner.Karma,
linter: Linter.EsLint,
skipFormat: false,
skipPostInstall: true,
});

const packageJson = readJson(host, 'package.json');

// ASSERT
expect(packageJson?.scripts?.postinstall).toBeFalsy();
});

describe('--unit-test-runner', () => {
describe('karma', () => {
it('should add karma dependencies', async () => {
Expand Down
35 changes: 9 additions & 26 deletions packages/angular/src/generators/init/init.ts
@@ -1,29 +1,30 @@
import { cypressInitGenerator } from '@nrwl/cypress';
import { GeneratorCallback, logger, Tree } from '@nrwl/devkit';
import {
addDependenciesToPackageJson,
formatFiles,
GeneratorCallback,
logger,
readWorkspaceConfiguration,
updateJson,
Tree,
updateWorkspaceConfiguration,
} from '@nrwl/devkit';
import { jestInitGenerator } from '@nrwl/jest';
import { Linter } from '@nrwl/linter';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { E2eTestRunner, UnitTestRunner } from '../../utils/test-runners';
import {
angularVersion,
angularDevkitVersion,
angularVersion,
jasmineCoreVersion,
jasmineSpecReporterVersion,
jestPresetAngularVersion,
protractorVersion,
rxjsVersion,
tsNodeVersion,
tsLibVersion,
zoneJsVersion,
protractorVersion,
jasmineCoreVersion,
jasmineSpecReporterVersion,
tsNodeVersion,
typesJasmineVersion,
typesJasminewd2Version,
zoneJsVersion,
} from '../../utils/versions';
import { karmaGenerator } from '../karma/karma';
import { Schema } from './schema';
Expand All @@ -35,10 +36,6 @@ export async function angularInitGenerator(
const options = normalizeOptions(rawOptions);
setDefaults(host, options);

if (!options.skipPostInstall) {
addPostInstall(host);
}

const depsTask = !options.skipPackageJson
? updateDependencies(host)
: () => {};
Expand All @@ -59,7 +56,6 @@ function normalizeOptions(options: Schema): Required<Schema> {
linter: options.linter ?? Linter.EsLint,
skipFormat: options.skipFormat ?? false,
skipInstall: options.skipInstall ?? false,
skipPostInstall: options.skipPostInstall ?? false,
skipPackageJson: options.skipPackageJson ?? false,
style: options.style ?? 'css',
unitTestRunner: options.unitTestRunner ?? UnitTestRunner.Jest,
Expand Down Expand Up @@ -90,19 +86,6 @@ function setDefaults(host: Tree, options: Schema) {
updateWorkspaceConfiguration(host, workspace);
}

function addPostInstall(host: Tree) {
updateJson(host, 'package.json', (pkgJson) => {
pkgJson.scripts = pkgJson.scripts ?? {};
const command = 'ngcc --properties es2020 browser module main';
if (!pkgJson.scripts.postinstall) {
pkgJson.scripts.postinstall = command;
} else if (!pkgJson.scripts.postinstall.includes('ngcc')) {
pkgJson.scripts.postinstall = `${pkgJson.scripts.postinstall} && ${command}`;
}
return pkgJson;
});
}

function updateDependencies(host: Tree): GeneratorCallback {
return addDependenciesToPackageJson(
host,
Expand Down
1 change: 0 additions & 1 deletion packages/angular/src/generators/init/schema.d.ts
Expand Up @@ -10,5 +10,4 @@ export interface Schema {
style?: Styles;
linter?: Linter;
skipPackageJson?: boolean;
skipPostInstall?: boolean;
}
5 changes: 0 additions & 5 deletions packages/angular/src/generators/init/schema.json
Expand Up @@ -72,11 +72,6 @@
"type": "boolean",
"default": false,
"description": "Do not add dependencies to `package.json`."
},
"skipPostInstall": {
"type": "boolean",
"default": false,
"description": "Do not add or append `ngcc` to the `postinstall` script in `package.json`."
}
},
"additionalProperties": false
Expand Down
1 change: 0 additions & 1 deletion packages/angular/src/generators/library/schema.d.ts
Expand Up @@ -28,7 +28,6 @@ export interface Schema {
setParserOptionsProject?: boolean;
skipModule?: boolean;
skipPackageJson?: boolean;
skipPostInstall?: boolean;
standalone?: boolean;
displayBlock?: boolean;
inlineStyle?: boolean;
Expand Down
5 changes: 0 additions & 5 deletions packages/angular/src/generators/library/schema.json
Expand Up @@ -57,11 +57,6 @@
"default": false,
"description": "Do not add dependencies to `package.json`."
},
"skipPostInstall": {
"type": "boolean",
"default": false,
"description": "Do not add or append `ngcc` to the `postinstall` script in `package.json`."
},
"skipTsConfig": {
"type": "boolean",
"default": false,
Expand Down