@enalmada/bun-externals
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

bun-externals

What

Workaround for bun not having a way to define all node_modules as external https://github.com/oven-sh/bun/issues/6351

Installation

bun install -D @enalmada/bun-externals

Usage

// build.ts
/// <reference types="bun-types" />

import getExternalDependencies from '@enalmada/bun-externals';

export async function buildWithExternals(): Promise<void> {
  const externals = await getExternalDependencies();

  const result = await Bun.build({
    entrypoints: ['./src/index.ts'],
    outdir: './dist',
    target: 'node',
    external: externals,
    root: './src',
  });

  if (!result.success) {
    console.error('Build failed');
    for (const message of result.logs) {
      console.error(message);
    }
    throw new AggregateError(result.logs, 'Build failed');
  }
}

void buildWithExternals();

See build.ts for example

TODO

  • [ ] deprecate with a plugin or actual bun feature

Notes

Build

Contribute

Using changesets so please remember to run "changeset" with any PR that might be interesting to people on an older template. Although this isn't being deployed as a module, I would like to call out things worth keeping in sync.

/@enalmada/bun-externals/

    Package Sidebar

    Install

    npm i @enalmada/bun-externals

    Weekly Downloads

    582

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    267 kB

    Total Files

    44

    Last publish

    Collaborators

    • enalmada