Convert backend code to ES modules

Bundling code now with Rollup for its flat bundling and tree shaking
support. Front end code still goes through Webpack for browser support.
This commit is contained in:
Zaid Abdulla committed 2019-02-04 23:47:54 -08:00
1 parent 824639976f
commit 1e41c72d60
62 files changed
+718 -898

No files matched your search

+6 -10
View File
@@ -18,10 +18,9 @@
*/
"use strict";
const childProcess = require("child_process");
const crypto = require("crypto");
const config = require("./config");
import { fork } from "child_process";
import crypto from "crypto";
import * as config from "./config";
const TIMEOUT = config.get("EXT_TIMEOUT");
@@ -36,11 +35,11 @@ function messageHandler(message) {
}
}
function run(args, callback) {
export function run(args, callback) {
const scriptName = args[0];
if (!processes[scriptName]) {
const p = childProcess.fork("lib/extension-wrapper", [scriptName]);
const p = fork("lib/extension-wrapper", [scriptName]);
processes[scriptName] = p;
p.on("error", () => {
@@ -91,7 +90,7 @@ function kill(process, callback) {
}, 100);
}
function killAll(callback) {
export function killAll(callback) {
let counter = 1;
for (const n in processes) {
++counter;
@@ -102,6 +101,3 @@ function killAll(callback) {
}
if (--counter === 0 && callback) callback();
}
exports.run = run;
exports.killAll = killAll;