An ESBuild and TSUP plugin that allows importing files as raw text, base64, binary, or data URLs with zero configuration. Version 0.3.1 is the latest stable release, with recent releases including backward-compatible fixes and binary loader improvements. Key differentiators: supports query suffixes like ?raw, ?text, ?base64, ?binary, ?dataurl, ?file; smart fallback extension resolution; custom loader mapping; regex-based native onLoad filter for performance; works with both ESBuild and TSUP. Developed under react18-tools, it is lightweight and targets documentation tools, live editors (react-live), markdown tooling, and template-driven workflows.
npm install esbuild-raw-pluginNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to add the raw plugin to ESBuild and import a file as raw text string.
Upgrade to >=0.3.0 for proper binary loader support.
Replace `import raw from 'esbuild-raw-plugin'` with `import { raw } from 'esbuild-raw-plugin'`.Ensure that the 'ext' option includes required extensions, e.g., raw({ ext: ['.ts', '.tsx'] })Use `defineConfig({ esbuildPlugins: [raw()] })` instead of `plugins: [raw()]` in tsup config.Add `declare module '*?raw' { const content: string; export default content; }` to a .d.ts file.Install the package: `npm install esbuild-raw-plugin --save-dev` and use ES module imports (e.g., `import { raw } from 'esbuild-raw-plugin'`).Add declare module '*?raw' { const content: string; export default content; }' to your global .d.ts file.Call the function: `plugins: [raw()]` instead of `plugins: [raw]`.
Use named import: `import { raw } from 'esbuild-raw-plugin'`.