Skip to content

Commit a65d71b

Browse files
committedFeb 7, 2025
support bun single-file executable
1 parent 2bab5dd commit a65d71b

File tree

7 files changed

+450
-175
lines changed

7 files changed

+450
-175
lines changed
 

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*.blob
22
build/
3+
*.exe
4+
35
# Logs
46
logs
57
*.log

‎README.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
# webview-nodejs-demo-app
2-
A full demo app for webview-nodejs to "Eat your own dogfood."
2+
A full demo app for webview-nodejs to "Eat your own dogfood".
33

44
```bash
5-
npm run
5+
npm start
6+
```
7+
8+
## About packaging
9+
10+
The time webview-nodejs-demo-app created is kind of special: the popular pkg is deprecated and node-sea is still experimental and doesn't support modules. So..., there's no good way to package the project in Node.js, but we can use Bun:
611

12+
```bash
13+
npx bun build --compile index.js server/main.js
714
```
815

9-
## Memo: About the packaging
16+
Bun supports cross-compiling but webview-nodejs doesn't. So before https://github.com/Winterreisender/webview-nodejs/issues/29 is done, it's recommend to build in each platform.
17+
18+
## License
1019

11-
The time webview-nodejs-demo-app created is kind of special: the popular pkg is deprecated and node-sea is still experimental and doesn't support modules. So,..., there's not a good way to package the project.
20+
Apache-2.0

‎bun.lock

+308
Large diffs are not rendered by default.

‎index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const {Worker} = require('worker_threads');
2-
const {Webview} = require('webview-nodejs').createRequire();
3-
1+
import {Worker} from 'worker_threads';
2+
import {Webview} from 'webview-nodejs';
3+
import dummy from "libwebview-nodejs/package.json" with { type: "file" };
44

55
const worker = new Worker("./server/main.js")
66

‎package-lock.json

+119-165
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"name": "webview-nodejs-demo-app",
3+
"type": "module",
34
"scripts": {
45
"start": "node index.js",
5-
"prestart": "npm run --prefix web build"
6+
"web:build": "npm run --prefix web build",
7+
"dist": "npx bun build --compile index.js server/main.js"
68
},
79
"dependencies": {
810
"express": "^4.21.2",
9-
"webview-nodejs": "^0.5.0-dev.1"
11+
"webview-nodejs": "^0.5.0-dev.2"
1012
}
1113
}

‎server/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const express = require('express').createRequire();
1+
import express from 'express';
22
const app = express()
33
const port = 3000
44

0 commit comments

Comments
 (0)
Please sign in to comment.