Skip to content

Commit f59b46c

Browse files
avivkellerovflowd
andauthored
fix(nextjs): fix static exports (#8439)
* fix(static): fix static rendering * fixup! * fixup! use async anyway * fixup! async caching * fixup! * Update .github/workflows/build.yml Co-authored-by: Claudio Wunder <[email protected]> Signed-off-by: Aviv Keller <[email protected]> * fixup! --------- Signed-off-by: Aviv Keller <[email protected]> Co-authored-by: Claudio Wunder <[email protected]>
1 parent 411449c commit f59b46c

File tree

14 files changed

+34
-42
lines changed

14 files changed

+34
-42
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ jobs:
6767
# this should be a last resort in case by any chances the build memory gets too high
6868
# but in general this should never happen
6969
NODE_OPTIONS: '--max_old_space_size=4096'
70-
# We want to ensure that static exports for all locales do not occur on `pull_request` events
71-
NEXT_PUBLIC_STATIC_EXPORT_LOCALE: ${{ github.event_name == 'push' }}
7270
# See https://github.com/vercel/next.js/pull/81318
7371
TURBOPACK_STATS: ${{ matrix.os == 'ubuntu-latest' }}
7472

@@ -77,3 +75,14 @@ jobs:
7775
with:
7876
name: webpack-stats
7977
path: apps/site/.next/server/webpack-stats.json
78+
79+
- name: Build Next.js (Static Export)
80+
# We want to generate a static build, as it is a requirement of our website.
81+
run: node_modules/.bin/turbo deploy ${{ env.TURBO_ARGS }}
82+
env:
83+
# We want to ensure we have enough RAM allocated to the Node.js process
84+
# this should be a last resort in case by any chances the build memory gets too high
85+
# but in general this should never happen
86+
NODE_OPTIONS: '--max_old_space_size=4096'
87+
# We want to ensure that static exports for all locales do not occur on `pull_request` events
88+
NEXT_PUBLIC_STATIC_EXPORT_LOCALE: ${{ github.event_name == 'push' }}

apps/site/app/[locale]/not-found.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use server';
2-
31
import { getTranslations } from 'next-intl/server';
42

53
import Button from '#site/components/Common/Button';

apps/site/components/withDownloadSection.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ const WithDownloadSection: FC<WithDownloadSectionProps> = async ({
2222
}) => {
2323
const locale = await getLocale();
2424

25-
const snippets = await provideDownloadSnippets(locale);
25+
const snippets = await provideDownloadSnippets();
26+
27+
const localeSnippets = snippets.get(locale) ?? [];
2628

2729
// By default the translated languages do not contain all the download snippets
2830
// Hence we always merge any translated snippet with the fallbacks for missing snippets
29-
const fallbackSnippets = await provideDownloadSnippets(defaultLocale.code);
31+
const fallbackSnippets = snippets.get(defaultLocale.code) ?? [];
3032

3133
const { pathname } = getClientContext();
3234

3335
// Some available translations do not have download snippets translated or have them partially translated
3436
// This aims to merge the available translated snippets with the fallback snippets
3537
const memoizedSnippets = fallbackSnippets
36-
.filter(snippet => !snippets.some(s => s.name === snippet.name))
37-
.concat(snippets);
38+
.filter(snippet => !localeSnippets.some(s => s.name === snippet.name))
39+
.concat(localeSnippets);
3840

3941
// Decides which initial release to use based on the current pathname
4042
const initialRelease = pathname.endsWith('/current')

apps/site/components/withNodeRelease.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use server';
2-
31
import provideReleaseData from '#site/next-data/providers/releaseData';
42

53
import type { NodeRelease, NodeReleaseStatus } from '#site/types';

apps/site/components/withReleaseSelect.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use server';
2-
31
import StatelessSelect from '@node-core/ui-components/Common/Select/StatelessSelect';
42

53
import Link from '#site/components/Link';

apps/site/components/withSupporters.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use server';
2-
31
import provideSupporters from '#site/next-data/providers/supportersData';
42

53
import type { FC, PropsWithChildren } from 'react';

apps/site/next-data/generators/majorNodeReleases.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import nodevu from '@nodevu/core';
44

5-
const nodevuData = await nodevu({ fetch });
6-
75
/**
86
* Filters Node.js release data to return only major releases with documented support.
97
*/
108
export default async function getMajorNodeReleases() {
9+
const nodevuData = await nodevu({ fetch });
10+
1111
return Object.entries(nodevuData).filter(([version, { support }]) => {
1212
// Filter out those without documented support
1313
// Basically those not in schedule.json
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
'use cache';
1+
import { cache } from 'react';
22

33
import generateDownloadSnippets from '#site/next-data/generators/downloadSnippets.mjs';
44

5-
const provideDownloadSnippets = async (language: string) => {
6-
const downloadSnippets = await generateDownloadSnippets();
7-
8-
if (downloadSnippets.has(language)) {
9-
return downloadSnippets.get(language)!;
10-
}
11-
12-
return [];
13-
};
14-
15-
export default provideDownloadSnippets;
5+
export default cache(generateDownloadSnippets);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
'use cache';
1+
import { cache } from 'react';
22

3-
import provideReleaseData from '#site/next-data/generators/releaseData.mjs';
3+
import generateReleaseData from '#site/next-data/generators/releaseData.mjs';
44

5-
export default provideReleaseData;
5+
export default cache(generateReleaseData);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
'use cache';
1+
import { cache } from 'react';
22

3-
import provideReleaseVersions from '#site/next-data/generators/releaseVersions.mjs';
3+
import generateReleaseVersions from '#site/next-data/generators/releaseVersions.mjs';
44

5-
export default provideReleaseVersions;
5+
export default cache(generateReleaseVersions);

0 commit comments

Comments
 (0)