{"id":25373,"library":"esbuild-plugin-modify-entrypoints","title":"esbuild-plugin-modify-entrypoints","description":"esbuild plugin (v0.2.0) that allows modifying the contents of entrypoint files before they are processed by esbuild. It provides a callback function that receives the current entrypoint contents and can return modified contents along with an optional loader. Version 0.2.0 is the latest stable release, requires esbuild >=0.15 and Node.js >=18.12.0. Key differentiator: simple, focused plugin for editing entrypoint content without needing to manipulate esbuild's internal pipeline, unlike more complex alternatives.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/webdeveric/esbuild-plugin-modify-entrypoints","tags":["javascript","esbuild","plugin","modify","entrypoints"],"install":[{"cmd":"npm install esbuild-plugin-modify-entrypoints","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-modify-entrypoints","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-modify-entrypoints","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: provides esbuild build system and plugin API","package":"esbuild","optional":false}],"imports":[{"note":"Named export; default export is not available.","wrong":"import modifyEntrypointsPlugin from 'esbuild-plugin-modify-entrypoints'","symbol":"modifyEntrypointsPlugin","correct":"import { modifyEntrypointsPlugin } from 'esbuild-plugin-modify-entrypoints'"},{"note":"CommonJS require returns an object with the named export.","wrong":"const modifyEntrypointsPlugin = require('esbuild-plugin-modify-entrypoints')","symbol":"modifyEntrypointsPlugin","correct":"const { modifyEntrypointsPlugin } = require('esbuild-plugin-modify-entrypoints')"},{"note":"TypeScript users may want to import the options type for type-safe callbacks.","wrong":"","symbol":"ModifyEntrypointsPluginOptions","correct":"import type { ModifyEntrypointsPluginOptions } from 'esbuild-plugin-modify-entrypoints'"}],"quickstart":{"code":"const esbuild = require('esbuild');\nconst { modifyEntrypointsPlugin } = require('esbuild-plugin-modify-entrypoints');\nesbuild.build({\n  entryPoints: ['src/app.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    modifyEntrypointsPlugin(({ contents, path }) => {\n      // Prepend a console log to all entrypoint files\n      return {\n        contents: `console.log('Entry: ${path}');\\n${contents}`,\n        loader: 'ts',\n      };\n    }),\n  ],\n}).catch(() => process.exit(1));","lang":"javascript","description":"Demonstrates using the plugin with esbuild's CommonJS API to modify entrypoint contents by prepending a log statement."},"warnings":[{"fix":"Upgrade to 0.2.0 or later which provides both `contents` and `path`.","message":"The callback receives an object with only `contents` and `path`. Ensure you check for all expected properties.","severity":"gotcha","affected_versions":"<0.2.0"},{"fix":"Explicitly set the `loader` field in the return value to match your content's syntax (e.g., 'ts', 'js', 'tsx').","message":"Returning an object without a `loader` property may cause esbuild to use default loader, potentially mismatched.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the plugin on explicit entrypoints; for other files, use other esbuild plugins like svgr or CSS modules.","message":"This plugin only affects entrypoints listed in the `entryPoints` option; it does not affect imported modules.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always set the `loader` to avoid confusion; upgrade to 0.2.0+ for safer defaults.","message":"The `loader` option in the return value is optional; if omitted, the original loader from the entrypoint is used. However, in some versions misbehavior may occur.","severity":"deprecated","affected_versions":"<0.2.0"}],"env_vars":null,"search_vec":"'0.15':53 '0.2.0':45 '18.12.0':56 'allow':10 'along':39 'altern':77 'callback':26 'complex':76 'content':13,33,38,65 'current':31 'differenti':58 'edit':63 'entrypoint':5,15,32,64,82 'esbuild':2,6,22,52,70,79 'esbuild-plugin-modify-entrypoint':1 'file':16 'focus':60 'function':27 'intern':72 'javascript':78 'key':57 'latest':48 'loader':43 'manipul':69 'modifi':4,11,37,81 'need':67 'node.js':55 'option':42 'pipelin':73 'plugin':3,7,61,80 'process':20 'provid':24 'receiv':29 'releas':50 'requir':51 'return':36 'simpl':59 'stabl':49 'unlik':74 'v0.2.0':8 'version':44 'without':66","created_at":"2026-05-01T13:44:25.736303+00:00","updated_at":"2026-05-01T13:44:25.736303+00:00","problems":[{"fix":"Ensure your callback always returns an object with a `contents` string at minimum.","cause":"The callback returned undefined or an object without the required `contents`.","error":"Error: The plugin 'modify-entrypoints' must return an object with a `contents` property."},{"fix":"Verify the plugin is properly imported and passed in the `plugins` array.","cause":"The callback parameter is undefined, usually because the plugin was not added correctly.","error":"TypeError: Cannot destructure property 'contents' of 'undefined' or 'null'."},{"fix":"Double-check the file path in `entryPoints` and ensure it is correct relative to the working directory.","cause":"The entryPoints array references a file that doesn't exist.","error":"Error: esbuild: Failed to resolve entry point: Entry point 'foo' not found."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/webdeveric/esbuild-plugin-modify-entrypoints","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/esbuild-plugin-modify-entrypoints","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}