forked from libffi/libffi
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_build_npm.ts
More file actions
116 lines (109 loc) · 3.48 KB
/
_build_npm.ts
File metadata and controls
116 lines (109 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* NPM Package Builder for libffi.wasm
* Creates NPM-compatible package from Deno-first source
*/
import { build, emptyDir } from "https://deno.land/x/dnt@0.38.1/mod.ts"
await emptyDir("./npm")
await build({
entryPoints: ["./src/lib/index.ts"],
outDir: "./npm",
shims: {
deno: true,
webAssembly: true,
},
package: {
name: "@discere-os/libffi.wasm",
version: "3.5.2",
description: "High-performance libffi foreign function interface library with WebAssembly and TypeScript-first API",
keywords: ["ffi", "wasm", "webassembly", "foreign-function-interface", "libffi", "c-interop"],
license: "MIT",
repository: {
type: "git",
url: "git+https://github.com/discere-os/discere-nucleus.git",
directory: "client/emscripten/libffi.wasm"
},
bugs: {
url: "https://github.com/discere-os/discere-nucleus/issues"
},
homepage: "https://github.com/discere-os/discere-nucleus/tree/main/client/emscripten/libffi.wasm",
author: {
name: "Discere OS Contributors",
url: "https://github.com/discere-os"
},
main: "./esm/lib/index.js",
module: "./esm/lib/index.js",
types: "./esm/lib/index.d.ts",
exports: {
".": {
"import": "./esm/lib/index.js",
"types": "./esm/lib/index.d.ts"
},
"./types": {
"import": "./esm/lib/types.js",
"types": "./esm/lib/types.d.ts"
}
},
files: [
"esm/",
"script/",
"README.md",
"LICENSE"
],
scripts: {
"test": "node script/test.js",
"bench": "node script/bench.js"
},
engines: {
"node": ">=18.0.0"
},
browser: {
"./esm/lib/index.js": "./esm/lib/index.js"
}
},
postBuild() {
// Copy WASM files and assets to NPM package
Deno.copyFileSync("install/wasm/libffi-main.js", "npm/esm/libffi-main.js")
Deno.copyFileSync("install/wasm/libffi-main.wasm", "npm/esm/libffi-main.wasm")
Deno.copyFileSync("install/wasm/libffi-side.wasm", "npm/esm/libffi-side.wasm")
Deno.copyFileSync("install/wasm/type-info.json", "npm/esm/type-info.json")
Deno.copyFileSync("LICENSE", "npm/LICENSE")
Deno.copyFileSync("README.md", "npm/README.md")
// Create package info for CDN distribution
const packageInfo = {
name: "@discere-os/libffi.wasm",
version: "3.5.2",
description: "High-performance libffi with WASM and TypeScript support",
main: "./esm/lib/index.js",
types: "./esm/lib/index.d.ts",
files: {
"main": "./esm/libffi-main.js",
"wasm": "./esm/libffi-main.wasm",
"side": "./esm/libffi-side.wasm",
"types": "./esm/type-info.json"
},
cdn: {
primary: "https://wasm.discere.cloud/libffi@3.5.2/",
fallback: [
"https://cdn.jsdelivr.net/npm/@discere-os/libffi.wasm@3.5.2/esm/",
"https://unpkg.com/@discere-os/libffi.wasm@3.5.2/esm/"
]
},
features: {
simd: true,
complexNumbers: true,
rawApi: true,
goClosures: true,
wasm32: true,
wasm64: false
},
buildDate: new Date().toISOString()
}
Deno.writeTextFileSync("npm/package-info.json", JSON.stringify(packageInfo, null, 2))
console.log("✅ NPM package built successfully")
console.log(" - ES modules in npm/esm/")
console.log(" - WASM binaries included")
console.log(" - Ready for CDN deployment")
},
})
console.log("\n🎉 Build complete! Ready to publish:")
console.log(" cd npm && npm publish")