Registry / web-framework / hanami-assets

hanami-assets

JSON →
library2.3.2jsnpmunverified

An esbuild plugin for Hanami asset management, version 2.3.2 (stable, released March 2025). It integrates esbuild into the Hanami Ruby web framework pipeline, providing JavaScript/CSS bundling, fingerprinting, and asset helpers. Unlike standalone esbuild, this plugin respects Hanami's asset directory conventions and integrates with Hanami's view helpers for asset tags. Release cadence is irregular, tied to Hanami framework updates. It is ESM-only and ships TypeScript definitions.

npm install hanami-assets
INSTALL
IMPORT
SIG · HANAMI-ASSETS
H
hanami-assets
web-frameworkjavascriptv2.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import hanamiAssets from 'hanami-assets'
const hanamiAssets = require('hanami-assets')
ESM-only since v2; CommonJS require will error.
Plugin
import type { Plugin } from 'hanami-assets'
TypeScript users should use type import for Plugin type.
AssetEntry
import type { AssetEntry } from 'hanami-assets'
AssetEntry is a type representing manifest entries.
PluginOptions
import type { PluginOptions } from 'hanami-assets'
Options interface for configurePlugin.

Bundles a JavaScript entry point with esbuild and Hanami assets plugin, generating fingerprinted assets.

import hanamiAssets from 'hanami-assets'; import esbuild from 'esbuild'; await esbuild.build({ entryPoints: ['app/assets/javascripts/application.js'], outdir: 'public/assets', bundle: true, plugins: [ hanamiAssets({ outDir: 'public/assets', manifestPath: 'public/assets/manifest.json', fingerprint: true }) ] }); console.log('Build complete with fingerprinting and manifest.');
Debug
Known issues
gotchaPlugin must be placed before other esbuild plugins that modify asset paths.
fix
Ensure hanamiAssets is the first plugin in the plugins array.
affects: >=2.0.0
deprecatedglob v11 and earlier produce deprecation warnings; bump glob to ^13.0.6.
fix
Upgrade glob dependency to ^13.0.6.
affects: >=2.3.2
breakingESM-only from v2; CommonJS require throws error.
fix
Switch to ES module imports (import syntax) or use dynamic import().
affects: >=2.0.0
gotchaManifest file must be writable; plugin overwrites existing manifest.
fix
Ensure manifestPath is writable and not used by another process.
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Using CommonJS require() on an ESM-only package.
fix
Replace require with import or use dynamic import().
TypeError: hanamiAssets is not a function
Incorrect import or missing default export.
fix
Use `import hanamiAssets from 'hanami-assets'` (ESM).
Error: ENOENT: no such file or directory, open '.../public/assets/manifest.json'
Output directory does not exist or is not writable.
fix
Create the output directory before running the build or set manifestPath correctly.
Error: esbuild is not defined
Missing esbuild peer dependency.
fix
Install esbuild: npm install esbuild --save-dev
Upgrade
Version history
2.3.2latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency; the plugin wraps esbuild for asset bundling.
globrequiredRequired for file pattern matching in asset scanning.
Agent activity
6 hits · last 30 days
node
6
Resources
hanami-assets — npm install hanami-assets · libregistry