You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to create an executable from my app using --compile option.
My app has https://www.npmjs.com/package/lighthouse as dependency.
The compilation process works fine, but at runtime, I have several errors related to .json files not found in the binary.
It seems that at compile time, bun transliterate .json files to .js file, according to its documentation.
However, locale management system of lighthouse try to read and parse some .json files (ar.json and so on), so they are unavailable in the binary, because they has been transliterated to .js file.
I have tried several workaround without any success, sadly (for example --loader .json:file, copy .json files before compilation process in the app's root directory and include them as assets…).
It seems that there is also the same kind of problem with .html file used as template by lighthouse.
Obviously, all is fine when I'm using -e lighthouse at compile time, but I don't want having lighthouse as external package.
Do you have a solution?
mageekguy@fedora:~/Tmp
4|1004> bun init
✓ Select a project template: Blank
+ .gitignore
+ package.json
+ index.ts
+ tsconfig.json (for editor autocomplete)
+ README.md
To get started, run:
bun run index.ts
bun install v1.2.5-canary.78 (94ab3007)
+ [email protected]
+ @types/[email protected]
6 packages installed [791.00ms]
mageekguy@fedora:~/Tmp
5|1005> bun install lighthouse
bun add v1.2.5-canary.78 (94ab3007)
installed [email protected] with binaries:
- lighthouse
- smokehouse
- chrome-debug
140 packages installed [1320.00ms]
mageekguy@fedora:~/Tmp
6|1006> vi app.js
mageekguy@fedora:~/Tmp
7|1007> bun build ./app.js --compile --outfile=./compiled_app
[62ms] bundle 1611 modules
[73ms] compile ./compiled_app
mageekguy@fedora:~/Tmp
8|1008> ./compiled_app
69364 | }
69365 |
69366 | // node_modules/lighthouse/shared/localization/locales.js
69367 | import fs from "fs";
69368 | var moduleDir = getModuleDirectory(import.meta);
69369 | ar: JSON.parse(fs.readFileSync(`${moduleDir}/locales/ar.json`, "utf8")),
^
ENOENT: no such file or directory, open '/$bunfs/root/locales/ar.json'
path: "/$bunfs/root/locales/ar.json",
syscall: "open",
errno: -2,
code: "ENOENT"
at /$bunfs/root/compiled_app:69369:33
Bun v1.2.5-canary.78+94ab3007a (Linux arm64)
app.js contents is:
import lighthouse from "lighthouse"
console.log('Hello, lighthouse!')
What is the expected behavior?
'Hello, lighthouse!'
What do you see instead?
69364 | }
69365 |
69366 | // node_modules/lighthouse/shared/localization/locales.js
69367 | import fs from "fs";
69368 | var moduleDir = getModuleDirectory(import.meta);
69369 | ar: JSON.parse(fs.readFileSync(${moduleDir}/locales/ar.json, "utf8")),
^
ENOENT: no such file or directory, open '/$bunfs/root/locales/ar.json'
path: "/$bunfs/root/locales/ar.json",
syscall: "open",
errno: -2,
code: "ENOENT"
at /$bunfs/root/compiled_app:69369:33
Bun v1.2.5-canary.78+94ab3007a (Linux arm64)
The text was updated successfully, but these errors were encountered:
What version of Bun is running?
1.2.5-canary.78+94ab3007a
What platform is your computer?
OSX on M3
What steps can reproduce the bug?
I would like to create an executable from my app using
--compile
option.My app has https://www.npmjs.com/package/lighthouse as dependency.
The compilation process works fine, but at runtime, I have several errors related to
.json
files not found in the binary.It seems that at compile time,
bun
transliterate.json
files to.js
file, according to its documentation.However, locale management system of lighthouse try to read and parse some
.json
files (ar.json
and so on), so they are unavailable in the binary, because they has been transliterated to.js
file.I have tried several workaround without any success, sadly (for example
--loader .json:file
, copy.json
files before compilation process in the app's root directory and include them as assets…).It seems that there is also the same kind of problem with
.html
file used as template bylighthouse
.Obviously, all is fine when I'm using
-e lighthouse
at compile time, but I don't want having lighthouse as external package.Do you have a solution?
app.js
contents is:What is the expected behavior?
'Hello, lighthouse!'
What do you see instead?
69364 | }
69365 |
69366 | // node_modules/lighthouse/shared/localization/locales.js
69367 | import fs from "fs";
69368 | var moduleDir = getModuleDirectory(import.meta);
69369 | ar: JSON.parse(fs.readFileSync(
${moduleDir}/locales/ar.json
, "utf8")),^
ENOENT: no such file or directory, open '/$bunfs/root/locales/ar.json'
path: "/$bunfs/root/locales/ar.json",
syscall: "open",
errno: -2,
code: "ENOENT"
Bun v1.2.5-canary.78+94ab3007a (Linux arm64)
The text was updated successfully, but these errors were encountered: