An ESBuild and TSUP plugin for importing files as raw text, base64, dataurl, binary, or file content. v0.3.1 is current, released in February 2025. The plugin supports query suffixes like ?raw, ?text, ?base64, ?binary, ?dataurl, ?file, and smart extension resolution. It uses a fast regex-based onLoad filter, requires no configuration for common cases, and works as both an ESBuild plugin and a TSUP esbuildPlugin. Differentiators include zero-config setup, TypeScript declarations, and fallback resolution for folders and missing extensions.
npm install esrawNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Set up ESBuild with the raw plugin and import a file as raw text.
Upgrade to esbuild-raw-plugin@^0.3.0
Use explicit extensions or upgrade to v0.1.0+ and rely on auto-resolution.
Use 'customLoaders' instead of 'ext'.
Add 'declare module "*?raw" { const content: string; export default content; }' to your declarations.d.tsUse 'customLoaders' to whitelist specific file types rather than relying on query suffixes.
Run 'npm install esbuild-raw-plugin --save-dev'
Use 'import { raw } from 'esbuild-raw-plugin''Add 'declare module "*?raw" { const content: string; export default content; }' to a .d.ts fileAdd 'customLoaders: { '.svg': 'text' }' to plugin options.No dependency data recorded yet.