Skip to content

Commit

Permalink
chore(webpack): remove appIndexJs path and hard code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LeoMcA committed May 9, 2024
1 parent 2a92a56 commit 8a8e7f6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 27 deletions.
14 changes: 0 additions & 14 deletions client/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,13 @@ 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"),
appPath: resolveApp("."),
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"),
Expand Down
2 changes: 1 addition & 1 deletion client/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions client/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions client/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 8a8e7f6

Please sign in to comment.