[go: nahoru, domu]

Skip to content

Commit

Permalink
Optimize ES6 Module Loader Polyfill
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DirectXMan12 committed Mar 21, 2017
1 parent e25f9c4 commit 399fa2e
Show file tree
Hide file tree
Showing 11 changed files with 45,683 additions and 8 deletions.
3 changes: 3 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ licenses (all MPL 2.0 compatible):

vendor/pako/ : MIT

vendor/browser-es-module-loader: MIT

Any other files not mentioned above are typically marked with
a copyright/license header at the top of the file. The default noVNC
license is MPL-2.0.
Expand All @@ -66,3 +68,4 @@ Or alternatively the license texts may be found here:
http://en.wikipedia.org/wiki/BSD_licenses
http://www.gzip.org/zlib/zlib_license.html
http://www.apache.org/licenses/LICENSE-2.0.html
https://opensource.org/licenses/MIT
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,25 @@
"babel-plugin-transform-es2015-modules-systemjs": "^6.22.0",
"babel-plugin-transform-es2015-modules-umd": "^6.22.0",
"babelify": "^7.3.0",
"browser-es-module-loader": "^0.4.1",
"browserify": "^13.1.0",
"chai": "^3.5.0",
"commander": "^2.9.0",
"es-module-loader": "^2.1.0",
"fs-extra": "^1.0.0",
"jsdom": "*",
"karma": "^1.3.0",
"karma-babel-preprocessor": "^6.0.1",
"karma-chai": "^0.1.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.0",
"karma-sauce-launcher": "^1.0.0",
"karma-requirejs": "^1.1.0",
"requirejs": "^2.3.2",
"karma-sauce-launcher": "^1.0.0",
"mocha": "^3.1.2",
"node-getopt": "*",
"po2json": "*",
"requirejs": "^2.3.2",
"rollup": "^0.41.4",
"rollup-plugin-node-resolve": "^2.0.0",
"sinon-chai": "^2.8.0"
}
}
8 changes: 5 additions & 3 deletions utils/use_require.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ 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;

files.map((filename) => path.join(base_path, filename)).forEach((filepath) => {
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);
});
});
});
Expand Down Expand Up @@ -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));
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions vendor/browser-es-module-loader/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Custom Browser ES Module Loader
===============================

This is a module loader using babel and the ES Module Loader polyfill.
It's based heavily on
https://github.com/ModuleLoader/browser-es-module-loader, but uses
WebWorkers to compile the modules in the background.

To generate, run `rollup -c` in this directory, and then run `browserify
src/babel-worker.js > dist/babel-worker.js`.

LICENSE
-------

MIT
Loading

0 comments on commit 399fa2e

Please sign in to comment.