resource-bundler

raw JSON →
0.0.8 verified Sat Apr 25 auth: no javascript abandoned

A simple asset bundler for Express applications, inspired by the .NET MVC 4 bundler. It combines multiple CSS or JavaScript files into single bundles with optional minification via custom transformers. Version 0.0.8 is the latest, with low release cadence (no recent updates). Key differentiators: lightweight, Express integration, extensible via custom transformers. Not actively maintained; may have compatibility issues with modern Node.js.

error Cannot find module 'resource-bundler'
cause Package not installed or not properly linked.
fix
Run 'npm install resource-bundler' or check package.json dependencies.
error TypeError: bundler is not a function
cause Incorrect import: import { bundler } instead of default import.
fix
Use 'import bundler from "resource-bundler"' (default export).
error Error: Bundle 'css' not found
cause Bundle name mismatch or bundle not added before resolve.
fix
Ensure bundle name matches and bundle is added before calling resolve().
breaking The package is unmaintained and may not work with Node.js >= 12.
fix Consider alternatives like webpack or parcel.
gotcha Bundles are resolved relative to the public directory; incorrect paths may cause 404s.
fix Ensure file paths are correct and accessible via static middleware.
gotcha No built-in minification; transformers must be added manually.
fix Use custom transformers with uglify-js or clean-css.
npm install resource-bundler
yarn add resource-bundler
pnpm add resource-bundler

This shows how to set up Express with resource-bundler, create style and script bundles, and serve them on a route.

import express from 'express';
import bundler from 'resource-bundler';
import { StyleBundle, ScriptBundle } from 'resource-bundler';

const app = express();
const bundle = bundler(app, { production: process.env.NODE_ENV === 'production' });

bundle.add(new StyleBundle('css')
  .withFiles('public/css/reset.css', 'public/css/main.css'));

bundle.add(new ScriptBundle('js')
  .withFiles('public/js/lib/jquery.js', 'public/js/app.js'));

app.get('/', (req, res) => {
  res.send(`
    <link href="${bundle.resolve('css')}" rel="stylesheet">
    <script src="${bundle.resolve('js')}"></script>
  `);
});

app.listen(3000);