@ninjutsu-build/bun

0.3.0 • Public • Published

bun - Ninjutsu Build

A package to create a ninjutsu-build rule for transpiling TypeScript to JavaScript using bun.

There are no rules in @ninjutsu-build/bun for bundling as this would require bun to output all of the files that have been bundled while processing a particular entry point. This would allow us to save this to an appropriate dyndep file and use this in the rule.

There are no rules in @ninjutsu-build/bun to execute JavaScript as this would require bun to output all the files that have been imported or required (or allow us to intercept those calls which is done with @ninjutsu-build/node) so we can create a dyndep file to capture all of the dependencies.

Installation

Make sure bun is installed by following their instructions.

Most likely you require both @ninjutsu-build/bun and @ninjutsu-build/code as a devDependency, which can be achieved by running the following npm command:

$ npm install @ninjutsu-build/core @ninjutsu-build/bun --save-dev

Basic Example

The following transpiles all *.test.ts files in the tests directory to JavaScript,

import { NinjaBuilder } from "@ninjutsu-build/core";
import { makeTranspileRule } from "@ninjutsu-build/bun";
import { globSync } from "glob";

const ninja = new NinjaBuilder();
const transpile = makeTranspileRule(ninja);

globSync("src/*.tests.ts", { posix: true }).map((ts) =>
 transpile({
    in: ts,
    out: join("$builddir", "dist", basename(file, extname(file)) + ".mjs"),
    args: "--target node",
  })
);

writeFileSync("build.ninja", ninja.output);

Package Sidebar

Install

npm i @ninjutsu-build/bun

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

3.34 kB

Total Files

3

Last publish

Collaborators

  • elliotgoodrich