Skip to content

Commit

Permalink
[Dashboard] Fix: Memory optimizations to reduce build failures (#5903)
Browse files Browse the repository at this point in the history
See https://nextjs.org/docs/app/building-your-application/optimizing/memory-usage#disable-webpack-cache

<!-- start pr-codex -->

---

## PR-Codex overview
This PR introduces optimizations to the webpack configuration and modifies several components to improve performance and fix TypeScript errors.

### Detailed summary
- Added `webpackMemoryOptimizations` to `experimental` in `next.config.ts`.
- Simplified `webpack` function by removing `dev` parameter.
- Changed cache type to `memory` in `next.config.ts`.
- Updated `abi-selector.tsx` to remove TypeScript error comments.
- Enhanced `ApplyForOpCreditsForm.tsx` by streamlining `onChange` handling.
- Modified `MarkdownRenderer` to handle optional `href` and added TypeScript error comments for future fixes.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
gregfromstl committed Jan 7, 2025
1 parent c06ecda commit ddb6af1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
8 changes: 6 additions & 2 deletions apps/dashboard/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,18 @@ function getConfig(): NextConfig {
...baseNextConfig,
experimental: {
webpackBuildWorker: true,
webpackMemoryOptimizations: true,
},
// @ts-expect-error - this is a valid option
webpack: (config, { dev }) => {
if (config.cache && !dev) {
webpack: (config) => {
if (config.cache) {
config.cache = Object.freeze({
type: "filesystem",
maxMemoryGenerations: 0,
});
config.cache = Object.freeze({
type: "memory",
});
}
config.externals.push("pino-pretty");
config.module = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ export const AbiSelector: React.FC<AbiSelectorProps> = ({
options={options}
defaultValue={options.find((o) => o.value === defaultValue)}
chakraStyles={{
// @ts-expect-error - this works fine
container: (provided) => ({
...provided,
width: "full",
}),
}}
value={options.find((o) => o.value === value)}
// @ts-expect-error - this works fine
onChange={(selectedFn) => {
if (selectedFn) {
onChange((selectedFn as { label: string; value: string }).value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const MarkdownRenderer: React.FC<{

a: (props) => (
<Link
href={props.href}
href={props.href ?? "#"}
target="_blank"
{...cleanedProps(props)}
className="mt-4 text-link-foreground hover:text-foreground"
Expand All @@ -103,6 +103,7 @@ export const MarkdownRenderer: React.FC<{
if (code?.disableCodeHighlight) {
return (
<div className="my-4">
{/* @ts-expect-error - TODO: fix this */}
<PlainTextCodeBlock
{...cleanedProps(props)}
code={onlyText(props.children).trim()}
Expand All @@ -114,6 +115,7 @@ export const MarkdownRenderer: React.FC<{
return (
<div className="my-4">
<CodeClient
// @ts-expect-error - TODO: fix this
lang={language}
{...cleanedProps(props)}
code={onlyText(props.children).trim()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export const ApplyForOpCreditsForm: React.FC<ApplyForOpCreditsFormProps> = ({
}))}
placeholder="Select industry"
isRequired
// @ts-expect-error - this works fine
onChange={(value) => {
if (value?.value) {
form.setValue("superchain_verticals", value.value);
Expand Down Expand Up @@ -222,14 +221,10 @@ export const ApplyForOpCreditsForm: React.FC<ApplyForOpCreditsFormProps> = ({
label: chain === "Optimism" ? "OP Mainnet" : chain,
value: chain,
}))}
// @ts-expect-error - this works fine
onChange={(values) => {
form.setValue(
"superchain_chain",
values
// @ts-expect-error - this works fine
.map(({ value }) => value)
.join(";"),
values.map(({ value }) => value).join(";"),
);
}}
isMulti
Expand Down

0 comments on commit ddb6af1

Please sign in to comment.