This commit is contained in:
Pierre Ossman 2019-11-12 14:12:18 +01:00
commit 686c8d259a
8 changed files with 105429 additions and 40497 deletions

View File

@ -40,17 +40,18 @@
}, },
"homepage": "https://github.com/novnc/noVNC", "homepage": "https://github.com/novnc/noVNC",
"devDependencies": { "devDependencies": {
"babel-core": "*", "@babel/core": "*",
"babel-plugin-add-module-exports": "*", "@babel/plugin-syntax-dynamic-import": "*",
"@babel/plugin-transform-modules-amd": "*",
"@babel/plugin-transform-modules-commonjs": "*",
"@babel/plugin-transform-modules-systemjs": "*",
"@babel/plugin-transform-modules-umd": "*",
"@babel/preset-env": "*",
"@babel/cli": "*",
"babel-plugin-import-redirect": "*", "babel-plugin-import-redirect": "*",
"babel-plugin-syntax-dynamic-import": "*",
"babel-plugin-transform-es2015-modules-amd": "*",
"babel-plugin-transform-es2015-modules-commonjs": "*",
"babel-plugin-transform-es2015-modules-systemjs": "*",
"babel-plugin-transform-es2015-modules-umd": "*",
"babel-preset-es2015": "*",
"babelify": "*",
"browserify": "*", "browserify": "*",
"babelify": "*",
"core-js": "*",
"chai": "*", "chai": "*",
"commander": "*", "commander": "*",
"es-module-loader": "*", "es-module-loader": "*",

View File

@ -4,7 +4,7 @@ const path = require('path');
const program = require('commander'); const program = require('commander');
const fs = require('fs'); const fs = require('fs');
const fse = require('fs-extra'); const fse = require('fs-extra');
const babel = require('babel-core'); const babel = require('@babel/core');
const SUPPORTED_FORMATS = new Set(['amd', 'commonjs', 'systemjs', 'umd']); const SUPPORTED_FORMATS = new Set(['amd', 'commonjs', 'systemjs', 'umd']);
@ -134,8 +134,12 @@ function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
// NB: we need to make a copy of babel_opts, since babel sets some defaults on it // NB: we need to make a copy of babel_opts, since babel sets some defaults on it
const babel_opts = () => ({ const babel_opts = () => ({
plugins: [`transform-es2015-modules-${import_format}`], plugins: [],
presets: ['es2015'], presets: [
[ '@babel/preset-env',
{ targets: 'ie >= 11',
modules: import_format } ]
],
ast: false, ast: false,
sourceMaps: source_maps, sourceMaps: source_maps,
}); });
@ -268,13 +272,15 @@ function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
console.log(`Writing ${out_app_path}`); console.log(`Writing ${out_app_path}`);
return helper.appWriter(out_path_base, legacy_path_base, out_app_path) return helper.appWriter(out_path_base, legacy_path_base, out_app_path)
.then((extra_scripts) => { .then((extra_scripts) => {
let legacy_scripts = extra_scripts; let legacy_scripts = [];
legacyFiles.forEach((file) => { legacyFiles.forEach((file) => {
let rel_file_path = path.relative(out_path_base, file); let rel_file_path = path.relative(out_path_base, file);
legacy_scripts.push(rel_file_path); legacy_scripts.push(rel_file_path);
}); });
legacy_scripts = legacy_scripts.concat(extra_scripts);
let rel_app_path = path.relative(out_path_base, out_app_path); let rel_app_path = path.relative(out_path_base, out_app_path);
legacy_scripts.push(rel_app_path); legacy_scripts.push(rel_app_path);

View File

@ -23,7 +23,7 @@ module.exports = {
// setup for requirejs // setup for requirejs
const ui_path = path.relative(base_out_path, const ui_path = path.relative(base_out_path,
path.join(script_base_path, 'app', 'ui')); path.join(script_base_path, 'app', 'ui'));
return writeFile(out_path, `requirejs(["${ui_path}"], (ui) => {});`) return writeFile(out_path, `requirejs(["${ui_path}"], function (ui) {});`)
.then(() => { .then(() => {
console.log(`Please place RequireJS in ${path.join(script_base_path, 'require.js')}`); console.log(`Please place RequireJS in ${path.join(script_base_path, 'require.js')}`);
const require_path = path.relative(base_out_path, const require_path = path.relative(base_out_path,
@ -33,10 +33,6 @@ module.exports = {
}, },
}, },
'commonjs': { 'commonjs': {
optionsOverride: (opts) => {
// CommonJS supports properly shifting the default export to work as normal
opts.plugins.unshift("add-module-exports");
},
appWriter: (base_out_path, script_base_path, out_path) => { appWriter: (base_out_path, script_base_path, out_path) => {
const browserify = require('browserify'); const browserify = require('browserify');
const b = browserify(path.join(script_base_path, 'app/ui.js'), {}); const b = browserify(path.join(script_base_path, 'app/ui.js'), {});
@ -60,9 +56,5 @@ module.exports = {
}, },
}, },
'umd': { 'umd': {
optionsOverride: (opts) => {
// umd supports properly shifting the default export to work as normal
opts.plugins.unshift("add-module-exports");
},
}, },
}; };

View File

@ -6,8 +6,8 @@ It's based heavily on
https://github.com/ModuleLoader/browser-es-module-loader, but uses https://github.com/ModuleLoader/browser-es-module-loader, but uses
WebWorkers to compile the modules in the background. WebWorkers to compile the modules in the background.
To generate, run `rollup -c` in this directory, and then run `browserify To generate, run `npx rollup -c` in this directory, and then run
src/babel-worker.js > dist/babel-worker.js`. `./genworker.js`.
LICENSE LICENSE
------- -------

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) : typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.BrowserESModuleLoader = factory()); (global = global || self, global.BrowserESModuleLoader = factory());
}(this, function () { 'use strict'; }(this, (function () { 'use strict';
/* /*
* Environment * Environment
@ -1477,5 +1477,5 @@
return BrowserESModuleLoader; return BrowserESModuleLoader;
})); })));
//# sourceMappingURL=browser-es-module-loader.js.map //# sourceMappingURL=browser-es-module-loader.js.map

13
vendor/browser-es-module-loader/genworker.js vendored Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env node
var fs = require("fs");
var browserify = require("browserify");
browserify("src/babel-worker.js")
.transform("babelify", {
presets: [ [ "@babel/preset-env", { targets: "ie >= 11" } ] ],
global: true,
ignore: [ "../../node_modules/core-js" ]
})
.bundle()
.pipe(fs.createWriteStream("dist/babel-worker.js"));

View File

@ -1,12 +1,10 @@
/*import { transform as babelTransform } from 'babel-core'; // Polyfills needed for Babel to function
import babelTransformDynamicImport from 'babel-plugin-syntax-dynamic-import'; require("core-js");
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 babelTransform = require('babel-core').transform; var babelTransformDynamicImport = require('@babel/plugin-syntax-dynamic-import');
var babelTransformDynamicImport = require('babel-plugin-syntax-dynamic-import'); var babelTransformModulesSystemJS = require('@babel/plugin-transform-modules-systemjs');
var babelTransformES2015ModulesSystemJS = require('babel-plugin-transform-es2015-modules-systemjs'); var babelPresetEnv = require('@babel/preset-env');
var babelPresetES2015 = require('babel-preset-es2015');
self.onmessage = function (evt) { self.onmessage = function (evt) {
// transform source with Babel // transform source with Babel
@ -17,8 +15,8 @@ self.onmessage = function (evt) {
moduleIds: false, moduleIds: false,
sourceMaps: 'inline', sourceMaps: 'inline',
babelrc: false, babelrc: false,
plugins: [babelTransformDynamicImport, babelTransformES2015ModulesSystemJS], plugins: [babelTransformDynamicImport, babelTransformModulesSystemJS],
presets: [babelPresetES2015], presets: [ [ babelPresetEnv, { targets: 'ie >= 11' } ] ],
}); });
self.postMessage({key: evt.data.key, code: output.code, source: evt.data.source}); self.postMessage({key: evt.data.key, code: output.code, source: evt.data.source});