refactor(compiler): remove dependency on fs-extra (#41445)

Currently, fs-extra is used to delete a directory recursively, but this is already available in native Node.JS. Hence, making this dependency redundant.

See: https://nodejs.org/docs/latest-v12.x/api/fs.html

PR Close #41445
This commit is contained in:
Alan Agius 2021-04-04 18:06:02 +02:00 committed by atscott
parent 44e7865698
commit 3a823abcc5
10 changed files with 4 additions and 31 deletions

View File

@ -84,7 +84,6 @@
"@types/convert-source-map": "^1.5.1",
"@types/diff": "^3.5.1",
"@types/events": "3.0.0",
"@types/fs-extra": "4.0.2",
"@types/hammerjs": "2.0.35",
"@types/inquirer": "^7.3.0",
"@types/jasmine": "3.5.10",
@ -121,7 +120,6 @@
"dependency-graph": "^0.7.2",
"diff": "^3.5.0",
"domino": "2.1.2",
"fs-extra": "4.0.2",
"google-closure-compiler": "20200517.0.0",
"hammerjs": "2.0.8",
"http-server": "^0.12.3",

View File

@ -41,7 +41,6 @@ ts_library(
"@npm//@bazel/typescript",
"@npm//@types/node",
"@npm//chokidar",
"@npm//fs-extra",
"@npm//minimist",
"@npm//reflect-metadata",
"@npm//tsickle",

View File

@ -31,7 +31,6 @@ nodejs_test(
"@nodejs//:node",
"@npm//domino",
"@npm//chokidar",
"@npm//fs-extra",
"@npm//source-map-support",
"@npm//shelljs",
"@npm//typescript",

View File

@ -46,7 +46,6 @@ const requiredNodeModules = {
'tslib': resolveNpmTreeArtifact('npm/node_modules/tslib'),
'domino': resolveNpmTreeArtifact('npm/node_modules/domino'),
'xhr2': resolveNpmTreeArtifact('npm/node_modules/xhr2'),
'fs-extra': resolveNpmTreeArtifact('npm/node_modules/fs-extra'),
// Fine grained dependencies which are used by the integration test Angular modules, and
// need to be symlinked so that they can be resolved by NodeJS or NGC.

View File

@ -19,7 +19,6 @@
"chokidar": "^3.0.0",
"convert-source-map": "^1.5.1",
"dependency-graph": "^0.7.2",
"fs-extra": "4.0.2",
"magic-string": "^0.25.0",
"semver": "^6.3.0",
"source-map": "^0.6.1",

View File

@ -8,9 +8,7 @@ ts_library(
"src/**/*.ts",
]),
deps = [
"@npm//@types/fs-extra",
"@npm//@types/node",
"@npm//fs-extra",
"@npm//typescript",
],
)

View File

@ -7,7 +7,6 @@
*/
/// <reference types="node" />
import * as fs from 'fs';
import * as fsExtra from 'fs-extra';
import * as p from 'path';
import {AbsoluteFsPath, FileStats, FileSystem, PathManipulation, PathSegment, PathString, ReadonlyFileSystem} from './types';
@ -121,7 +120,7 @@ export class NodeJSFileSystem extends NodeJSReadonlyFileSystem implements FileSy
}
}
removeDeep(path: AbsoluteFsPath): void {
fsExtra.removeSync(path);
fs.rmdirSync(path, {recursive: true});
}
private safeMkdir(path: AbsoluteFsPath): void {

View File

@ -11,7 +11,6 @@ ts_library(
deps = [
"//packages/compiler-cli/src/ngtsc/file_system",
"//packages/compiler-cli/src/ngtsc/file_system/testing",
"@npm//@types/fs-extra",
"@npm//typescript",
],
)

View File

@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import * as realFs from 'fs';
import * as fsExtra from 'fs-extra';
import * as os from 'os';
import {NodeJSFileSystem, NodeJSPathManipulation, NodeJSReadonlyFileSystem} from '../src/node_js_file_system';
import {AbsoluteFsPath, PathSegment} from '../src/types';
@ -269,10 +268,10 @@ describe('NodeJSFileSystem', () => {
});
describe('removeDeep()', () => {
it('should delegate to fsExtra.remove()', () => {
const spy = spyOn(fsExtra, 'removeSync');
it('should delegate to rmdirSync()', () => {
const spy = spyOn(realFs, 'rmdirSync');
fs.removeDeep(abcPath);
expect(spy).toHaveBeenCalledWith(abcPath);
expect(spy).toHaveBeenCalledWith(abcPath, {recursive: true});
});
});
});

View File

@ -2601,13 +2601,6 @@
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
"@types/fs-extra@4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-4.0.2.tgz#7b9b1bbf85962cbe029b5a83c9b530d7c75af3ba"
integrity sha512-Id1hnmfd+7G9K+jWz2syfMcpymx2mj6B1y4C72vAoYQzxOA79UhY/kNvOCyb9yYR1SoSaHyhwcYtWKKqUiLTZA==
dependencies:
"@types/node" "*"
"@types/fs-extra@^8.0.1":
version "8.1.0"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-8.1.0.tgz#1114834b53c3914806cd03b3304b37b3bd221a4d"
@ -7528,15 +7521,6 @@ fs-constants@^1.0.0:
resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
fs-extra@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.2.tgz#f91704c53d1b461f893452b0c307d9997647ab6b"
integrity sha1-+RcExT0bRh+JNFKwwwfZmXZHq2s=
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"
fs-extra@^0.23.1:
version "0.23.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.23.1.tgz#6611dba6adf2ab8dc9c69fab37cddf8818157e3d"