Skip to content

ESbuild🔗🔗

ESbuild automatically compiles and bundles all files into ECMAScript, including dependencies under node_modules and therefore Lightrun’s agent.

To get ESbuild to work with Lightrun, you need to exclude Lightrun from the bundle so the agent doesn’t get bundled.

Add the following flag to your ESbuild build command:

--external:lightrun

For example, in package.json:

{
  "scripts": {
    "build:esbuild": "esbuild --external:lightrun/* --platform=node --loader:.ts=ts --bundle --sourcemap index.ts --outdir=esout"
  }
}

Adding this flag instructs ESbuild to skip bundling Lightrun, ensuring the agent remains readable and functional (i.e., not obfuscated as part of the output bundle).


Last update: January 27, 2026