Replies: 4 comments 4 replies
-
|
+1 |
Beta Was this translation helpful? Give feedback.
-
|
Please checkout https://bun.sh/blog/bun-v1.1.25#embedding-files-in-standalone-executables-without-importing Mark as solved if this works for you. |
Beta Was this translation helpful? Give feedback.
-
|
linux cachyos bash, tried to embed a dir: test-project/client via 🥟 v1.3.1
❯ bun build --compile ./src/index.ts ./embed/**/*.png
error: ModuleNotFound resolving "./embed/**/*.png" (entry point)
test-project/client via 🥟 v1.3.1
❯ bun build --compile ./src/index.ts ./embed/**/*
error: ModuleNotFound resolving "./embed/**/*" (entry point)
test-project/client via 🥟 v1.3.1
❯ bun -v
1.3.1
test-project/client via 🥟 v1.3.1
❯ ll src/index.ts
-rw-r--r-- 1 majo majo 440 29. Okt 20:18 src/index.ts
test-project/client via 🥟 v1.3.1
❯ ll embed/
total 588
drwxr-xr-x 1 majo majo 72 29. Okt 19:35 .
drwxr-xr-x 1 majo majo 180 29. Okt 20:03 ..
-rw-r--r-- 1 majo majo 1657 29. Okt 19:27 index.html
-rw-r--r-- 1 majo majo 833 29. Okt 19:27 index.ts
-rw-r--r-- 1 majo majo 587739 26. Okt 04:06 logo.png
-rw-r--r-- 1 majo majo 2626 29. Okt 19:26 styles.cssid does build but give me an error when selecting the embed dir without start: desktop/maudio/client via 🥟 v1.3.1
❯ bun build --compile ./src/index.ts ./embed
[3ms] bundle 8 modules
[5ms] compile index
desktop/maudio/client via 🥟 v1.3.1
❯ ./index
EACCES: permission denied, mkdir '/$bunfs'
path: "/$bunfs",
syscall: "mkdir",
errno: -13,
code: "EACCES"
Bun v1.3.1 (Linux x64)please fix docs and/or implementation +1 |
Beta Was this translation helpful? Give feedback.
-
|
I found a solution that worked for me — maybe it will work for you too. The following works for me now, but it is not documented: desktop/maudio/client via 🥟 v1.3.1
❯ bun build --compile ./src/index.ts ./embed/**
[3ms] bundle 13 modules
[17ms] compile indexThe following will break: desktop/maudio/client via 🥟 v1.3.1 took 24s
❯ bun build --compile ./src/index.ts ./embed/**/*
error: ModuleNotFound resolving "./embed/**/*" (entry point)The following will not import the files from the './embed' directory (see desktop/maudio/client via 🥟 v1.3.1
❯ bun build --compile ./src/index.ts ./embed
[3ms] bundle 8 modules
[3ms] compile indexThis behaviour is very strange and should be documented. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I want to embed a nextJS static export into an executable program, like Golang does with embed, eg
//go:embed _ui/out/*How can I accomplish this Bun? I know you can load a file and make it available internally :
Is there a way to do the same for, say,
dist/*?Beta Was this translation helpful? Give feedback.
All reactions