Next.js Discord

Discord Forum

[Bug?] Server is approaching the used memory threshold, restarting...

Unanswered
Atlantic mackerel posted this in #help-forum
Open in Discord
Atlantic mackerelOP
1. yarn add react-icons
2. example code:
'use server'
import {FC} from "react";
import {TbCertificate, TbTools} from "react-icons/tb";
import {GoLaw} from "react-icons/go";
import {RiLiveFill} from "react-icons/ri";
import {FaPeopleRobbery, FaSchoolFlag} from "react-icons/fa6";
import { IoIosInformationCircleOutline } from "react-icons/io";
import { IoIosHelpCircleOutline } from "react-icons/io";
import { GrNotes } from "react-icons/gr";
import { FaCalendarAlt } from "react-icons/fa";
import { FaCheck } from "react-icons/fa";
import { FaListCheck } from "react-icons/fa6";
import { IoFastFood } from "react-icons/io5";

export type AbcRoute = {
    title: string;
    icon?: FC<any>;
    initiallyOpened?: boolean;
    href?: string;
    children?: AbcRoute[];
}

export const abcRoute: AbcRoute[] = [
    { title: 'A', icon: FaPeopleRobbery, href: 'xxxx' },
    { title: 'B', icon: IoIosInformationCircleOutline, href: 'xxxx'},
    { title: 'C', icon: IoIosHelpCircleOutline, href: 'xxxx' },
    {
        title: 'D',
        icon: FaCalendarAlt,
        children: [
            { title: 'E', href: 'xxxx' },
            { title: 'F', href: 'xxxx' },
            { title: 'F', href: 'xxxx' },
        ],
    },
    // ... write more if you can not reproduce this issue
];

3. yarn dev && watch memory usage

3 Replies

Atlantic mackerelOP
react-icons, material icons, etc. Most of these libraries publish barrel files with a lot of re-exports. E.g. material-ui/icons ships 5500 module re-exports, which causes all of them to be compiled. You have to add modularizeImports to reduce it, here's an example: long compile times locally - along with "JavaScript heap out of memory" since upgrade to NextJS 13 #45529 (comment)
Gray-tailed Tattler
I'm using https://lucide.dev/icons/ no slowness noticed yet