refactor(curriculum): remove challenge caching (#66297)

This commit is contained in:
Jeevankumar S
2026-03-10 14:19:51 +05:30
committed by GitHub
parent fcdf03fe33
commit 316b3b02ce
+7 -23
View File
@@ -1,5 +1,5 @@
import { existsSync, readdirSync } from 'fs';
import { join, resolve, basename } from 'path';
import { resolve } from 'path';
import { isEmpty, cloneDeep } from 'lodash';
import debug from 'debug';
@@ -8,8 +8,7 @@ import { createPoly } from '@freecodecamp/shared/utils/polyvinyl';
import { isAuditedSuperBlock } from '@freecodecamp/shared/utils/is-audited';
import {
CommentDictionary,
translateCommentsInChallenge,
type Challenge as ParsedChallenge
translateCommentsInChallenge
} from '../../tools/challenge-parser/translation-parser';
import { SuperBlocks } from '@freecodecamp/shared/config/curriculum';
import type { Chapter } from '@freecodecamp/shared/config/chapters';
@@ -44,8 +43,6 @@ interface Meta extends BlockStructure {
superOrder: number;
}
const challengeCache = new Map<string, ParsedChallenge>();
/**
* Validates challenges against meta.json challengeOrder
* @param {Array<object>} foundChallenges - Array of challenge objects
@@ -334,26 +331,13 @@ export class BlockCreator {
const challengePath = langUsed === 'english' ? englishPath : i18nPath;
const cachedChallenge = challengeCache.get(challengePath);
const challenge =
cachedChallenge ??
translateCommentsInChallenge(
await parser(challengePath),
langUsed,
this.commentTranslations
);
challenge.translationPending = this.lang !== 'english' && !isAudited;
// Add source location to allow tracing back to original file (necessary to
// update the client when files change)
challenge.sourceLocation = join(
basename(this.blockContentDir),
block,
filename
const challenge = translateCommentsInChallenge(
await parser(challengePath),
langUsed,
this.commentTranslations
);
challengeCache.set(challengePath, challenge);
challenge.translationPending = this.lang !== 'english' && !isAudited;
return finalizeChallenge(challenge, meta);
}