Registry / devops / esbuild-plugin-inline-functions

esbuild-plugin-inline-functions

JSON →
library0.2.0jsnpmunverified

An esbuild plugin that inlines JavaScript functions annotated with /* @inline */ hints, eliminating function call overhead. Version 0.2.0 (stable, active development). Unlike manual inlining or other tools, it automatically handles imports, dependencies, control flow (early returns, conditionals), variable scoping, and execution order. Supports both regular functions and arrow functions. Includes a /* @pure */ annotation to enable hoisting of duplicate pure function calls. Ships TypeScript declarations. Requires @babel/parser, @babel/traverse, @babel/types as peer dependencies. Works in any esbuild context (e.g., tsup, Vite, pure esbuild).

npm install esbuild-plugin-inline-functions
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-INL
E
esbuild-plugin-inline-functions
devopsjavascriptv0.2.0
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.

inlineFunctionsPlugin
import { inlineFunctionsPlugin } from 'esbuild-plugin-inline-functions'
import inlineFunctionsPlugin from 'esbuild-plugin-inline-functions'
Named export, not default. For CommonJS: const { inlineFunctionsPlugin } = require('esbuild-plugin-inline-functions'). Works with both ESM and CJS.
default
import { inlineFunctionsPlugin } from 'esbuild-plugin-inline-functions'
import inlineFunctionsPlugin from 'esbuild-plugin-inline-functions'
No default export exists; only the named export inlineFunctionsPlugin is available. Using default import will result in undefined.
require
const { inlineFunctionsPlugin } = require('esbuild-plugin-inline-functions')
CommonJS usage with named destructuring.

Shows basic usage with esbuild: import the plugin, apply it, and annotate functions with /* @inline */ to inline their calls.

import { inlineFunctionsPlugin } from 'esbuild-plugin-inline-functions'; import * as esbuild from 'esbuild'; await esbuild.build({ entryPoints: ['input.js'], outfile: 'output.js', plugins: [inlineFunctionsPlugin()], }); // input.js should contain functions annotated with /* @inline */ comment /* @inline */ function add(a, b) { return a + b; } console.log(add(1, 2));
Debug
Known issues
gotchaThe plugin uses @babel/parser which requires TypeScript files to have the syntax plugin? Double check: When using with TypeScript, ensure @babel/parser is configured to parse TypeScript. The plugin may not support TypeScript syntax out of the box.
fix
Set esbuild plugins after ensuring esbuild handles TypeScript (type stripping) or use the plugin only on JavaScript files. Alternatively, verify if plugin version supports TypeScript via @babel/preset-typescript.
affects: 0.2.0
deprecatedIf using an older version of esbuild (pre-0.12), the plugin API may not be compatible. Always use esbuild >= 0.12.
fix
Update esbuild to version 0.12 or later.
affects: >=0.0.0
gotchaThe /* @inline */ hint is a comment, not a decorator or pragma. It must appear exactly before a function declaration (not expression) and in the exact /* @inline */ format, including the leading /* and trailing */
fix
Use /* @inline */ exactly; avoid // @inline or other whitespace variations.
affects: 0.2.0
breakingIn version 0.1.0, the plugin used a different API? (Check changelog). Version 0.2.0 changed how hints are parsed? Currently no known breaking changes, but be aware of potential future ones.
fix
Pin to 0.2.0 or check release notes for breaking changes.
affects: >=0.2.0
Errors
Common errors & fixes
Error: Cannot find module '@babel/parser'
Missing peer dependency @babel/parser.
fix
Run npm install @babel/parser@^7.26.3
TypeError: inlineFunctionsPlugin is not a function
Default import used instead of named import.
fix
Use import { inlineFunctionsPlugin } from 'esbuild-plugin-inline-functions';
Error: The plugin must be called with no arguments?
Inline functions plugin expects no arguments (or an options object?). Current docs show no arguments.
fix
Call inlineFunctionsPlugin() without arguments. If options are needed in future, check docs.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
@babel/parserrequiredParses JavaScript/TypeScript source code to detect inline hints.
@babel/traverserequiredTraverses AST to find function declarations and calls for inlining.
@babel/typesrequiredProvides AST node type utilities used during traversal.
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-inline-functions — npm install esbuild-plugin-inline-functions · libregistry