Skip to content

Commit a42bbba

Browse files
committed
limit caching to CI
1 parent 3887c43 commit a42bbba

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

next.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ const nextConfig = {
3838
trailingSlash: true,
3939
serverExternalPackages: ['rehype-preset-minify'],
4040
outputFileTracingExcludes,
41-
experimental: {
42-
webpackBuildWorker: true,
43-
parallelServerCompiles: true,
44-
},
4541
webpack: (config, options) => {
4642
config.plugins.push(
4743
codecovNextJSWebpackPlugin({

src/mdx.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async function getAllFilesFrontMatter(): Promise<FrontMatter[]> {
240240
) as PlatformConfig;
241241
} catch (err) {
242242
// the file may not exist and that's fine, for anything else we throw
243-
if (err.code !== 'ENOENT' && err.code !== 'ABORT_ERR') {
243+
if (err.code !== 'ENOENT') {
244244
throw err;
245245
}
246246
}
@@ -476,17 +476,21 @@ export async function getFileBySlug(slug: string): Promise<SlugFile> {
476476
);
477477
}
478478

479-
const cacheKey = md5(source);
480-
const cacheFile = path.join(CACHE_DIR, cacheKey);
479+
let cacheKey: string | null = null;
480+
let cacheFile: string | null = null;
481+
if (process.env.CI === '1') {
482+
cacheKey = md5(source);
483+
cacheFile = path.join(CACHE_DIR, cacheKey);
481484

482-
try {
483-
const cached = await readCacheFile<SlugFile>(cacheFile);
484-
return cached;
485-
} catch (err) {
486-
if (err.code !== 'ENOENT') {
487-
// If cache is corrupted, ignore and proceed
488-
// eslint-disable-next-line no-console
489-
console.warn(`Failed to read MDX cache: ${cacheFile}`, err);
485+
try {
486+
const cached = await readCacheFile<SlugFile>(cacheFile);
487+
return cached;
488+
} catch (err) {
489+
if (err.code !== 'ENOENT' && err.code !== 'ABORT_ERR') {
490+
// If cache is corrupted, ignore and proceed
491+
// eslint-disable-next-line no-console
492+
console.warn(`Failed to read MDX cache: ${cacheFile}`, err);
493+
}
490494
}
491495
}
492496

@@ -615,10 +619,12 @@ export async function getFileBySlug(slug: string): Promise<SlugFile> {
615619
},
616620
};
617621

618-
writeCacheFile(cacheFile, JSON.stringify(resultObj)).catch(e => {
619-
// eslint-disable-next-line no-console
620-
console.warn(`Failed to write MDX cache: ${cacheFile}`, e);
621-
});
622+
if (cacheFile) {
623+
writeCacheFile(cacheFile, JSON.stringify(resultObj)).catch(e => {
624+
// eslint-disable-next-line no-console
625+
console.warn(`Failed to write MDX cache: ${cacheFile}`, e);
626+
});
627+
}
622628

623629
return resultObj;
624630
}

0 commit comments

Comments
 (0)