summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSolly Ross <sross@redhat.com>2017-02-11 16:49:03 -0500
committerSolly Ross <sross@redhat.com>2017-03-21 17:39:07 -0400
commit399fa2ee2da4b7a766e7b95b56436e79f0a42a73 (patch)
tree5f37101b8384b95662fa6a81fd3d95a5c72ce203 /utils
parente25f9c40102c6566e63b7caa30f620da86fd0d60 (diff)
downloadnovnc-399fa2ee2da4b7a766e7b95b56436e79f0a42a73.tar.gz
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.
Diffstat (limited to 'utils')
-rwxr-xr-xutils/use_require.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/utils/use_require.js b/utils/use_require.js
index 43f12af..bfa14f6 100755
--- a/utils/use_require.js
+++ b/utils/use_require.js
@@ -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));