diff --git a/client/package-lock.json b/client/package-lock.json
index 41b875522c..9083fbc104 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -10597,6 +10597,11 @@
"topo": "2.x.x"
}
},
+ "jquery": {
+ "version": "3.3.1",
+ "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
+ "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg=="
+ },
"js-levenshtein": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.3.tgz",
diff --git a/client/package.json b/client/package.json
index d7f9575841..9d5d516491 100644
--- a/client/package.json
+++ b/client/package.json
@@ -32,6 +32,7 @@
"gatsby-remark-prismjs": "^3.0.2",
"gatsby-source-filesystem": "^2.0.5",
"gatsby-transformer-remark": "^2.1.8",
+ "jquery": "3.3.1",
"lodash": "^4.17.10",
"loop-protect": "^2.1.6",
"monaco-editor-webpack-plugin": "^1.5.4",
diff --git a/client/src/client/frame-runner.js b/client/src/client/frame-runner.js
index e26a0b71a0..031ec48270 100644
--- a/client/src/client/frame-runner.js
+++ b/client/src/client/frame-runner.js
@@ -1,3 +1,9 @@
+import chai from 'chai';
+import '@babel/polyfill';
+import jQuery from 'jquery';
+
+window.$ = jQuery;
+
document.addEventListener('DOMContentLoaded', function() {
const {
timeout,
@@ -10,7 +16,6 @@ document.addEventListener('DOMContentLoaded', function() {
throwError
} = document.__deps__.rx;
const frameReady = document.__frameReady;
- const chai = parent.chai;
const source = document.__source;
const __getUserInput = document.__getUserInput || (x => x);
const checkChallengePayload = document.__checkChallengePayload;
@@ -56,10 +61,6 @@ document.addEventListener('DOMContentLoaded', function() {
return source;
}
};
- const userCode = document.createElement('script');
- userCode.type = 'text/javascript';
- userCode.text = code;
- document.body.appendChild(userCode);
const assert = chai.assert;
const getUserInput = __getUserInput;
// Iterate through the test one at a time
@@ -70,7 +71,7 @@ document.addEventListener('DOMContentLoaded', function() {
let test;
let __result;
// uncomment the following line to inspect
- // the framerunner as it runs tests
+ // the frame-runner as it runs tests
// make sure the dev tools console is open
// debugger;
try {
diff --git a/client/src/client/workers/test-evaluator.js b/client/src/client/workers/test-evaluator.js
index ecf090431f..f1e3d5f7ec 100644
--- a/client/src/client/workers/test-evaluator.js
+++ b/client/src/client/workers/test-evaluator.js
@@ -1,8 +1,5 @@
-/* global chai, importScripts */
-importScripts(
- 'https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js',
- 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill.min.js'
-);
+import chai from 'chai';
+import '@babel/polyfill';
const oldLog = self.console.log.bind(self.console);
self.console.log = function proxyConsole(...args) {
diff --git a/client/src/templates/Challenges/rechallenge/builders.js b/client/src/templates/Challenges/rechallenge/builders.js
index 037fb2c66b..d3f1f86ddf 100644
--- a/client/src/templates/Challenges/rechallenge/builders.js
+++ b/client/src/templates/Challenges/rechallenge/builders.js
@@ -93,26 +93,22 @@ A required file can not have both a src and a link: src = ${src}, link = ${link}
return head.concat(element);
}, '');
- const body = Promise.all(files).then(
- files => files.reduce(
- (body, file) => [...body, file.contents + file.tail + htmlCatch],
- []
- )
- .map(source => createBody({ source }))
+ const body = Promise.all(files).then(files =>
+ files
+ .reduce(
+ (body, file) => [...body, file.contents + file.tail + htmlCatch],
+ []
+ )
+ .map(source => createBody({ source }))
);
- /* eslint-disable max-len */
- const babelPolyfillCDN =
- 'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill.min.js';
- const babelPolyfill = ``;
- /* eslint-enable max-len */
const frameRunner =
'';
return from(
- Promise.all([head, body, babelPolyfill, frameRunner, sourceMap]).then(
- ([head, body, babelPolyfill, frameRunner, sourceMap]) => ({
- build: head + body + babelPolyfill + frameRunner,
+ Promise.all([head, body, frameRunner, sourceMap]).then(
+ ([head, body, frameRunner, sourceMap]) => ({
+ build: head + frameRunner + body,
sources: sourceMap
})
)
diff --git a/client/src/templates/Challenges/utils/build.js b/client/src/templates/Challenges/utils/build.js
index 996833ab0f..c744eb6bdc 100644
--- a/client/src/templates/Challenges/utils/build.js
+++ b/client/src/templates/Challenges/utils/build.js
@@ -1,5 +1,4 @@
-import { combineLatest, of } from 'rxjs';
-import { map } from 'rxjs/operators';
+import { of } from 'rxjs';
import { flow } from 'lodash';
import { throwers } from '../rechallenge/throwers';
@@ -13,9 +12,6 @@ import { transformers, testJS$JSX } from '../rechallenge/transformers';
import { cssToHtml, jsToHtml, concatHtml } from '../rechallenge/builders.js';
import { isPromise } from './polyvinyl';
-const jQueryCDN =
- 'https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js';
-const jQuery = ``;
const frameRunner =
"";
@@ -24,9 +20,6 @@ const globalRequires = [
link:
'https://cdnjs.cloudflare.com/' +
'ajax/libs/normalize/4.2.0/normalize.min.css'
- },
- {
- src: jQueryCDN
}
];
@@ -118,11 +111,9 @@ export function buildBackendChallenge(state) {
const {
solution: { value: url }
} = backendFormValuesSelector(state);
- return combineLatest(of(frameRunner), of(jQuery)).pipe(
- map(([frameRunner, jQuery]) => ({
- build: jQuery + frameRunner,
- sources: { url },
- checkChallengePayload: { solution: url }
- }))
- );
+ return of({
+ build: frameRunner,
+ sources: { url },
+ checkChallengePayload: { solution: url }
+ });
}
diff --git a/client/src/templates/Challenges/utils/frame.js b/client/src/templates/Challenges/utils/frame.js
index 0bd30252af..cdbd6f848a 100644
--- a/client/src/templates/Challenges/utils/frame.js
+++ b/client/src/templates/Challenges/utils/frame.js
@@ -12,7 +12,6 @@ import {
import { configure, shallow, mount } from 'enzyme';
import Adapter16 from 'enzyme-adapter-react-16';
import { setConfig } from 'react-hot-loader';
-import 'chai';
import { isJSEnabledSelector } from '../redux';