fix(client): use babel polyfill for async

This commit is contained in:
Valeriy S
2018-12-07 09:28:02 +03:00
committed by Stuart Taylor
parent ace67970e4
commit 2e598f692d
3 changed files with 15 additions and 7 deletions

View File

@ -1,5 +1,8 @@
/* global chai, importScripts */
importScripts('https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js');
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'
);
const oldLog = self.console.log.bind(self.console);
self.console.log = function proxyConsole(...args) {

View File

@ -63,8 +63,8 @@ export const cssToHtml = cond([
// ) => Observable[{ build: String, sources: Dictionary }]
export function concatHtml(required, template, files) {
const createBody = template ? _template(template) : defaultTemplate;
const sourceMap = Promise.all(files).then(
files => files.reduce((sources, file) => {
const sourceMap = Promise.all(files).then(files =>
files.reduce((sources, file) => {
sources[file.name] = file.source || file.contents;
return sources;
}, {})
@ -101,13 +101,18 @@ A required file can not have both a src and a link: src = ${src}, link = ${link}
.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 = `<script src="${babelPolyfillCDN}" type="text/javascript"></script>`;
/* eslint-enable max-len */
const frameRunner =
'<script src="/js/frame-runner.js" type="text/javascript"></script>';
return from(
Promise.all([head, body, frameRunner, sourceMap]).then(
([head, body, frameRunner, sourceMap]) => ({
build: head + body + frameRunner,
Promise.all([head, body, babelPolyfill, frameRunner, sourceMap]).then(
([head, body, babelPolyfill, frameRunner, sourceMap]) => ({
build: head + body + babelPolyfill + frameRunner,
sources: sourceMap
})
)

View File

@ -15,7 +15,7 @@ import { isPromise } from './polyvinyl';
const jQueryCDN =
'https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js';
const jQuery = `<script src='${jQueryCDN}' typ='text/javascript'></script>`;
const jQuery = `<script src='${jQueryCDN}' type='text/javascript'></script>`;
const frameRunner =
"<script src='/js/frame-runner.js' type='text/javascript'></script>";