Next.js Discord

Discord Forum

JSON + static export results in twice the size

Unanswered
American Sable posted this in #help-forum
Open in Discord
American SableOP
On App router with output: "export" when I import a JSON from filesystem, it gets loaded as a script tag

5 Replies

American SableOP
For example
const HomePage = async () => {
    const messages = (await import(`@/messages/fr.json`));

    return (
        <>
            <p>{JSON.stringify(messages)}</p>
        </>
    );
};


When I open the HTML file after building, I can see the content inside the <p> tag (expected)
But I also see the content of the json file as a <script> before the end of the <body>.
<body class="__className_f154f2">
  <p>
    {&quot;about_page&quot;:&quot;About&quot;,&quot;home_page&quot;:&quot;Home&quot;}
  </p>

...

<script>
  self.__next_f.push([1,':[["$","p",null,{"children":"{\\"about_page\\":\\"About\\",\\"home_page\\":\\"Home\\"}"}],["$","$L1b",null,{}],["$","$L1c",null,{}],"$L1d",["$","$L1e",null,{}]]\n17:null\n',]);
</script>

...

</body>
How would I get rid of the <script> content.
Seems that same thing is happening for metadata
American SableOP
Is this expected? If yes what’s the reason?