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.
Common errors
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().
Warnings
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.
Install
npm install resource-bundler yarn add resource-bundler pnpm add resource-bundler Imports
- bundler wrong
const bundler = require('resource-bundler')correctimport bundler from 'resource-bundler' - Bundle wrong
const { Bundle } = require('resource-bundler')correctimport { Bundle } from 'resource-bundler' - StyleBundle wrong
const StyleBundle = require('resource-bundler').StyleBundlecorrectimport { StyleBundle } from 'resource-bundler'
Quickstart
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);