Monopack

raw JSON →
0.2.6 verified Sat Apr 25 auth: no javascript

A JavaScript bundler for Node.js monorepo applications (v0.2.6, alpha quality). It bundles a single main.js from monorepo sources, produces a minimal package.json and yarn.lock for only used third-party dependencies, and installs them. Built on webpack with deterministic builds. Different from general bundlers (e.g., webpack, rollup) by focusing on monorepo workflow and offline deployment. Alpha stage with limited features and support for Node.js >=6.14.4 and Yarn >=1.3.2. Low release cadence (no updates since v0.2.1).

error Error: Cannot find module 'monopack'
cause Package not installed or used without npx/npm script.
fix
Install: npm install --save-dev monopack and use: npx monopack or ./node_modules/.bin/monopack
error Error: The value of --out-dir must be a directory
cause --out-dir used with a file path instead of directory.
fix
Provide a directory: --out-dir ./dist
error Error: Unknown command: --build
cause Option placed before command or wrong syntax.
fix
Use correct syntax: monopack build main.js
gotcha Yarn is required even if your project uses npm. Dependencies collection is deterministic only with Yarn.
fix Install Yarn globally or ensure it's available in PATH.
gotcha The --out-dir option defaults to a temporary directory; explicitly set it to avoid loss of output.
fix Use --out-dir ./dist or -d ./dist.
gotcha Dynamic requires (e.g., require(variable)) are not detected; use --with-extra-module to include them.
fix Add -m <package> for each dynamically required dependency.
gotcha The bundle includes only sources from the monorepo. Third-party dependencies are installed separately, not bundled.
fix Ensure third-party packages are in your monorepo's package.json.
npm install monopack-builder
yarn add monopack-builder
pnpm add monopack-builder

Installs monopack, creates a simple entry file, builds it to a directory, and runs the output bundle.

// Install locally
npm install --save-dev monopack

// Create a simple main.js entrypoint
console.log('Hello from monorepo!');

// Run build
npx monopack build main.js --out-dir ./dist

// Output includes: dist/main.js, dist/package.json, dist/yarn.lock, dist/node_modules
// Run the built app
node dist/main.js