Skip to content

Commit 2ae112c

Browse files
committed
wip - bun docs update
1 parent 4fbcbb8 commit 2ae112c

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

packages/varlock-website/astro.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export default defineConfig({
101101
items: [
102102
{ label: 'Overview', slug: 'integrations/overview' },
103103
{ label: 'JavaScript / Node.js', slug: 'integrations/javascript' },
104+
{ label: 'Bun', slug: 'integrations/bun' },
104105
{ label: 'Next.js', slug: 'integrations/nextjs' },
105106
{ label: 'Vite-based', slug: 'integrations/vite' },
106107
{ label: 'Astro', slug: 'integrations/astro' },

packages/varlock-website/src/components/ExecCommandWidget.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const { command, showBinary = true, dlx = false } = Astro.props;
2323
<TabItem label="vlt">
2424
<Code code={`${dlx ? "vlx" : "vlx --"} ${command}`} lang="bash" />
2525
</TabItem>
26+
<TabItem label="bun">
27+
<Code code={`${dlx ? "bunx" : "bun run"} ${command}`} lang="bash" />
28+
</TabItem>
2629
{
2730
showBinary && (
2831
<TabItem label="standalone binary">

packages/varlock-website/src/components/InstallJsDepsWidget.astro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@ const packagesStr = Array.isArray(packages) ? packages.join(" ") : packages;
3636
lang="bash"
3737
/>
3838
</TabItem>
39+
<TabItem label="bun">
40+
<Code
41+
code={`bun ${remove ? "remove" : "add"} ${dev ? "-D " : ""}${packagesStr}`}
42+
lang="bash"
43+
/>
44+
</TabItem>
3945
</Tabs>

packages/varlock-website/src/components/WorksWithLogoList.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ const languagesLogos: LogoItem[] = [
3030
icon: "simple-icons:nodedotjs",
3131
href: "/integrations/javascript/",
3232
},
33+
{
34+
title: "Bun",
35+
icon: "simple-icons:bun",
36+
href: "/integrations/bun/",
37+
},
3338
{
3439
title: "Python",
3540
icon: "simple-icons:python",
@@ -50,11 +55,6 @@ const languagesLogos: LogoItem[] = [
5055
icon: "simple-icons:php",
5156
href: "/integrations/other-languages/",
5257
},
53-
{
54-
title: "Rust",
55-
icon: "simple-icons:rust",
56-
href: "/integrations/other-languages/",
57-
},
5858
{
5959
title: "...and more",
6060
icon: "simple-icons:gnubash",
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Bun
3+
description: How to integrate Varlock with a Bun-powered JavaScript project
4+
---
5+
import { TabItem, Tabs } from "@astrojs/starlight/components";
6+
import ExecCommandWidget from '@/components/ExecCommandWidget.astro';
7+
8+
For the most part, Varlock just works with Bun the same way it works with Node.js, and other JavaScript integrations work the same way.
9+
10+
11+
### Conflicts with Bun's .env loading
12+
Bun does its own automatic loading of `.env` files, based on the current value of `NODE_ENV` (or `BUN_ENV`), which it defaults to `development` if not set. This causes problems when bun decides to load `.env.development` and passes those env vars into varlock.
13+
14+
The best way to fix this is to [disable bun's automatic loading of `.env` files](https://bun.com/docs/runtime/environment-variables#disabling-automatic-env-loading) in your `bunfig.toml` file:
15+
```diff lang="toml" title="bunfig.toml"
16+
env = false
17+
```
18+
19+
You may also use the `--no-env-file` CLI flag when invoking scripts with `bun`/`bunx`.
20+
21+
Note that if you are building a standalone executable using `bun build`, you can use the `--no-compile-autoload-dotenv` flag to disable this behavior in the final executable.
22+
23+
24+
### Using a preload script (optional)
25+
One option we have with bun is to use a [preload script](https://bun.com/docs/runtime/bunfig#preload), configured in `bunfig.toml`. If you do this, you will no longer have to use `bun run varlock run -- yourscript` or use `import 'varlock/auto-load'` in your code!
26+
27+
```diff lang="toml" title="bunfig.toml"
28+
preload = ["varlock/auto-load"]
29+
```
30+
31+
:::caution[Do not use preload with framework integrations]
32+
Note that you should not do this if using a framework integration, as those integrations watch your `.env` files to trigger live-reloading.
33+
:::

0 commit comments

Comments
 (0)