Skip to content

Commit

Permalink
fix(@schematics/angular): remove @types/node from new projects
Browse files Browse the repository at this point in the history
The `@types/node` package is now only added if E2E tests (`ng generate e2e`) or universal are added to a project.
  • Loading branch information
clydin committed Mar 16, 2022
1 parent cf04d00 commit c927c03
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/schematics/angular/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from '@angular-devkit/schematics';
import { NodeDependencyType, addPackageJsonDependency } from '../utility/dependencies';
import { JSONFile } from '../utility/json-file';
import { latestVersions } from '../utility/latest-versions';
import { relativePathToWorkspaceRoot } from '../utility/paths';
import { getWorkspace, updateWorkspace } from '../utility/workspace';
import { Builders } from '../utility/workspace-models';
Expand Down Expand Up @@ -93,6 +94,11 @@ export default function (options: E2eOptions): Rule {
name: 'ts-node',
version: '~9.1.1',
},
{
type: NodeDependencyType.Dev,
name: '@types/node',
version: latestVersions['@types/node'],
},
].forEach((dep) => addPackageJsonDependency(host, dep)),
addScriptsToPackageJson(),
]);
Expand Down
13 changes: 11 additions & 2 deletions packages/schematics/angular/universal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript';
import { findNode, getDecoratorMetadata } from '../utility/ast-utils';
import { InsertChange } from '../utility/change';
import { addPackageJsonDependency, getPackageJsonDependency } from '../utility/dependencies';
import {
NodeDependencyType,
addPackageJsonDependency,
getPackageJsonDependency,
} from '../utility/dependencies';
import { latestVersions } from '../utility/latest-versions';
import { findBootstrapModuleCall, findBootstrapModulePath } from '../utility/ng-ast-utils';
import { relativePathToWorkspaceRoot } from '../utility/paths';
import { targetBuildNotFoundError } from '../utility/project-targets';
Expand Down Expand Up @@ -226,7 +231,11 @@ function addDependencies(): Rule {
};
addPackageJsonDependency(host, platformServerDep);

return host;
addPackageJsonDependency(host, {
type: NodeDependencyType.Dev,
name: '@types/node',
version: latestVersions['@types/node'],
});
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"devDependencies": {
"@angular/cli": "<%= '~' + version %>",
"@angular/compiler-cli": "<%= latestVersions.Angular %>",<% if (!minimal) { %>
"@types/jasmine": "<%= latestVersions['@types/jasmine'] %>",<% } %>
"@types/node": "<%= latestVersions['@types/node'] %>",<% if (!minimal) { %>
"@types/jasmine": "<%= latestVersions['@types/jasmine'] %>",
"jasmine-core": "<%= latestVersions['jasmine-core'] %>",
"karma": "<%= latestVersions['karma'] %>",
"karma-chrome-launcher": "<%= latestVersions['karma-chrome-launcher'] %>",
Expand Down

0 comments on commit c927c03

Please sign in to comment.