https://github.com/openwebf/node-wbc
WBC(WebF ByteCode Format) file implement for WebF.
https://github.com/openwebf/node-wbc
Last synced: 3 months ago
JSON representation
WBC(WebF ByteCode Format) file implement for WebF.
- Host: GitHub
- URL: https://github.com/openwebf/node-wbc
- Owner: openwebf
- License: apache-2.0
- Created: 2023-07-28T10:19:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-20T14:21:30.000Z (over 1 year ago)
- Last Synced: 2025-05-14T04:35:38.976Z (12 months ago)
- Language: C
- Homepage:
- Size: 7.5 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WBC
The [WBC](https://github.com/openwebf/rfc/blob/main/working/wbc1.en-US.md)(WebF bytecode file) file generator.
The WBC file is a specially designed binary file that contains pre-compiled JavaScript bytecodes and other assets, which could speed up the loading of WebF's application.
## Install
```
npm install @openwebf/wbc --save
```
## Cli Usage
**Install**
```
npm install @openwebf/wbc -g
```
**Convert JavaScript Into WBC file**
```
wbc -s /tmp/index.js -d /tmp
```
**Transform Inline Scripts in HTML**
```
wbc -s ./demo.html -d ./demo_wbc.html --convert-html
```
## Node Usage
**Convert JavaScript Into WBC buffer**
```javascript
const { compileJavaScriptToWbc } = require('@openwebf/wbc');
compileJavaScriptToWbc('function hello() { return 1 + 1};'); // the WBC bytes
```
**Transform Inline JavaScript Codes into WBC**
```javascript
const { transformInlineScriptToWbc } = require('@openwebf/wbc');
const transformedHtml = transformInlineScriptToWbc(`
console.log('helloworld');
`);
console.log(transformedHtml); /*
// The WBC binary contents
*/
```
## Contribute
**Generate compile_commands.json**
```
node-gyp configure -- -f gyp.generator.compile_commands_json.py
```
**Prebuild linux binary**
1. Install docker
2. Build local image with Dockerfile
```
docker build -t qjsc .
```
3. Enter into images
```
docker run --rm -it -v $(pwd):/project qjsc
```
4. Set up env in docker container
```
cd project
scl enable rh-nodejs12 bash
scl enable devtoolset-7 bash
```
5. Build your binary
```
npm install
npm run prebuild
```