Skip to content

Commit 1cb444d

Browse files
committed
Update dependencies and use esbuild for bundling
You may wonder why all these changes are done in one commit, and that's because they're all kind of interrelated: - I initially updated PureScript to 0.15.x, which produces code that uses ES modules instead of CommonJS ones - The version of `purescript-decimals` in the 0.15.x package set was tested with decimal.js 10.3.1, so use that - Since we're using ES modules now, I updated `clipboardy` and `xdg-basedir` to versions that use ES modules (I admit that I didn't have to do this one in this commit) - `pulp browserify` doesn't work with PureScript 0.15.x, so I had to migrate to something else (I chose `esbuild`) Side note: `purescript-parsing` 9.0.0 brings with it a wonderful performance boost[1], which speeds up the test suite by 3 times on my machine (from `102.231 s ± 0.485 s` to `34.666 s ± 0.299 s`). [1]: purescript-contrib/purescript-parsing#154
1 parent 901ebe6 commit 1cb444d

File tree

8 files changed

+1710
-959
lines changed

8 files changed

+1710
-959
lines changed

copy.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const { copyFileSync } = require("fs");
1+
import { copyFileSync } from "fs";
22

3-
copyFileSync("insect.js", "web/insect.js");
43
copyFileSync("node_modules/keyboardevent-key-polyfill/index.js", "web/keyboardevent-key-polyfill.js");
54
copyFileSync("node_modules/jquery/dist/jquery.min.js", "web/jquery.min.js");
65
copyFileSync("node_modules/jquery.terminal/js/jquery.terminal.min.js", "web/jquery.terminal.min.js");

index.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env node
22

3-
var os = require("os");
4-
var path = require("path");
5-
var Insect = require('./output/Insect/index.js');
3+
import * as Insect from "./output/Insect/index.js";
4+
import * as path from "path";
65

76
var insectEnv = Insect.initialEnvironment;
87

@@ -46,7 +45,8 @@ if (process.argv.length >= 4) {
4645
}
4746

4847
if (process.env.INSECT_NO_RC !== "true") {
49-
var lineReader = require("line-reader");
48+
var [os, lineReader] = await Promise.all([import("os"), import("line-reader")]);
49+
5050
var rcFile = path.join(os.homedir(), ".insectrc");
5151
lineReader.eachLine(rcFile, function (line) {
5252
var res = runInsect(Insect.fmtPlain, line);
@@ -67,18 +67,14 @@ if (process.env.INSECT_NO_RC !== "true") {
6767
startInsect();
6868
}
6969

70-
function startInsect() {
70+
async function startInsect() {
7171
var interactive = process.stdin.isTTY;
7272

7373
if (interactive) {
74-
var readline = require('readline');
75-
var xdgBasedir = require('xdg-basedir');
76-
var path = require('path');
77-
var clipboardy = require('clipboardy');
78-
var fs = require('fs');
74+
var [fs, clipboardy, readline, xdgBasedir] = await Promise.all([import("fs"), import("clipboardy"), import("readline"), import("xdg-basedir")]);
7975

8076
// Open the history file for reading and appending.
81-
var historyFd = fs.openSync(path.join(xdgBasedir.data, "insect-history"), 'a+');
77+
var historyFd = fs.openSync(path.join(xdgBasedir.xdgData, "insect-history"), 'a+');
8278

8379
var maxHistoryLength = 5000;
8480

@@ -161,11 +157,11 @@ function startInsect() {
161157

162158
rl.prompt();
163159
} else {
164-
// Read from non-interactive stream (shell pipe)
165-
166160
if (typeof lineReader === "undefined") {
167-
var lineReader = require("line-reader");
161+
var lineReader = await import("line-reader");
168162
}
163+
164+
// Read from non-interactive stream (shell pipe)
169165
lineReader.eachLine(process.stdin, function(line) {
170166
var res = runInsect(Insect.fmtPlain, line);
171167
if (res) {

0 commit comments

Comments
 (0)