Skip to content

Commit 972150b

Browse files
kxxtalerque
authored andcommitted
Setup Typst syntax highlighting via WASM module
1 parent 95ef548 commit 972150b

6 files changed

Lines changed: 558 additions & 27 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ static/%.css: sass/%.scss | node_modules
152152
%.avif: %.pdf
153153
$(MAGICK) -density 150 $< $@
154154

155-
static/codemirror.js: src/codemirror-bundle.js | node_modules
156-
$(NPX) esbuild $< --bundle --outfile=$@ --format=iife --conditions=import
155+
static/codemirror.js: src/codemirror-bundle.js build.js | node_modules
156+
$(NPX) node build.js
157157

158158
.PHONY: static
159159
static: $(PDFS) $(PREVIEWS) static/main.css static/codemirror.js

build.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { build } from "esbuild";
2+
import { wasmLoader } from 'esbuild-plugin-wasm'
3+
4+
await build({
5+
entryPoints: ["src/codemirror-bundle.js"],
6+
bundle: true,
7+
format: "esm",
8+
target: ["es2020"],
9+
sourcemap: false,
10+
loader: { ".wasm": "file" },
11+
outdir: "static",
12+
outbase: "src",
13+
assetNames: "[name]",
14+
entryNames: "codemirror",
15+
plugins: [wasmLoader()],
16+
publicPath: "/",
17+
supported: {
18+
'top-level-await': true,
19+
},
20+
});

0 commit comments

Comments
 (0)