Registry / devops / f2e-middle-esbuild

f2e-middle-esbuild

JSON →
library0.11.3jsnpmunverified

f2e-middle-esbuild is a plugin-middleware for the f2e-server framework that integrates esbuild for fast JavaScript/TypeScript bundling and transpilation. Version 0.11.3 is the latest stable release. It allows configuring esbuild build options via an `.esbuildrc.js` file, supports external module splitting for faster dev builds, and provides a bundle size analyzer endpoint. Compared to standalone esbuild usage, it seamlessly integrates with f2e-server's middleware pipeline, lifecycle events, and file watching. The package ships TypeScript type definitions.

npm install f2e-middle-esbuild
INSTALL
IMPORT
SIG · F2E-MIDDLE-ESBUILD
F
f2e-middle-esbuild
devopsjavascriptv0.11.3
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.

BuildOptions
import type { BuildOptions } from 'f2e-middle-esbuild'
const { BuildOptions } = require('f2e-middle-esbuild')
BuildOptions is a TypeScript type export. Use type import to avoid runtime issues. The package is ESM and CJS compatible but types are only for TS.
default
import esbuildMiddleware from 'f2e-middle-esbuild'
const esbuildMiddleware = require('f2e-middle-esbuild').default
Default export is the middleware factory function. In CJS, require returns the default directly; .default is not needed.
EsbuildMiddlewareOptions
import type { EsbuildMiddlewareOptions } from 'f2e-middle-esbuild'
const { EsbuildMiddlewareOptions } = require('f2e-middle-esbuild')
EsbuildMiddlewareOptions is a TypeScript type for the middleware config object.

Shows minimum configuration for TypeScript bundling with f2e-middle-esbuild in a f2e-server project.

// .f2econfig.js module.exports = { middleware: [ { middleware: 'esbuild', watches: [/\.[jet]?sx?$/] } ] }; // .esbuildrc.js (created by copy from node_modules) /** @type { import('f2e-middle-esbuild').BuildOptions[] } */ let config = [ { entryPoints: { index: 'src/index.tsx' }, bundle: true, format: 'iife', loader: { '.tsx': 'tsx', '.ts': 'ts' }, sourcemap: true, target: 'chrome70' } ]; module.exports = config; // index.html <script src="src/index.tsx"></script>
Debug
Known issues
gotchaThe .esbuildrc.js file must be copied from node_modules initially: `cp ./node_modules/f2e-middle-esbuild/.esbuildrc.js ./`. Otherwise the middleware will not find the default config.
fix
Run the copy command as documented, or create your own config file with the correct structure.
affects: >=0.0.0
deprecatedThe option `ignore_external` is a custom parameter (not esbuild's). Its behavior may change in future versions.
fix
Avoid relying on custom options unless necessary; check changelog for updates.
affects: <=0.11.3
gotchaBundle size analyzer is accessed via /static/index.js.html (or based on entry name). This endpoint is only available in development mode and may not exist if the middleware configuration differs.
fix
Ensure the middleware is configured properly and the entry point name matches.
affects: >=0.0.0
breakingVersion 0.10.0 changed the configuration format from a single object to an array of BuildOptions (multiple configurations). Old single-object configs will break.
fix
Wrap your config in an array even if you have only one configuration.
affects: <0.10.0
gotchaThe external_splits feature requires `ignore_external` to be false and `external` array to be non-empty. If either condition isn't met, external_splits is silently ignored.
fix
Set `ignore_external: false` and provide at least one entry in `external`.
affects: >=0.10.0
Errors
Common errors & fixes
Error: Cannot find module 'f2e-server'
f2e-middle-esbuild requires f2e-server as a peer dependency. It is not installed automatically.
fix
Run `npm install f2e-server --save-dev` (or save) to install the peer dependency.
Error: ENOENT: no such file or directory, open '.esbuildrc.js'
The middleware expects an .esbuildrc.js file in the project root, but it doesn't exist.
fix
Copy the default config from node_modules: `cp ./node_modules/f2e-middle-esbuild/.esbuildrc.js ./` or create your own.
TypeError: f2eMiddleware is not a function
When using require('f2e-middle-esbuild') in CJS, the default export is the middleware function, but using .default may result in undefined.
fix
Use `const esbuildMiddleware = require('f2e-middle-esbuild');` without .default.
Upgrade
Version history
0.11.3latest on npm
Audit
Dependencies
f2e-serverrequiredPeer dependency; this is a middleware for f2e-server and requires it to run.
Agent activity
4 hits · last 30 days
node
4
Resources
f2e-middle-esbuild — npm install f2e-middle-esbuild · libregistry