esbuild Adapter

Applies to

The @softarc/native-federation-esbuild package is a thin, framework-agnostic adapter that plugs the core builder into esbuild. It powers the React reference example and can be used with any stack where you drive your own build script — there is no CLI wrapper or framework coupling.

If you are on Angular, use the Angular adapter instead — it wraps this adapter and adds builder, schematics and dev-server integration. This section is for projects (React, Preact, Lit, plain TypeScript, …) that drive esbuild themselves.

What's in the Box

Piece Entry point Purpose
Builder runEsBuildBuilder(configPath, options) High-level entry point. Loads federation.config.js, runs the initial build, and — when watch: true — wires up the file watcher and rebuild queue. See Builder.
Low-level adapter createEsBuildAdapter(config) Returns an NFBuildAdapter (setup / build / dispose) for users who want to drive buildForFederation directly. See Build Adapters.
Build options EsBuildBuilderOptions Workspace-level options: outputPath, tsConfig, entryPoints, dev, watch, cachePath, … See Builder.
Adapter config EsBuildAdapterConfig esbuild-specific extension points: plugins, fileReplacements, compensateExports, loader. See Configuration.

Why an Adapter?

The core builder is intentionally bundler-agnostic — it orchestrates the federation build and delegates the actual bundling to an NFBuildAdapter. The esbuild adapter is that bridge for esbuild:

Install

npm i -D esbuild @softarc/native-federation @softarc/native-federation-esbuild

On the host page, you also want the orchestrator runtime for import-map + remote loading:

npm i @softarc/native-federation-orchestrator

In this Section

Prerequisites

A complete working example lives at native-federation-examples-react — React 18 + esbuild + Shadow-DOM custom element + orchestrator host page.