@pmb0/bun-plugin-nestjs
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

@pmb0/bun-plugin-nestjs

@pmb0/bun-plugin-nestjs is a Bun plugin designed to simplify the bundling process of NestJS applications. One key challenge is how NestJS checks for optional dependencies: It attempts to load them using require() (see this code snippet). If these dependencies are not installed, this approach typically leads to bundler errors.

@pmb0/bun-plugin-nestjs addresses this issue by marking any uninstalled dependencies as external, allowing the bundler to complete the process without failing due to missing dependencies.

Another challenge is that you can no longer rely on the Nest CLI and its associated compile-time steps. For example, compiler plugins from @nestjs/swagger won't run automatically. As a result, you'll need to manually add the necessary decorators to your code to ensure that metadata for Swagger and other tools is properly generated.

Other potential issues may arise depending on the specific tools or structure of your application. For instance, you might encounter difficulties with certain dynamic imports, reflection mechanisms, or loading module-related assets.

Getting Started

Add @pmb0/bun-plugin-nestjs to your dependencies.

bun add --dev @pmb0/bun-plugin-nestjs

Create a bun build script:

// build.ts
import { NestPlugin } from "@pmb0/bun-plugin-nestjs";

const out = await Bun.build({
  entrypoints: ["./src/main.ts"],
  format: "esm",
  minify: {
    identifiers: false,
    syntax: true,
    whitespace: true,
  },
  outdir: "/tmp/test",
  packages: "bundle",
  plugins: [NestPlugin],
  sourcemap: "linked",
  target: "node",
});

console.log("Build done", out.success ? "Success" : out);

Build the Nest app:

bun build.ts

Readme

Keywords

none

Package Sidebar

Install

npm i @pmb0/bun-plugin-nestjs

Weekly Downloads

443

Version

1.0.6

License

none

Unpacked Size

3.64 kB

Total Files

4

Last publish

Collaborators

  • pmb00