From c55782bfaff0b026b66c09dc257daa2ec1a92bb2 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Mon, 29 Mar 2021 01:20:43 +0200 Subject: [PATCH] chore: clean up unused code --- .../webpack5/src/configuration/angular.ts | 40 +------------------ packages/webpack5/src/configuration/base.ts | 2 +- packages/webpack5/src/helpers/project.ts | 23 +++++++++-- 3 files changed, 23 insertions(+), 42 deletions(-) diff --git a/packages/webpack5/src/configuration/angular.ts b/packages/webpack5/src/configuration/angular.ts index d8b4f4c24..c525b72a1 100644 --- a/packages/webpack5/src/configuration/angular.ts +++ b/packages/webpack5/src/configuration/angular.ts @@ -1,11 +1,9 @@ -import { resolve, dirname } from 'path'; import Config from 'webpack-chain'; import { existsSync } from 'fs'; -import get from 'lodash.get'; -import { getProjectFilePath, getProjectRootPath } from '../helpers/project'; -import { getEntryPath, getPlatformName } from '../helpers/platform'; +import { getProjectFilePath } from '../helpers/project'; import { env as _env, IWebpackEnv } from '../index'; +import { getEntryPath } from '../helpers/platform'; import base from './base'; export default function (config: Config, env: IWebpackEnv = _env): Config { @@ -59,37 +57,3 @@ function getAngularCompilerPlugin() { const { AngularCompilerPlugin } = require('@ngtools/webpack'); return AngularCompilerPlugin; } - -// todo: move into project helper if used elsewhere -// todo: write tests -function findFile(fileName, currentDir): string | null { - // console.log(`findFile(${fileName}, ${currentDir})`) - const path = resolve(currentDir, fileName); - - if (existsSync(path)) { - return path; - } - - // bail if we reached the root dir - if (currentDir === resolve('/')) { - return null; - } - - // traverse to the parent folder - return findFile(fileName, resolve(currentDir, '..')); -} - -function findWorkspaceConfig(): string { - const possibleConfigNames = ['angular.json', 'workspace.json']; - - for (const name of possibleConfigNames) { - const path = findFile(name, getProjectRootPath()); - - if (path) { - return path; - } - } - - // not found - return null; -} diff --git a/packages/webpack5/src/configuration/base.ts b/packages/webpack5/src/configuration/base.ts index 5bc7773cf..cf9d8a8eb 100644 --- a/packages/webpack5/src/configuration/base.ts +++ b/packages/webpack5/src/configuration/base.ts @@ -9,13 +9,13 @@ import TerserPlugin from 'terser-webpack-plugin'; import { getProjectFilePath, getProjectRootPath } from '../helpers/project'; import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin'; +import { applyFileReplacements } from '../helpers/fileReplacements'; import { addCopyRule, applyCopyRules } from '../helpers/copyRules'; import { WatchStatePlugin } from '../plugins/WatchStatePlugin'; import { hasDependency } from '../helpers/dependencies'; import { applyDotEnvPlugin } from '../helpers/dotEnv'; import { env as _env, IWebpackEnv } from '../index'; import { getIPS } from '../helpers/host'; -import { applyFileReplacements } from '../helpers/fileReplacements'; import { getPlatformName, getAbsoluteDistPath, diff --git a/packages/webpack5/src/helpers/project.ts b/packages/webpack5/src/helpers/project.ts index b12b07691..494735090 100644 --- a/packages/webpack5/src/helpers/project.ts +++ b/packages/webpack5/src/helpers/project.ts @@ -19,9 +19,7 @@ interface IPackageJson { * Utility function to get the contents of the project package.json */ export function getPackageJson() { - return require( - getProjectFilePath('package.json') - ) as IPackageJson; + return require(getProjectFilePath('package.json')) as IPackageJson; } /** @@ -31,3 +29,22 @@ export function getPackageJson() { export function getProjectFilePath(filePath: string): string { return resolve(getProjectRootPath(), filePath); } + +// unused helper, but keeping it here as we may need it +// todo: remove if unused for next few releases +// function findFile(fileName, currentDir): string | null { +// // console.log(`findFile(${fileName}, ${currentDir})`) +// const path = resolve(currentDir, fileName); +// +// if (existsSync(path)) { +// return path; +// } +// +// // bail if we reached the root dir +// if (currentDir === resolve('/')) { +// return null; +// } +// +// // traverse to the parent folder +// return findFile(fileName, resolve(currentDir, '..')); +// }