Skip to content

Commit 353e7f0

Browse files
gaearonclaude
andcommitted
Small cleanups
- Error decoder: key the compiled-MDX cache on the error message instead of the entire codes.json map. - Home page clock: tick on minute boundaries again instead of every 60s from mount. - next.config: drop the @babel/* entries from serverExternalPackages; the server no longer uses Babel. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2c972e4 commit 353e7f0

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

next.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ const nextConfig = {
1818
reactCompiler: true,
1919
cacheComponents: true,
2020
serverExternalPackages: [
21-
'@babel/core',
22-
'@babel/plugin-transform-modules-commonjs',
23-
'@babel/preset-react',
2421
'@mdx-js/mdx',
2522
'gray-matter',
2623
'unist-util-visit',

src/components/Layout/HomeContent.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,17 @@ function CurrentTime() {
9595

9696
useEffect(() => {
9797
const msPerMinute = 60 * 1000;
98+
let timeout;
9899

99100
function updateDate() {
100101
setDate(new Date());
102+
const now = Date.now();
103+
const nextMinute = (Math.floor(now / msPerMinute) + 1) * msPerMinute;
104+
timeout = setTimeout(updateDate, nextMinute - now);
101105
}
102106

103107
updateDate();
104-
const interval = setInterval(updateDate, msPerMinute);
105-
return () => clearInterval(interval);
108+
return () => clearTimeout(timeout);
106109
}, []);
107110

108111
const currentTime = date?.toLocaleTimeString([], {

src/lib/loadErrorDecoderData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function loadErrorCodes(): Promise<Record<string, string>> {
3333
*/
3434
async function compileErrorDecoderData(
3535
code: string | null,
36-
errorCodes: Record<string, string>
36+
errorMessage: string | null
3737
): Promise<ErrorDecoderData> {
3838
'use cache';
3939
cacheLife('max');
@@ -49,7 +49,7 @@ async function compileErrorDecoderData(
4949
return {
5050
...compiled,
5151
errorCode: code,
52-
errorMessage: code ? errorCodes[code] : null,
52+
errorMessage,
5353
};
5454
}
5555

@@ -60,7 +60,7 @@ export async function loadErrorDecoderData(
6060
if (code && !errorCodes[code]) {
6161
notFound();
6262
}
63-
return compileErrorDecoderData(code, errorCodes);
63+
return compileErrorDecoderData(code, code ? errorCodes[code] : null);
6464
}
6565

6666
export async function listErrorCodes(): Promise<string[]> {

0 commit comments

Comments
 (0)