iMod Bundler

1.5.0 · active · verified Tue Apr 21

iMod is a command-line interface (CLI) and programmatic JavaScript API-based bundler specifically designed for creating small, efficient modules. It is powered by Rollup, abstracting much of its complexity to provide a streamlined experience. Currently at version 1.5.0, iMod offers integrated TypeScript type declaration generation and simplifies the setup for common module formats including ES Modules (ESM), CommonJS (CJS), and UMD. While a specific release cadence isn't detailed, it generally follows semantic versioning. Its key differentiators include an opinionated yet configurable build pipeline, a focus on ease of use for 'tiny modules,' and support for multiple configuration methods via `package.json` or dedicated configuration files like `imod.config.js`.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates programmatic initialization of iMod and execution of a build operation, logging success or failure.

import Imod from 'imod';
import path from 'path';

// Initialize iMod with the current working directory as the project root.
// Adjust 'cwd' if your project root is different from where this script runs.
const iModInstance = new Imod({
  cwd: path.resolve(__dirname, '..', '..') // Assumes script is in 'scripts/build.ts' and project root is two levels up
});

console.log('Starting iMod build process...');

iModInstance.build()
  .then(() => {
    console.log('iMod build completed successfully!');
    console.log('Check the ' + (iModInstance.config.outDir || './dist') + ' directory for compiled output.');
  })
  .catch((error: any) => {
    console.error('iMod build failed:', error);
    process.exit(1);
  });

// To run in development/watch mode:
// iModInstance.dev().then(() => {
//   console.log('iMod is now watching for changes...');
// });

view raw JSON →