README
ahjs-worker-bundler
Make a worker bundle from a Node.js package.
How to use
Run this tool from a directory containing package.json. Ideally, it should be installed as a dev dependency and set as a script. For simplicity, all configuration for the bundle is derived from package.json values, mostly using standard fields:
// NOTE: Comments are not actually valid in JSON.
{
// Recommended to avoid accidentally publishing as a real npm package.
"private": true,
"files": [
// What files to include into the bundle, including the script files mentioned in "bin"/"directories.bin".
"**/*.js"
],
// If this is set, it must be a object mapping job types to the script that should be invoked to process their jobs.
// NOTE: If this is set, "directories.bin" cannot be set.
"bin": {
"jobTypeA": "path/to/handlerA.js",
"jobTypeB": "path/to/handlerB.js"
},
"directories": {
// If this is set, it is assumed that handlers are located at ${bin}/${jobType}.js.
// NOTE: If this is set, "bin" cannot be set.
"bin": "path/to/handlers/folder"
},
"engines": {
// If this is set, the Node.js version bundled will be compatible with this range.
"node": ">= 16 < 18.3"
},
"scripts": {
"build-bundle": "ahjs-wb"
},
"dependencies": {
// Any dependencies here will be installed in a Linux Docker container and bundled.
// NOTE: Other dependency types are not installed e.g. devDependencies, peerDependencies.
},
"devDependencies": {
// Replace asterisk with specific version range.
"@ahjs/worker-bundler": "*"
}
}
All other fields are ignored, so they can be used for other purposes.
The output file will be ahjs-worker.tar.gz
.