asset-mapper-esbuild
raw JSON → 1.0.1 verified Fri May 01 auth: no javascript
A manifest generator for ESBuild designed to integrate with Symfony AssetMapper (Mercure). Version 1.0.1, stable. It generates an asset manifest file during ESBuild builds, enabling Symfony's AssetMapper to resolve versioned asset URLs. This package bridges ESBuild's build output with Symfony's asset management system, providing a streamlined workflow for JavaScript/CSS assets in Symfony projects. It ships TypeScript definitions and requires esbuild >= 0.14.0 as a peer dependency. Relatively new with limited adoption.
Common errors
error Error: Cannot find module 'asset-mapper-esbuild' ↓
cause Package not installed or import path misspelled.
fix
Install the package: npm install asset-mapper-esbuild
error TypeError: assetMapperEsbuildPlugin is not a function ↓
cause Incorrect import (e.g., using default import as named import).
fix
Use default import: import assetMapperEsbuildPlugin from 'asset-mapper-esbuild'
error Error: Cannot find esbuild peer dependency ↓
cause esbuild not installed or version incompatible.
fix
Install esbuild >=0.14.0: npm install esbuild@^0.14.0
Warnings
gotcha Manifest file must not be excluded from version control if used in production to resolve asset paths. ↓
fix Ensure the generated manifest file (default: manifest.json) is committed to your repository or generated in the CI/CD pipeline.
deprecated The 'assetMap' option was removed in v1.0; use 'publicPath' and 'outputPath' instead. ↓
fix Replace 'assetMap' with 'publicPath' and 'outputPath' options.
gotcha ESBuild version must be >=0.14.0; older versions are incompatible. ↓
fix Update esbuild to version 0.14.0 or higher.
Install
npm install asset-mapper-esbuild yarn add asset-mapper-esbuild pnpm add asset-mapper-esbuild Imports
- assetMapperEsbuildPlugin wrong
const assetMapperEsbuildPlugin = require('asset-mapper-esbuild')correctimport { assetMapperEsbuildPlugin } from 'asset-mapper-esbuild' - AssetMapperEsbuildPluginOptions wrong
import { AssetMapperEsbuildPluginOptions } from 'asset-mapper-esbuild'correctimport type { AssetMapperEsbuildPluginOptions } from 'asset-mapper-esbuild' - default wrong
import { default } from 'asset-mapper-esbuild'correctimport assetMapperEsbuildPlugin from 'asset-mapper-esbuild'
Quickstart
import { assetMapperEsbuildPlugin } from 'asset-mapper-esbuild';
import * as esbuild from 'esbuild';
await esbuild.build({
entryPoints: ['src/app.js'],
bundle: true,
outdir: 'public/build',
plugins: [assetMapperEsbuildPlugin({
publicPath: '/build',
outputPath: 'public/build',
manifestFilename: 'manifest.json',
})],
});