Optimize ES6 Module Loader Polyfill

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.
This commit is contained in:
Solly Ross
2017-02-11 16:49:03 -05:00
parent e25f9c4010
commit 399fa2ee2d
11 changed files with 45683 additions and 8 deletions

View File

@@ -23,7 +23,7 @@ var lib_dir_base = path.resolve(__dirname, '..', 'lib');
// walkDir *recursively* walks directories trees,
// calling the callback for all normal files found.
var walkDir = function (base_path, cb) {
var walkDir = function (base_path, cb, filter) {
fs.readdir(base_path, (err, files) => {
if (err) throw err;
@@ -31,9 +31,11 @@ var walkDir = function (base_path, cb) {
fs.lstat(filepath, (err, stats) => {
if (err) throw err;
if (filter !== undefined && !filter(filepath, stats)) return;
if (stats.isSymbolicLink()) return;
if (stats.isFile()) cb(filepath);
if (stats.isDirectory()) walkDir(filepath, cb);
if (stats.isDirectory()) walkDir(filepath, cb, filter);
});
});
});
@@ -123,7 +125,7 @@ var make_lib_files = function (import_format, source_maps, with_app_dir) {
};
walkDir(core_path, handleDir.bind(null, true, in_path || core_path));
walkDir(vendor_path, handleDir.bind(null, true, in_path || main_path));
walkDir(vendor_path, handleDir.bind(null, true, in_path || main_path), (filepath, stats) => !((stats.isDirectory() && path.basename(filepath) === 'browser-es-module-loader') || path.basename(filepath) === 'sinon.js'));
if (with_app_dir) {
walkDir(app_path, handleDir.bind(null, false, in_path || app_path));