{"id":25438,"library":"esbuild-raw","title":"esbuild-raw-plugin","description":"An ESBuild and TSUP plugin (v0.3.1) that imports files as raw text, base64, data URL, binary, or file content via query suffixes like ?raw, ?text, ?base64, ?dataurl, ?binary, and ?file. Supports smart extension resolution and custom loader mappings. Currently stable with monthly releases. Differentiates from similar plugins by supporting multiple output formats, zero-config setup, and compatibility with both esbuild and tsup.","status":"active","version":"0.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/react18-tools/esbuild-raw-plugin","tags":["javascript","esbuild","esbuild-plugin","tsup-plugin","raw-text-import","import-as-text","file-loader","raw-file-loader","code-import","typescript"],"install":[{"cmd":"npm install esbuild-raw","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-raw","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-raw","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v0.1.0; CommonJS require will not work.","wrong":"const raw = require('esbuild-raw-plugin')","symbol":"raw","correct":"import { raw } from 'esbuild-raw-plugin'"},{"note":"Default export is also available but typed as the same function; prefer named import for clarity.","wrong":"","symbol":"raw (default import)","correct":"import raw from 'esbuild-raw-plugin'"},{"note":"This is a TypeScript type, not a runtime value; use type import to avoid bundling issues.","wrong":"import { RawPluginOptions } from 'esbuild-raw-plugin'","symbol":"RawPluginOptions","correct":"import type { RawPluginOptions } from 'esbuild-raw-plugin'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { raw } from 'esbuild-raw-plugin';\n\nbuild({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'out.js',\n  plugins: [raw()],\n}).catch(() => process.exit(1));\n\n// In src/index.ts:\nimport code from './example.js?raw';\nconsole.log(code); // string content of example.js","lang":"typescript","description":"Shows basic setup with ESBuild and import of a file as raw text using the ?raw suffix."},"warnings":[{"fix":"Update to v0.3.1 for backward compatibility fixes.","message":"Version 0.3.0 changed binary loaders; ensure ?binary suffix works as expected.","severity":"breaking","affected_versions":">=0.3.0 <0.3.0"},{"fix":"Test that imports with suffixes work; if not, check for custom resolvers or other plugins.","message":"Query suffix like ?raw is resolved before extension; ensure your bundler configuration does not interfere with esbuild's resolver.","severity":"gotcha","affected_versions":"all"},{"fix":"Add `declare module '*?raw' { const content: string; export default content; }` to a .d.ts file.","message":"For TypeScript projects, you must add module declarations for suffixes like ?raw to avoid type errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `import code from './utils?raw'` instead of specifying full path.","message":"Version 0.1.0 introduced autocomplete extension resolution; direct filename may no longer be necessary.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to latest version: `npm install esbuild-raw-plugin@latest`","cause":"Using an older version (pre-0.1.0) that exported a factory instead of a direct plugin function.","error":"Error: The plugin \"esbuild-raw-plugin\" doesn't have a setup function"},{"fix":"Ensure `raw()` is included in the esbuild `plugins` array.","cause":"Missing esbuild plugin configuration; plugin not added to plugins array.","error":"Module not found: Error: Can't resolve './example.js?raw'"},{"fix":"Add `declare module '*?raw' { const content: string; export default content; }` to a `.d.ts` file.","cause":"Missing type declaration for ?raw imports.","error":"TypeScript error: Cannot find module './example.js?raw' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}