{"id":25395,"library":"esbuild-plugin-rawbundle","title":"esbuild-plugin-rawbundle","description":"esbuild plugin that allows importing modules as bundled ESM strings via the `?rawbundle` query suffix. Version 0.2.2 is the latest stable release. This plugin processes imports like `import raw from 'jquery?rawbundle'` and returns the esbuild-bundled output as a default string export, using the specified esbuild options. It is maintained for esbuild plugin ecosystem integration. Differentiators: built on top of esbuild's internal bundling, supports any format/platform, and provides raw bundled content for dynamic use cases like code injection or embedding.","status":"active","version":"0.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/divriots/esbuild-plugin-raw-loader","tags":["javascript","vite","vite-plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-rawbundle","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-rawbundle","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-rawbundle","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CommonJS require will fail.","wrong":"const rawBundlePlugin = require('esbuild-plugin-rawbundle');","symbol":"default","correct":"import rawBundlePlugin from 'esbuild-plugin-rawbundle';"},{"note":"The ?rawbundle suffix triggers the plugin on a per-import basis.","wrong":"import { rawBundle } from 'jquery?rawbundle';","symbol":"rawBundle","correct":"import rawBundle from 'jquery?rawbundle'; // default export is a string"},{"note":"esbuildOptions are a plain object, not an esbuild BuildOptions instance.","wrong":"rawBundlePlugin(new esbuild.BuildOptions())","symbol":"rawBundlePlugin options","correct":"rawBundlePlugin({ esbuildOptions: { format: 'esm', platform: 'browser' } })"}],"quickstart":{"code":"import rawBundlePlugin from 'esbuild-plugin-rawbundle';\nimport * as esbuild from 'esbuild';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'out.js',\n  plugins: [\n    rawBundlePlugin({\n      esbuildOptions: {\n        format: 'esm',\n        platform: 'browser',\n        write: false,\n      },\n    }),\n  ],\n});\n\n// In src/index.js:\n// import myBundle from './lib?rawbundle';\n// console.log(myBundle); // string of bundled content","lang":"javascript","description":"Demonstrates using esbuild-plugin-rawbundle to bundle a dependency as a raw string import via the ?rawbundle query."},"warnings":[{"fix":"Ensure your imports use the `?rawbundle` suffix exactly.","message":"The plugin only processes imports ending with `?rawbundle`. Other imports are passed through unmodified.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Do not set `write: true` in esbuildOptions passed to the plugin.","message":"If `esbuildOptions.write` is not set to false, esbuild may write output files unexpectedly. The plugin internally sets `write: false` but if you override it, files can be written to disk.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"None.","message":"No deprecation warnings known for this version.","severity":"deprecated","affected_versions":"0.2.2"},{"fix":"Ensure esbuild is installed and version matches plugin requirements.","message":"The plugin requires esbuild as a peer dependency. Incompatible esbuild versions may cause runtime errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"None.","message":"No breaking changes known for current version.","severity":"breaking","affected_versions":"0.2.2"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install --save-dev esbuild-plugin-rawbundle","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'esbuild-plugin-rawbundle'"},{"fix":"Use `import rawBundlePlugin from 'esbuild-plugin-rawbundle'` and ensure package.json has `\"type\": \"module\"`.","cause":"Using CommonJS require instead of ESM import.","error":"TypeError: rawBundlePlugin is not a function"},{"fix":"Ensure plugins array contains the result of rawBundlePlugin(options), not a different object.","cause":"Plugin object not correctly passed to esbuild's plugins array.","error":"Error: The plugin 'rawbundle' does not have a valid setup callback"},{"fix":"Add appropriate loader to esbuildOptions, e.g., `rawBundlePlugin({ esbuildOptions: { loader: { '.html': 'text' } } })`.","cause":"Importing a file type not handled by esbuild's default loaders without proper esbuildOptions.","error":"Build failed with 1 error: error: No loader is configured for \".html\" files"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}