Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.direnv
/.direnv/
/npm/
/src/main.wasm
/src/wasm_exec.js
39 changes: 39 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { build, emptyDir } from "@deno/dnt";
import denoJson from "./deno.json" with { type: "json" };

const command = new Deno.Command("go", {
args: ["build", "-o", "../main.wasm", "main.go"],
cwd: "src/go",
Expand All @@ -23,3 +26,39 @@ if (!wasmExecJs) {

await Deno.copyFile(wasmExecJs, "src/wasm_exec.js");
await Deno.chmod("src/wasm_exec.js", 0o644);

// Build npm package
await emptyDir("npm");

await build({
entryPoints: ["./mod.ts"],
outDir: "npm",
scriptModule: false,
shims: {
deno: "dev",
},
compilerOptions: {
lib: ["DOM", "ESNext"],
target: "Latest",
},
package: {
name: "publiccode-parser",
version: denoJson.version,
description: denoJson.description,
license: "EUPL-1.2",
repository: {
type: "git",
url: "git+https://github.com/italia/publiccode-parser-js.git",
},
bugs: {
url: "https://github.com/italia/publiccode-parser-js/issues",
},
devDependencies: {
"@types/golang-wasm-exec": "^1.15.2",
},
},
postBuild() {
Deno.copyFileSync("LICENSE", "npm/LICENSE");
Deno.copyFileSync("src/main.wasm", "npm/esm/src/main.wasm");
},
});
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
"types": ["@types/golang-wasm-exec"]
},
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.42.3",
"@std/assert": "jsr:@std/assert@^1.0.13",
"@types/golang-wasm-exec": "npm:@types/golang-wasm-exec@^1.15.2"
},
"publish": {
"exclude": ["!src/main.wasm", "!src/wasm_exec.js"]
},
"tasks": {
"build": "deno run --allow-env --allow-read --allow-run --allow-write build.ts"
"build": "deno run --allow-env --allow-net --allow-read --allow-run --allow-write build.ts"
},
"test": {
"permissions": {
Expand Down
58 changes: 57 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading