Skip to content

Commit 26d4b0e

Browse files
feat(client): stop transforming jsx extensions (freeCodeCamp#57177)
1 parent 56817b6 commit 26d4b0e

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

client/src/templates/Challenges/rechallenge/transformers.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import sassData from '../../../../config/browser-scripts/sass-compile.json';
1313
import {
1414
transformContents,
1515
transformHeadTailAndContents,
16-
setExt,
1716
compileHeadTail,
1817
createSource
1918
} from '../../../../../shared/utils/polyvinyl';
@@ -127,10 +126,10 @@ const getJSXTranspiler = loopProtectOptions => async challengeFile => {
127126
await loadBabel();
128127
await loadPresetReact();
129128
const babelOptions = getBabelOptions(presetsJSX, loopProtectOptions);
130-
return flow(
131-
partial(transformHeadTailAndContents, babelTransformCode(babelOptions)),
132-
partial(setExt, 'js')
133-
)(challengeFile);
129+
return transformHeadTailAndContents(
130+
babelTransformCode(babelOptions),
131+
challengeFile
132+
);
134133
};
135134

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

266265
function challengeFilesToObject(challengeFiles) {
267266
const indexHtml = challengeFiles.find(file => file.fileKey === 'indexhtml');
268-
const indexJsx = challengeFiles.find(
269-
file => file.fileKey === 'indexjs' && file.history[0] === 'index.jsx'
270-
);
267+
const indexJsx = challengeFiles.find(file => file.fileKey === 'indexjsx');
271268
const stylesCss = challengeFiles.find(file => file.fileKey === 'stylescss');
272269
const scriptJs = challengeFiles.find(file => file.fileKey === 'scriptjs');
273270
const indexTs = challengeFiles.find(file => file.fileKey === 'indexts');

shared/utils/polyvinyl.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,6 @@ export function setContent(
100100
};
101101
}
102102

103-
export async function setExt(ext: string, polyP: Promise<ChallengeFile>) {
104-
const poly = await polyP;
105-
checkPoly(poly);
106-
const newPoly = {
107-
...poly,
108-
ext,
109-
path: poly.name + '.' + ext,
110-
fileKey: poly.name + ext
111-
};
112-
newPoly.history = [...poly.history, newPoly.path];
113-
return newPoly;
114-
}
115-
116103
// This is currently only used to add back properties that are not stored in the
117104
// database.
118105
export function regeneratePathAndHistory(poly: ChallengeFile) {

0 commit comments

Comments
 (0)