metarhia-build
v0.0.2
Published
Metarhia Module Builder
Maintainers
Readme
Metarhia Module Builder
Installation
npm install --save-dev metarhia-buildThe metarhia-build CLI is available in the project (e.g. npx metarhia-build or via npm scripts).
Modes
Build (bundle library)
For libraries that ship a single bundled .mjs file.
- Create
build.jsonin the project root:
{ "order": ["error.js", "array.js", "async.js"] }Put CommonJS source files in
lib/as listed. Each file may use:const { a, b } = require('./internal.js');— internal, strippedconst { x } = require('external-pkg');— becomesimport { x } from './external-pkg.js';module.exports = { foo, bar };— becomesexport { foo, bar };- Multiline destructuring
requireis supported
Add to
package.json:
"scripts": {
"build": "metarhia-build"
}- Run
npm run build
Output: packagename.mjs (from package.json name) with: import block, concatenated file bodies (with // filename comments), and a combined export { ... } block.
Constraints: Node.js built-ins (node:*) are forbidden. Circular dependencies and unknown internal files produce build errors.
Link (symlink built packages)
For applications that depend on metarhia-build packages. Scans node_modules for packages with build.json, finds their .mjs bundles, and creates symlinks for static serving.
- Add to your app’s
package.json:
"scripts": {
"link": "metarhia-build link"
}- Ensure dependencies are built (each has a
.mjsinnode_modules/<pkg>/), then run:
npm run linkBy default, symlinks go to ./application/static. Custom path: npm run link ./public/vendor or npx metarhia-build link ./public/vendor.
Each built package’s packagename.mjs is symlinked as packagename.js in the target directory. Packages without a built .mjs are skipped.
License
Copyright (c) 2025–2026 Metarhia contributors.
MIT licensed. Part of Metarhia.
