bun-plugin-dlight

raw JSON →
0.5.0 verified Fri May 01 auth: no javascript

Bun build plugin for transpiling DLight views and models (.view.js/.view.ts files) inside Bun's bundler. v0.5.0, stable, with TypeScript types. Integrates directly into Bun.build() using Babel under the hood, without requiring Vite or Astro. Supports custom file filters and DLight preset options. Designed for Bun + DLight projects that want minimal tooling overhead.

error TypeError: dlightPlugin is not a function
cause Importing default export instead of named export.
fix
Use import { dlightPlugin } from 'bun-plugin-dlight'.
error Error: Cannot find module 'bun-plugin-dlight'
cause Package not installed or not in node_modules.
fix
Run 'bun add bun-plugin-dlight' to install.
error Bun.build: Plugin must be an object with a `name` property.
cause Passing an invalid plugin object (e.g., forgetting to call dlightPlugin()).
fix
Ensure you call dlightPlugin() as a function: plugins: [dlightPlugin()].
gotcha Plugin only works with Bun's Bun.build() API, not with other bundlers or runtimes.
fix Ensure you run the code with Bun and use Bun.build().
gotcha Requires Babel to be installed (comes bundled with Bun, but if custom Babel config is needed, it may conflict).
fix Avoid overriding Babel globally; rely on Bun's internal Babel.
breaking In v0.5.0, the plugin switched from CommonJS to ESM-only; require() no longer works.
fix Use import { dlightPlugin } from 'bun-plugin-dlight' instead of require().
npm install bun-plugin-dlight
yarn add bun-plugin-dlight
pnpm add bun-plugin-dlight

Shows how to import and use dlightPlugin inside Bun.build() with custom filter and options.

import { dlightPlugin } from 'bun-plugin-dlight';

const result = await Bun.build({
  outdir: './dist',
  entrypoints: ['./src/index.ts'],
  publicPath: '/build/',
  throw: true,
  plugins: [
    dlightPlugin({
      filter: /\.(view|model)\.[tj]s$/,
      options: {}
    }),
  ],
});

console.log('Build output:', result.outputs);