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.
pull/39434/head
Oliver Eyton-Williams 2020-08-19 22:30:46 +02:00 committed by GitHub
parent 7155c87e8b
commit eb75f8c8cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

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