esbuild-plugin-preserve-directives

JSON →
library 0.0.11 ·javascript
verified May 1, 2026

An esbuild plugin that ensures directives like 'use client' and 'use strict' are preserved at the top of output files. Current stable version is 0.0.11. The plugin scans source files for specified directives before bundling and reinserts them into the corresponding output chunks. It supports regex-based include/exclude patterns and works with esbuild's metafile option for improved accuracy. Updated frequently with community contributions, it is primarily used with React Server Components and Node.js ESM/CJS builds. Key differentiator: it handles directives that esbuild would otherwise strip, with minimal overhead.

total hits 14
actors 3 distinct systems
last hit 4d ago AhrefsBot
GPTBot
2
Search engines
1
Humans
2

top countries 🇨🇦 Canada · 🇺🇸 United States · 🇮🇳 India · 🇬🇧 United Kingdom