mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-02-16 18:31:50 +01:00
Upgrade to latest babel
There has been a lot of renaming and restructuring in babel, so we need to modify our code to handle the latest version. We also need to adjust the way we build our babel worker as babel itself no longer runs in older browsers such as Internet Explorer.
This commit is contained in:
parent
23871b42d1
commit
edb5fee88b
@ -4,7 +4,7 @@ const path = require('path');
|
||||
const program = require('commander');
|
||||
const fs = require('fs');
|
||||
const fse = require('fs-extra');
|
||||
const babel = require('babel-core');
|
||||
const babel = require('@babel/core');
|
||||
|
||||
const SUPPORTED_FORMATS = new Set(['amd', 'commonjs', 'systemjs', 'umd']);
|
||||
|
||||
@ -150,8 +150,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
|
||||
const babel_opts = () => ({
|
||||
plugins: [`transform-es2015-modules-${import_format}`],
|
||||
presets: ['es2015'],
|
||||
plugins: [],
|
||||
presets: [
|
||||
[ '@babel/preset-env',
|
||||
{ targets: 'ie >= 11',
|
||||
modules: import_format } ]
|
||||
],
|
||||
ast: false,
|
||||
sourceMaps: source_maps,
|
||||
});
|
||||
|
@ -33,10 +33,6 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
'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) => {
|
||||
const browserify = require('browserify');
|
||||
const b = browserify(path.join(script_base_path, 'app/ui.js'), {});
|
||||
@ -60,9 +56,5 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
'umd': {
|
||||
optionsOverride: (opts) => {
|
||||
// umd supports properly shifting the default export to work as normal
|
||||
opts.plugins.unshift("add-module-exports");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -6,8 +6,8 @@ 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`.
|
||||
To generate, run `npx rollup -c` in this directory, and then run
|
||||
`./genworker.js`.
|
||||
|
||||
LICENSE
|
||||
-------
|
||||
|
145844
kasmweb/vendor/browser-es-module-loader/dist/babel-worker.js
vendored
145844
kasmweb/vendor/browser-es-module-loader/dist/babel-worker.js
vendored
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = global || self, global.BrowserESModuleLoader = factory());
|
||||
}(this, function () { 'use strict';
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
/*
|
||||
* Environment
|
||||
@ -1477,5 +1477,5 @@
|
||||
|
||||
return BrowserESModuleLoader;
|
||||
|
||||
}));
|
||||
})));
|
||||
//# sourceMappingURL=browser-es-module-loader.js.map
|
||||
|
13
kasmweb/vendor/browser-es-module-loader/genworker.js
vendored
Normal file
13
kasmweb/vendor/browser-es-module-loader/genworker.js
vendored
Normal 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"));
|
@ -1,12 +1,10 @@
|
||||
/*import { transform as babelTransform } from 'babel-core';
|
||||
import babelTransformDynamicImport from 'babel-plugin-syntax-dynamic-import';
|
||||
import babelTransformES2015ModulesSystemJS from 'babel-plugin-transform-es2015-modules-systemjs';*/
|
||||
// Polyfills needed for Babel to function
|
||||
require("core-js");
|
||||
|
||||
// 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');
|
||||
var babelPresetES2015 = require('babel-preset-es2015');
|
||||
var babelTransform = require('@babel/core').transform;
|
||||
var babelTransformDynamicImport = require('@babel/plugin-syntax-dynamic-import');
|
||||
var babelTransformModulesSystemJS = require('@babel/plugin-transform-modules-systemjs');
|
||||
var babelPresetEnv = require('@babel/preset-env');
|
||||
|
||||
self.onmessage = function (evt) {
|
||||
// transform source with Babel
|
||||
@ -17,8 +15,8 @@ self.onmessage = function (evt) {
|
||||
moduleIds: false,
|
||||
sourceMaps: 'inline',
|
||||
babelrc: false,
|
||||
plugins: [babelTransformDynamicImport, babelTransformES2015ModulesSystemJS],
|
||||
presets: [babelPresetES2015],
|
||||
plugins: [babelTransformDynamicImport, babelTransformModulesSystemJS],
|
||||
presets: [ [ babelPresetEnv, { targets: 'ie >= 11' } ] ],
|
||||
});
|
||||
|
||||
self.postMessage({key: evt.data.key, code: output.code, source: evt.data.source});
|
||||
|
Loading…
Reference in New Issue
Block a user