Usage
Installation
npm install -D @monstermann/stdlib-transformpnpm add -D @monstermann/stdlib-transformyarn add -D @monstermann/stdlib-transformbun add -D @monstermann/stdlib-transformnub add -D @monstermann/stdlib-transformaube add -D @monstermann/stdlib-transformSetup
Vite, Rolldown, tsdown
import { stdlib } from "@monstermann/stdlib-transform"
import { defineConfig } from "vite"
export default defineConfig({
plugins: [stdlib()],
})import { stdlib } from "@monstermann/stdlib-transform"
import { defineConfig } from "rolldown"
export default defineConfig({
input: "src/index.ts",
plugins: [stdlib()],
})import { stdlib } from "@monstermann/stdlib-transform"
import { defineConfig } from "tsdown"
export default defineConfig({
entry: "src/index.ts",
plugins: [stdlib()],
})Bun
For Bun.build:
import { stdlibBun } from "@monstermann/stdlib-transform"
await Bun.build({
entrypoints: ["./src/index.ts"],
plugins: [stdlibBun()],
})
For bun run and bun test, register it in a preload:
import { stdlibBun } from "@monstermann/stdlib-transform"
import { plugin } from "bun"
plugin(stdlibBun())
preload = ["./preload.ts"]
[test]
preload = ["./preload.ts"]
Bun only uses the first plugin that returns something for a file. With other plugins, call transform(code, path) from your own instead.
Options
| Option | Default | Description |
|---|---|---|
include |
/\.m?[jt]sx?(?:\?.*)?$/ |
Only files whose path matches one of these are transformed. |
exclude |
Files whose path matches one of these are skipped. | |
debug |
false |
true, or a RegExp of paths: prints what is being replaced. |
enforce |
"pre" or "post", not for Bun. |
Dependencies in node_modules are never transformed.