A lightweight ESBuild and TSUP plugin (v0.3.1) that allows importing any file as raw text, base64, data URL, binary, or file content with zero configuration. Supports query suffixes like `?raw`, `?text`, `?base64`, `?dataurl`, `?binary`, `?file`, and automatically resolves file extensions. Useful for loading code files in documentation, interactive demos with react-live, or template-driven workflows. Actively maintained with monthly releases on npm, ships TypeScript types, and integrates seamlessly with ESBuild and TSUP builds.
npm install esbuild-raw-loaderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the plugin with ESBuild, import files with query suffixes, and configure custom loaders.
Update to >=0.3.0: npm install esbuild-raw-plugin@latest
Remove `ext` if you rely on default extension resolution, or keep for explicit control.
Place `raw()` before other esbuild plugins in the plugins array.
Add to declarations.d.ts: `declare module '*?raw' { const content: string; export default content; }`Specify full filename with extension to avoid ambiguity: import code from './file.ts?raw' instead of './file?raw'.
Ensure the plugin is correctly listed in `plugins` array and that you've imported `raw` properly.
Add `declare module '*?raw' { const content: string; export default content; }` to a .d.ts file.Use `const { raw } = require('esbuild-raw-plugin');` or `import { raw } from 'esbuild-raw-plugin';`.Update esbuild to >=0.8.0 and ensure you're using a compatible version.