Skip to content

Commit

Permalink
feat(client): stop transforming jsx extensions (freeCodeCamp#57177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojeytonwilliams authored Nov 18, 2024
1 parent 56817b6 commit 26d4b0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
13 changes: 5 additions & 8 deletions client/src/templates/Challenges/rechallenge/transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import sassData from '../../../../config/browser-scripts/sass-compile.json';
import {
transformContents,
transformHeadTailAndContents,
setExt,
compileHeadTail,
createSource
} from '../../../../../shared/utils/polyvinyl';
Expand Down Expand Up @@ -127,10 +126,10 @@ const getJSXTranspiler = loopProtectOptions => async challengeFile => {
await loadBabel();
await loadPresetReact();
const babelOptions = getBabelOptions(presetsJSX, loopProtectOptions);
return flow(
partial(transformHeadTailAndContents, babelTransformCode(babelOptions)),
partial(setExt, 'js')
)(challengeFile);
return transformHeadTailAndContents(
babelTransformCode(babelOptions),
challengeFile
);
};

const getTSTranspiler = loopProtectOptions => async challengeFile => {
Expand Down Expand Up @@ -265,9 +264,7 @@ export const embedFilesInHtml = async function (challengeFiles) {

function challengeFilesToObject(challengeFiles) {
const indexHtml = challengeFiles.find(file => file.fileKey === 'indexhtml');
const indexJsx = challengeFiles.find(
file => file.fileKey === 'indexjs' && file.history[0] === 'index.jsx'
);
const indexJsx = challengeFiles.find(file => file.fileKey === 'indexjsx');
const stylesCss = challengeFiles.find(file => file.fileKey === 'stylescss');
const scriptJs = challengeFiles.find(file => file.fileKey === 'scriptjs');
const indexTs = challengeFiles.find(file => file.fileKey === 'indexts');
Expand Down
13 changes: 0 additions & 13 deletions shared/utils/polyvinyl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,6 @@ export function setContent(
};
}

export async function setExt(ext: string, polyP: Promise<ChallengeFile>) {
const poly = await polyP;
checkPoly(poly);
const newPoly = {
...poly,
ext,
path: poly.name + '.' + ext,
fileKey: poly.name + ext
};
newPoly.history = [...poly.history, newPoly.path];
return newPoly;
}

// This is currently only used to add back properties that are not stored in the
// database.
export function regeneratePathAndHistory(poly: ChallengeFile) {
Expand Down

0 comments on commit 26d4b0e

Please sign in to comment.