@electric-otter/bark.js
v2.0.5
Published
Essential web build tools.
Readme
Bark.js
Bark.js is a popular JS library for website builds and website frameworks. It provides a simple CLI for serving static files and compiling local C/C++ code to browser-ready JavaScript with Emscripten.
It includes:
- HTMX
- Svelte
- React
serve, for local browser testing- C and C++ compilation to JavaScript through Emscripten
- JS minification and project bundling
Install
Install locally in a project:
npm install @electric-otter/bark.jsOr install globally to use the CLI from anywhere:
npm install -g @electric-otter/bark.jsCLI Usage
If installed locally, run commands with npx bark. If installed globally, run bark directly.
Build
Build C and C++ files into JavaScript:
bark buildThe build command finds local .c, .cpp, .cxx, .h, .hpp, and .hxx files, follows local header includes recursively, supports extensionless includes such as #include <name> by resolving name.h, name.hpp, or name.hxx, compiles them to a self-contained output.js, minifies the result to output.min.js, then removes output.js and the generated emsdk folder. The compiled payload is baked into output.min.js instead of emitted as a separate .wasm file.
Bundle
Bundle all files into a .build folder with JS minification:
bark bundleThe bundle command finds every file in the current directory (excluding .build, .git, emsdk, and node_modules), creates a .build folder mirroring the project structure, minifies .js and .mjs files with terser, and copies all other files as-is. A summary is printed on completion.
Header Builds
Bark.js also compiles discovered headers through a generated standalone source file. This catches header errors early, even when a project has no direct .c or .cpp source that includes every local header.
In Bark.js 2.0.2, the standalone header compile supports headers with common prerequisite assumptions:
certs.his compiled after including BearSSL types and macros with#include <bearssl.h>.GL1Funcs.his compiled after defining OpenGL ES types through#include <GLES/gl.h>and providing a defaultGL_FUNCmacro when the project has not already defined one.
These compatibility preludes are only added to the generated standalone header source. Project source files and original headers are not rewritten.
Use --SkipErrors to continue without failing the command when build errors occur:
bark build --SkipErrorsThe CLI checks npm for a newer Bark.js release each time it runs and prints an update command when one is available.
Serve
Serve the current folder for testing:
bark serveHelp
Show CLI help:
bark helpLocal install examples:
npx bark build
npx bark build --SkipErrors
npx bark bundle
npx bark serve
npx bark helpNotes
- Bark.js creates or uses an
emsdkfolder while building. - Build output is written to
output.min.js. - Bundle output is written to
.build/. - Bark.js 2.0.2 improves standalone header compilation for BearSSL certificate headers and OpenGL function-list headers.
