From 8a8e7f6f39c895dfb581abcbaf827ebe52d1c778 Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Thu, 9 May 2024 15:24:51 +0000 Subject: [PATCH] chore(webpack): remove appIndexJs path and hard code remove checks that abort the build if this file doesn't exist - the build fails anyway if this or the appHtml path doesn't exist --- client/config/paths.js | 14 -------------- client/config/webpack.config.js | 2 +- client/scripts/build.js | 6 ------ client/scripts/start.js | 6 ------ 4 files changed, 1 insertion(+), 27 deletions(-) diff --git a/client/config/paths.js b/client/config/paths.js index 6d6de4cf6014..37ee9d40188d 100644 --- a/client/config/paths.js +++ b/client/config/paths.js @@ -26,19 +26,6 @@ const buildPath = process.env.BUILD_PATH || "build"; const moduleFileExtensions = ["mjs", "js", "ts", "tsx", "json", "jsx"]; -// Resolve file paths in the same order as webpack -const resolveModule = (resolveFn, filePath) => { - const extension = moduleFileExtensions.find((extension) => - fs.existsSync(resolveFn(`${filePath}.${extension}`)) - ); - - if (extension) { - return resolveFn(`${filePath}.${extension}`); - } - - return resolveFn(`${filePath}.js`); -}; - // config after eject: we're in ./config/ const config = { dotenv: resolveApp("../.env"), @@ -46,7 +33,6 @@ const config = { appBuild: resolveApp(buildPath), appPublic: resolveApp("public"), appHtml: resolveApp("public/index.html"), - appIndexJs: resolveModule(resolveApp, "src/index"), appPackageJson: resolveApp("../package.json"), appSrc: resolveApp("src"), appTsConfig: resolveApp("tsconfig.json"), diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index 7436b4bff215..351491e4cfff 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -158,7 +158,7 @@ function config(webpackEnv) { : isEnvDevelopment && "cheap-module-source-map", // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. - entry: paths.appIndexJs, + entry: "./src/index.tsx", output: { // The build folder. path: paths.appBuild, diff --git a/client/scripts/build.js b/client/scripts/build.js index a3ce6e071b91..0bfd8504997e 100644 --- a/client/scripts/build.js +++ b/client/scripts/build.js @@ -7,7 +7,6 @@ import fs from "fs-extra"; import bfj from "bfj"; import webpack from "webpack"; import { checkBrowsers } from "react-dev-utils/browsersHelper.js"; -import checkRequiredFiles from "react-dev-utils/checkRequiredFiles.js"; import formatWebpackMessages from "react-dev-utils/formatWebpackMessages.js"; import printHostingInstructions from "react-dev-utils/printHostingInstructions.js"; import FileSizeReporter from "react-dev-utils/FileSizeReporter.js"; @@ -37,11 +36,6 @@ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024; const isInteractive = process.stdout.isTTY; -// Warn and crash if required files are missing -if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { - process.exit(1); -} - const argv = process.argv.slice(2); const writeStatsJson = argv.indexOf("--stats") !== -1; diff --git a/client/scripts/start.js b/client/scripts/start.js index 91f825a93d0e..a4949f991325 100644 --- a/client/scripts/start.js +++ b/client/scripts/start.js @@ -6,7 +6,6 @@ import chalk from "react-dev-utils/chalk.js"; import webpack from "webpack"; import WebpackDevServer from "webpack-dev-server"; import clearConsole from "react-dev-utils/clearConsole.js"; -import checkRequiredFiles from "react-dev-utils/checkRequiredFiles.js"; import { checkBrowsers } from "react-dev-utils/browsersHelper.js"; import { choosePort, @@ -36,11 +35,6 @@ const env = getClientEnvironment(paths.publicUrlOrPath.replace(/\/$/, "")); const useYarn = fs.existsSync(paths.yarnLockFile); const isInteractive = process.stdout.isTTY; -// Warn and crash if required files are missing -if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { - process.exit(1); -} - // Tools like Cloud9 rely on this. const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; const HOST = process.env.HOST || "0.0.0.0";