Skip to content

Commit c55782b

Browse files
committed
chore: clean up unused code
1 parent 7594d00 commit c55782b

3 files changed

Lines changed: 23 additions & 42 deletions

File tree

‎packages/webpack5/src/configuration/angular.ts‎

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { resolve, dirname } from 'path';
21
import Config from 'webpack-chain';
32
import { existsSync } from 'fs';
4-
import get from 'lodash.get';
53

6-
import { getProjectFilePath, getProjectRootPath } from '../helpers/project';
7-
import { getEntryPath, getPlatformName } from '../helpers/platform';
4+
import { getProjectFilePath } from '../helpers/project';
85
import { env as _env, IWebpackEnv } from '../index';
6+
import { getEntryPath } from '../helpers/platform';
97
import base from './base';
108

119
export default function (config: Config, env: IWebpackEnv = _env): Config {
@@ -59,37 +57,3 @@ function getAngularCompilerPlugin() {
5957
const { AngularCompilerPlugin } = require('@ngtools/webpack');
6058
return AngularCompilerPlugin;
6159
}
62-
63-
// todo: move into project helper if used elsewhere
64-
// todo: write tests
65-
function findFile(fileName, currentDir): string | null {
66-
// console.log(`findFile(${fileName}, ${currentDir})`)
67-
const path = resolve(currentDir, fileName);
68-
69-
if (existsSync(path)) {
70-
return path;
71-
}
72-
73-
// bail if we reached the root dir
74-
if (currentDir === resolve('/')) {
75-
return null;
76-
}
77-
78-
// traverse to the parent folder
79-
return findFile(fileName, resolve(currentDir, '..'));
80-
}
81-
82-
function findWorkspaceConfig(): string {
83-
const possibleConfigNames = ['angular.json', 'workspace.json'];
84-
85-
for (const name of possibleConfigNames) {
86-
const path = findFile(name, getProjectRootPath());
87-
88-
if (path) {
89-
return path;
90-
}
91-
}
92-
93-
// not found
94-
return null;
95-
}

‎packages/webpack5/src/configuration/base.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import TerserPlugin from 'terser-webpack-plugin';
99

1010
import { getProjectFilePath, getProjectRootPath } from '../helpers/project';
1111
import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin';
12+
import { applyFileReplacements } from '../helpers/fileReplacements';
1213
import { addCopyRule, applyCopyRules } from '../helpers/copyRules';
1314
import { WatchStatePlugin } from '../plugins/WatchStatePlugin';
1415
import { hasDependency } from '../helpers/dependencies';
1516
import { applyDotEnvPlugin } from '../helpers/dotEnv';
1617
import { env as _env, IWebpackEnv } from '../index';
1718
import { getIPS } from '../helpers/host';
18-
import { applyFileReplacements } from '../helpers/fileReplacements';
1919
import {
2020
getPlatformName,
2121
getAbsoluteDistPath,

‎packages/webpack5/src/helpers/project.ts‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ interface IPackageJson {
1919
* Utility function to get the contents of the project package.json
2020
*/
2121
export function getPackageJson() {
22-
return require(
23-
getProjectFilePath('package.json')
24-
) as IPackageJson;
22+
return require(getProjectFilePath('package.json')) as IPackageJson;
2523
}
2624

2725
/**
@@ -31,3 +29,22 @@ export function getPackageJson() {
3129
export function getProjectFilePath(filePath: string): string {
3230
return resolve(getProjectRootPath(), filePath);
3331
}
32+
33+
// unused helper, but keeping it here as we may need it
34+
// todo: remove if unused for next few releases
35+
// function findFile(fileName, currentDir): string | null {
36+
// // console.log(`findFile(${fileName}, ${currentDir})`)
37+
// const path = resolve(currentDir, fileName);
38+
//
39+
// if (existsSync(path)) {
40+
// return path;
41+
// }
42+
//
43+
// // bail if we reached the root dir
44+
// if (currentDir === resolve('/')) {
45+
// return null;
46+
// }
47+
//
48+
// // traverse to the parent folder
49+
// return findFile(fileName, resolve(currentDir, '..'));
50+
// }

0 commit comments

Comments
 (0)