fix(client): ensure presetEnv is loaded (#39431)

Prior to this, if a user first loaded a React challenge and then
navigated to a JS challenge, they would see
TypeError: Cannot read property 'presets' of undefined
in the console and be unable to run tests or evaluate code until they
reloaded the page.
This commit is contained in:
Oliver Eyton-Williams
2020-08-19 22:30:46 +02:00
committed by GitHub
parent 7155c87e8b
commit eb75f8c8cc

View File

@ -59,8 +59,9 @@ async function loadBabel() {
} }
async function loadPresetEnv() { async function loadPresetEnv() {
if (presetEnv) return; if (babelOptionsJSBase && babelOptionsJSBase.presets) return;
/* eslint-disable no-inline-comments */ /* eslint-disable no-inline-comments */
if (!presetEnv)
presetEnv = await import( presetEnv = await import(
/* webpackChunkName: "@babel/preset-env" */ '@babel/preset-env' /* webpackChunkName: "@babel/preset-env" */ '@babel/preset-env'
); );