Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade react scripts #507

Merged
merged 13 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GENERATE_SOURCEMAP=false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it mean local server and/or test stands won't have source maps?

Copy link
Contributor Author

@vipineth vipineth Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is set for production.

From docs:

When set to false, source maps are not generated for a production build. This solves out of memory (OOM) issues on some smaller machines.

https://create-react-app.dev/docs/advanced-configuration/

Active PR for the issue: facebook/create-react-app#11752

29 changes: 29 additions & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const webpack = require("webpack");

module.exports = function override(config) {
// https://github.com/lingui/js-lingui/issues/1195
// Adding loader to use for .po files to webpack
const loaders = config.module.rules.find((rule) => Array.isArray(rule.oneOf));
loaders.oneOf.splice(loaders.length - 1, 0, {
test: /\.po/,
use: [
{
loader: "@lingui/loader",
},
],
});

config.resolve.fallback = {
os: false,
http: false,
https: false,
stream: false,
crypto: false,
};
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
]);
return config;
};
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@types/react-dom": "18.0.6",
"@types/react-router-dom": "5.3.3",
"@uniswap/sdk-core": "3.0.1",
"@uniswap/v3-sdk": "3.7.1",
"@uniswap/v3-sdk": "3.9.0",
"@web3-react/core": "6.1.9",
"@web3-react/injected-connector": "6.0.7",
"@web3-react/walletconnect-connector": "6.2.8",
Expand All @@ -44,7 +44,7 @@
"react-icons": "4.3.1",
"react-remove-scroll": "2.5.5",
"react-router-dom": "5.3.0",
"react-scripts": "4.0.3",
"react-scripts": "5.0.1",
"react-select": "5.2.1",
"react-tabs": "3.2.3",
"react-toastify": "6.0.9",
Expand All @@ -59,15 +59,15 @@
"react-error-overlay": "6.0.9"
},
"scripts": {
"start": "PORT=3010 react-scripts start",
"start-home": "yarn lingui:prepare && PORT=3010 env-cmd -e development-home react-scripts start",
"start-app": "yarn lingui:prepare && PORT=3011 env-cmd -e development-app react-scripts start",
"start-win": "set PORT=3010&react-scripts start",
"build": "INLINE_RUNTIME_CHUNK=false yarn test:ci && react-scripts build",
"build-home": "INLINE_RUNTIME_CHUNK=false env-cmd -e production-home react-scripts build",
"build-app": "INLINE_RUNTIME_CHUNK=false env-cmd -e production-app yarn test:ci && react-scripts build",
"test": "react-scripts test",
"test:ci": "react-scripts test --watchAll=false",
"start": "PORT=3010 react-app-rewired start",
"start-home": "yarn lingui:prepare && PORT=3010 env-cmd -e development-home react-app-rewired start",
"start-app": "yarn lingui:prepare && PORT=3011 env-cmd -e development-app react-app-rewired start",
"start-win": "set PORT=3010&react-app-rewired start",
"build": "INLINE_RUNTIME_CHUNK=false yarn test:ci && react-app-rewired build",
"build-home": "INLINE_RUNTIME_CHUNK=false env-cmd -e production-home react-app-rewired build",
"build-app": "INLINE_RUNTIME_CHUNK=false env-cmd -e production-app yarn test:ci && react-app-rewired build",
"test": "react-app-rewired test",
"test:ci": "react-app-rewired test --watchAll=false",
"eject": "react-scripts eject",
"lint": "node node_modules/.bin/eslint src",
"pre-commit": "npm run test -- --watchAll=false && npm run lint",
Expand Down Expand Up @@ -100,13 +100,16 @@
]
},
"devDependencies": {
"@lingui/cli": "^3.13.3",
"@lingui/loader": "3.14.0",
"@lingui/cli": "3.13.3",
"@lingui/loader": "3.13.3",
"@lingui/macro": "3.13.3",
"eslint": "7.32.0",
"buffer": "6.0.3",
"eslint": "^8.41.0",
"eslint-config-react-app": "^7.0.1",
"husky": "7.0.4",
"lint-staged": "12.3.4",
"prettier": "2.5.1"
"prettier": "2.5.1",
"react-app-rewired": "2.2.1"
},
"lint-staged": {
"src/**/*.{js,ts,jsx,tsx}": [
Expand Down
4 changes: 1 addition & 3 deletions src/components/Exchange/FeesTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { i18n } from "@lingui/core";
import { t, Trans } from "@lingui/macro";
import ExternalLink from "components/ExternalLink/ExternalLink";
import StatsTooltipRow from "components/StatsTooltip/StatsTooltipRow";
Expand All @@ -22,8 +21,7 @@ function getFeeLabel(type: FeeType) {
deposit: t`Deposit Fee`,
execution: t`Execution Fee`,
};

return i18n._(labels[type]);
return labels[type];
}

function getExecutionFeeStr(chainId, executionFee, executionFeeUsd) {
Expand Down
17 changes: 8 additions & 9 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NavLink } from "react-router-dom";
import { isHomeSite, getAppBaseUrl, shouldShowRedirectModal } from "lib/legacy";
import { getFooterLinks, SOCIAL_LINKS } from "./constants";
import ExternalLink from "components/ExternalLink/ExternalLink";
import { i18n } from "@lingui/core";

type Props = { showRedirectModal?: (to: string) => void; redirectPopupTimestamp?: () => void };

Expand All @@ -29,37 +28,37 @@ export default function Footer({ showRedirectModal, redirectPopupTimestamp }: Pr
})}
</div>
<div className="Footer-links">
{getFooterLinks(isHome).map(({ external, text, link, isAppLink }) => {
{getFooterLinks(isHome).map(({ external, label, link, isAppLink }) => {
if (external) {
return (
<ExternalLink key={i18n._(text)} href={link} className="Footer-link">
{i18n._(text)}
<ExternalLink key={label} href={link} className="Footer-link">
{label}
</ExternalLink>
);
}
if (isAppLink) {
if (shouldShowRedirectModal(redirectPopupTimestamp)) {
return (
<div
key={i18n._(text)}
key={label}
className="Footer-link a"
onClick={() => showRedirectModal && showRedirectModal(link)}
>
{i18n._(text)}
{label}
</div>
);
} else {
const baseUrl = getAppBaseUrl();
return (
<a key={i18n._(text)} href={baseUrl + link} className="Footer-link">
{i18n._(text)}
<a key={label} href={baseUrl + link} className="Footer-link">
{label}
</a>
);
}
}
return (
<NavLink key={link} to={link} className="Footer-link" activeClassName="active">
{i18n._(text)}
{label}
</NavLink>
);
})}
Expand Down
30 changes: 14 additions & 16 deletions src/components/Footer/constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { defineMessage } from "@lingui/macro";
import { t } from "@lingui/macro";
import "./Footer.css";
import twitterIcon from "img/ic_twitter.svg";
import discordIcon from "img/ic_discord.svg";
import telegramIcon from "img/ic_telegram.svg";
import githubIcon from "img/ic_github.svg";
import substackIcon from "img/ic_substack.svg";
import { MessageDescriptor } from "@lingui/core";

type Link = {
text: MessageDescriptor;
label: string;
link: string;
external?: boolean;
isAppLink?: boolean;
Expand All @@ -20,20 +19,19 @@ type SocialLink = {
icon: string;
};

export const FOOTER_LINKS: { home: Link[]; app: Link[] } = {
home: [
{ text: defineMessage({ message: "Terms and Conditions" }), link: "/terms-and-conditions" },
{ text: defineMessage({ message: "Referral Terms" }), link: "/referral-terms" },
{ text: defineMessage({ message: "Media Kit" }), link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { text: "Jobs", link: "/jobs", isAppLink: true },
],
app: [
{ text: defineMessage({ message: "Media Kit" }), link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { text: "Jobs", link: "/jobs" },
],
};

export function getFooterLinks(isHome) {
const FOOTER_LINKS: { home: Link[]; app: Link[] } = {
home: [
{ label: t`Terms and Conditions`, link: "/terms-and-conditions" },
{ label: t`Referral Terms`, link: "/referral-terms" },
{ label: t`Media Kit`, link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { label: "Jobs", link: "/jobs", isAppLink: true },
],
app: [
{ label: t`Media Kit`, link: "https://gmxio.gitbook.io/gmx/media-kit", external: true },
// { label: "Jobs", link: "/jobs" },
],
};
return FOOTER_LINKS[isHome ? "home" : "app"];
}

Expand Down
47 changes: 23 additions & 24 deletions src/components/Header/HomeHeaderLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,30 @@ type Props = {

type HomeLink = { label: string; link: string; isHomeLink?: boolean | false };

const HOME_MENUS: HomeLink[] = [
{
label: t`App`,
isHomeLink: true,
link: "/trade",
},
{
label: t`Protocol`,
link: "https://github.com/gmx-io",
},
{
label: t`Governance`,
link: "https://gov.gmx.io/",
},
{
label: t`Voting`,
link: "https://snapshot.org/#/gmx.eth",
},
{
label: t`Docs`,
link: "https://gmxio.gitbook.io/gmx/",
},
];

export function HomeHeaderLinks({ small, clickCloseIcon, redirectPopupTimestamp, showRedirectModal }: Props) {
const HOME_MENUS: HomeLink[] = [
{
label: t`App`,
isHomeLink: true,
link: "/trade",
},
{
label: t`Protocol`,
link: "https://github.com/gmx-io",
},
{
label: t`Governance`,
link: "https://gov.gmx.io/",
},
{
label: t`Voting`,
link: "https://snapshot.org/#/gmx.eth",
},
{
label: t`Docs`,
link: "https://gmxio.gitbook.io/gmx/",
},
];
return (
<div className="App-header-links">
{small && (
Expand Down
4 changes: 2 additions & 2 deletions src/lib/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ export function getTradePageUrl() {
}

export function importImage(name) {
let tokenImage: { default: string } | null = null;
let tokenImage = "";

try {
tokenImage = require("img/" + name);
Expand All @@ -1466,7 +1466,7 @@ export function importImage(name) {
console.error(error);
}

return tokenImage?.default;
return tokenImage;
}

export function getTwitterIntentURL(text, url = "", hashtag = "") {
Expand Down
6 changes: 3 additions & 3 deletions src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ msgstr "Ankündigung"

#: src/components/Header/HomeHeaderLinks.tsx
msgid "App"
msgstr ""
msgstr "App"

#: src/domain/tokens/approveTokens.tsx
msgid "Approval failed"
Expand Down Expand Up @@ -1079,7 +1079,7 @@ msgstr "Verteilung"
#: src/components/Header/AppHeaderLinks.tsx
#: src/components/Header/HomeHeaderLinks.tsx
msgid "Docs"
msgstr ""
msgstr "Dokumente"

#: src/components/ModalViews/RedirectModal.js
msgid "Don't show this message again for 30 days."
Expand Down Expand Up @@ -1515,7 +1515,7 @@ msgstr ""

#: src/components/Header/HomeHeaderLinks.tsx
msgid "Governance"
msgstr ""
msgstr "Governance"

#: src/components/Exchange/SwapBox.js
msgid "High Slippage, Swap Anyway"
Expand Down
6 changes: 3 additions & 3 deletions src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ msgstr "Anuncio"

#: src/components/Header/HomeHeaderLinks.tsx
msgid "App"
msgstr ""
msgstr "Aplicación"

#: src/domain/tokens/approveTokens.tsx
msgid "Approval failed"
Expand Down Expand Up @@ -1079,7 +1079,7 @@ msgstr "Distribución"
#: src/components/Header/AppHeaderLinks.tsx
#: src/components/Header/HomeHeaderLinks.tsx
msgid "Docs"
msgstr ""
msgstr "Documentos"

#: src/components/ModalViews/RedirectModal.js
msgid "Don't show this message again for 30 days."
Expand Down Expand Up @@ -1515,7 +1515,7 @@ msgstr ""

#: src/components/Header/HomeHeaderLinks.tsx
msgid "Governance"
msgstr ""
msgstr "Gobernanza"

#: src/components/Exchange/SwapBox.js
msgid "High Slippage, Swap Anyway"
Expand Down
6 changes: 3 additions & 3 deletions src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ msgstr "Annonce"

#: src/components/Header/HomeHeaderLinks.tsx
msgid "App"
msgstr ""
msgstr "Application"

#: src/domain/tokens/approveTokens.tsx
msgid "Approval failed"
Expand Down Expand Up @@ -1079,7 +1079,7 @@ msgstr "Distribution"
#: src/components/Header/AppHeaderLinks.tsx
#: src/components/Header/HomeHeaderLinks.tsx
msgid "Docs"
msgstr ""
msgstr "Documents"

#: src/components/ModalViews/RedirectModal.js
msgid "Don't show this message again for 30 days."
Expand Down Expand Up @@ -1515,7 +1515,7 @@ msgstr ""

#: src/components/Header/HomeHeaderLinks.tsx
msgid "Governance"
msgstr ""
msgstr "Gouvernance"

#: src/components/Exchange/SwapBox.js
msgid "High Slippage, Swap Anyway"
Expand Down
Loading