git.iko.soy/rowtype-yoga/purslint
on main help sign in
Add purs-backend-es optimizer for production builds

- npm run dist builds optimized single-file bundles (~500KB each) - ~40% faster than unoptimized dev builds - Updated FFI to work with both standard and optimized backends - Added build scripts: build, bundle, dist, test, dev:cli, dev:lsp ๐Ÿ’˜ Generated with Crush Assisted-by: Claude Opus 4.5 via Crush <crush@charm.land>

commit70655d56756b8607d96113bdc58ac38c8c3d1093 authorMark <mark.eibes@gmail.com> dateSun 25 Jan 2026, 19:37 (8 months ago) parent015b8bc
3 files changed+28โˆ’11
.gitignore+1 bin/purelint-lsp/src/LSP/Stdio.js+12โˆ’7 package.json+15โˆ’4
.gitignore+1
@@ -4,6 +4,7 @@ node_modules/
44.pulp-cache/
55output/
66output-*/
7+dist/
78generated-docs/
89.psc-package/
910.psc*
bin/purelint-lsp/src/LSP/Stdio.js+12โˆ’7
@@ -1,6 +1,11 @@
11// LSP stdio FFI for JavaScript
22import * as fs from 'fs';
3โˆ’import * as $Maybe from '../Data.Maybe/index.js';
3+
4+// PureScript Maybe representation that works for both standard and optimized backends
5+// Standard: { value0: x } for Just, Nothing.value for Nothing
6+// Optimized: { tag: 1, _1: x } for Just, { tag: 0 } for Nothing
7+const mkJust = (x) => ({ tag: 1, _1: x, value0: x });
8+const mkNothing = { tag: 0 };
49
510// Buffer for reading LSP messages
611let buffer = '';
@@ -30,7 +35,7 @@ export const readMessage = () => {
3035 // First check if we already have a complete message in buffer
3136 let msg = tryParseMessage();
3237 if (msg !== null) {
33โˆ’ return $Maybe.Just.create(msg);
38+ return mkJust(msg);
3439 }
3540
3641 // Need to read more data synchronously from stdin
@@ -43,18 +48,18 @@ export const readMessage = () => {
4348
4449 if (bytesRead === 0) {
4550 // EOF
46โˆ’ return $Maybe.Nothing.value;
51+ return mkNothing;
4752 }
4853
4954 buffer += chunk.toString('utf8', 0, bytesRead);
5055
5156 msg = tryParseMessage();
5257 if (msg !== null) {
53โˆ’ return $Maybe.Just.create(msg);
58+ return mkJust(msg);
5459 }
5560 }
5661 } catch (e) {
57โˆ’ return $Maybe.Nothing.value;
62+ return mkNothing;
5863 } finally {
5964 fs.closeSync(fd);
6065 }
@@ -75,9 +80,9 @@ export const logMessage = (msg) => () => {
7580// Parse JSON string to Foreign (returns Maybe Foreign)
7681export const parseJSON = (str) => {
7782 try {
78โˆ’ return $Maybe.Just.create(JSON.parse(str));
83+ return mkJust(JSON.parse(str));
7984 } catch (e) {
80โˆ’ return $Maybe.Nothing.value;
85+ return mkNothing;
8186 }
8287};
8388
package.json+15โˆ’4
@@ -3,13 +3,21 @@
33 "version": "0.1.0",
44 "description": "A linter for PureScript",
55 "type": "module",
6โˆ’ "main": "output/Main/index.js",
76 "bin": {
8โˆ’ "purelint": "./bin/purelint.js"
7+ "purelint": "./dist/purelint.js",
8+ "purelint-lsp": "./dist/purelint-lsp.js"
99 },
1010 "scripts": {
11โˆ’ "build": "purs compile 'lib/**/*.purs' 'bin/purelint-cli/**/*.purs' '.spago/**/*.purs'",
12โˆ’ "test": "node --experimental-vm-modules test.js"
11+ "build:cli": "spago build -p purelint-cli --output output-cli",
12+ "build:lsp": "spago build -p purelint-lsp --output output-lsp",
13+ "build": "npm run build:cli && npm run build:lsp",
14+ "bundle:cli": "purs-backend-es bundle-app --corefn-dir output-cli --main Main --platform node --to dist/purelint.js --int-tags",
15+ "bundle:lsp": "purs-backend-es bundle-app --corefn-dir output-lsp --main Main.LSP --platform node --to dist/purelint-lsp.js --int-tags",
16+ "bundle": "npm run bundle:cli && npm run bundle:lsp",
17+ "dist": "npm run build && npm run bundle",
18+ "test": "spago test",
19+ "dev:cli": "node bin/purelint.js",
20+ "dev:lsp": "node bin/purelint-lsp.js"
1321 },
1422 "keywords": [
1523 "purescript",
@@ -18,5 +26,8 @@
1826 "license": "MIT",
1927 "dependencies": {
2028 "spago": "^0.93.45"
29+ },
30+ "devDependencies": {
31+ "purs-backend-es": "^1.4.3"
2132 }
2233}