Registry / devops / esbuild-plugin-rawbundle

esbuild-plugin-rawbundle

JSON →
library0.2.2jsnpmunverified

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.

npm install esbuild-plugin-rawbundle
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-RAW
E
esbuild-plugin-rawbundle
devopsjavascriptv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import rawBundlePlugin from 'esbuild-plugin-rawbundle';
const rawBundlePlugin = require('esbuild-plugin-rawbundle');
Package is ESM-only; CommonJS require will fail.
rawBundle
import rawBundle from 'jquery?rawbundle'; // default export is a string
import { rawBundle } from 'jquery?rawbundle';
The ?rawbundle suffix triggers the plugin on a per-import basis.
rawBundlePlugin options
rawBundlePlugin({ esbuildOptions: { format: 'esm', platform: 'browser' } })
rawBundlePlugin(new esbuild.BuildOptions())
esbuildOptions are a plain object, not an esbuild BuildOptions instance.

Demonstrates using esbuild-plugin-rawbundle to bundle a dependency as a raw string import via the ?rawbundle query.

import rawBundlePlugin from 'esbuild-plugin-rawbundle'; import * as esbuild from 'esbuild'; await esbuild.build({ entryPoints: ['src/index.js'], bundle: true, outfile: 'out.js', plugins: [ rawBundlePlugin({ esbuildOptions: { format: 'esm', platform: 'browser', write: false, }, }), ], }); // In src/index.js: // import myBundle from './lib?rawbundle'; // console.log(myBundle); // string of bundled content
Debug
Known issues
gotchaThe plugin only processes imports ending with `?rawbundle`. Other imports are passed through unmodified.
fix
Ensure your imports use the `?rawbundle` suffix exactly.
affects: >=0.0.0
gotchaIf `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.
fix
Do not set `write: true` in esbuildOptions passed to the plugin.
affects: >=0.0.0
deprecatedNo deprecation warnings known for this version.
fix
None.
affects: 0.2.2
gotchaThe plugin requires esbuild as a peer dependency. Incompatible esbuild versions may cause runtime errors.
fix
Ensure esbuild is installed and version matches plugin requirements.
affects: >=0.0.0
breakingNo breaking changes known for current version.
fix
None.
affects: 0.2.2
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-rawbundle'
Package not installed or incorrect import path.
fix
npm install --save-dev esbuild-plugin-rawbundle
TypeError: rawBundlePlugin is not a function
Using CommonJS require instead of ESM import.
fix
Use `import rawBundlePlugin from 'esbuild-plugin-rawbundle'` and ensure package.json has `"type": "module"`.
Error: The plugin 'rawbundle' does not have a valid setup callback
Plugin object not correctly passed to esbuild's plugins array.
fix
Ensure plugins array contains the result of rawBundlePlugin(options), not a different object.
Build failed with 1 error: error: No loader is configured for ".html" files
Importing a file type not handled by esbuild's default loaders without proper esbuildOptions.
fix
Add appropriate loader to esbuildOptions, e.g., `rawBundlePlugin({ esbuildOptions: { loader: { '.html': 'text' } } })`.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-rawbundle — npm install esbuild-plugin-rawbundle · libregistry