mirror of
https://github.com/novnc/noVNC.git
synced 2026-06-03 02:49:40 +00:00
This commit makes the ES6 module loader polyfill use Web Workers, so that Babel doesn't block the browser from animating. It also uses localStorage to cache the compiled results, only recompiling on source changes, so it makes loading faster while developing noVNC. This includes a vendored copy of the ES6 module loader, modified as described above.
24 lines
1021 B
JavaScript
24 lines
1021 B
JavaScript
/*import { transform as babelTransform } from 'babel-core';
|
|
import babelTransformDynamicImport from 'babel-plugin-syntax-dynamic-import';
|
|
import babelTransformES2015ModulesSystemJS from 'babel-plugin-transform-es2015-modules-systemjs';*/
|
|
|
|
// sadly, due to how rollup works, we can't use es6 imports here
|
|
var babelTransform = require('babel-core').transform;
|
|
var babelTransformDynamicImport = require('babel-plugin-syntax-dynamic-import');
|
|
var babelTransformES2015ModulesSystemJS = require('babel-plugin-transform-es2015-modules-systemjs');
|
|
|
|
self.onmessage = function (evt) {
|
|
// transform source with Babel
|
|
var output = babelTransform(evt.data.source, {
|
|
compact: false,
|
|
filename: evt.data.key + '!transpiled',
|
|
sourceFileName: evt.data.key,
|
|
moduleIds: false,
|
|
sourceMaps: 'inline',
|
|
babelrc: false,
|
|
plugins: [babelTransformDynamicImport, babelTransformES2015ModulesSystemJS],
|
|
});
|
|
|
|
self.postMessage({key: evt.data.key, code: output.code, source: evt.data.source});
|
|
};
|