#pkg for Bun?

1 messages · Page 1 of 1 (latest)

long moss
#

I can use pkg to bundle Node apps into a standalone executable. Is there a tool to do the same thing for Bun apps?

#

Because I'm making an app in JS, and want to use Bun for its supposedly better FFI performance, but if I can't package it into a standalone app I'll have to use Node

old vapor
long moss
#

sweet!
It is 93 MB compared to pkg's 43 MB output which is a lot bigger, but I suppose it's not that big of a deal and will probably be relatively miniscule once I start importing all the node modules this project will require.

#

Why is Bun so much bigger though?

old vapor
#

node doesn't have transpiler and other features that bun ships with

#

in future it will get smaller once fully customizable bun comptime build infra is in place

outer kayak
long moss
#

with minify

long moss
#

yeah, there should be a way to remove the transpiler and other features that bun ships with if your project doesn't need those features

long moss
# old vapor https://bun.sh/docs/bundler/executables
import { Window } from "skia-canvas";
let win = new Window(1023, 768);

doesn't seem to work with this

2 | var Aa=Object.create;var{getPrototypeOf:ta,defineProperty:wA,getOwnPropertyNames:ea}=Object;var La=Object.prototype.hasOwnProperty;var aa=(H,$,A)=>{A=H!=null?Aa(ta(H)):{};const t=$||!H||!H.__esModule?wA(A,"default",{value:H,enumerable:!0}):A;for(let e of ea(H))if(!La.call(t,e))wA(t,e,{get:()=>H[e],enumerable:!0});return t};var W=(H,$)=>()=>($||H(($={exports:{}}).exports,$),$.exports);var UA=W((ia)=>{function fa(){var H;if(ra){var $=new Error;H=A}else H=t;return H;function A(e){if(e)$.message=e.message,e=$,t(e)}function t(e){if(e){if(process.throwDeprecation)throw e;else if(!process.noDeprecation){var a="fs: missing callback "+(e.stack||e.message);if(process.traceDeprecation)console.trace(a);else console.error(a)}}}}function Ia(H){return typeof H==="function"?H:fa()}var FH=import.meta.require("path"),gH=!1,mH=import.meta.require("fs"),ra=process.env.NODE_DEBUG&&/fs/.test(process.env.NODE_DEBUG),pr=FH.normalize;if(gH)pH=/(.*?)(?:[\/\\]+|$)/g;else pH=/(.*?)(?:[\/]+|$)/g;var pH;if(gH)d$=/^(?:[a-zA-Z]:|[\\\/]{2}[^ | ... truncated 

TypeError: undefined is not an object (evaluating 'this.native[H]')
      at init (/$bunfs/root/openpaint3d:2:61713)
      at new SH (/$bunfs/root/openpaint3d:2:67106)
      at new U$ (/$bunfs/root/openpaint3d:2:64582)
      at /$bunfs/root/openpaint3d:2:102974

Bun v1.1.27 (Linux x64)
#

even if I put a direct link

import { Window } from "./node_modules/skia-canvas/lib/index";

it gives the same error

#

I think Bun's bundler/compiler is just broke. I guess I'll have to bundle it myself smh

#

the bundler can't find stuff either

bun build ./src/openpaint3d.js --outdir out
23 |       neon = Object.entries(require('./v6')).reduce( (api, [name, fn]) => {
                                         ^
error: Could not resolve: "./v6"
    at /home/vexcess/Desktop/openpaint-3d/node_modules/skia-canvas/lib/index.js:23:37
make: *** [Makefile:2: build] Error 1

old vapor
#

did you install it as trusted dependency?

#

bun doesnt run postinstall scripts if dependency isnt trusted

plucky grotto
#

yeah this package has a install script and insnt listed in default one (maybe it should be added)
-# im interested to know why the end user is expected to have cargo and all of this tho

long moss
long moss
#

even after adding as a trusted dependency and reinstalling it still throws the same error

old vapor
#

did you fully remove node modules and lock files?

long moss
#

no

#

now I did and still same error

old vapor
#

remove lock file node modules and also rm -rf ~/.bun/install/

long moss
#

still the same

old vapor
#

using latest bun?

#

oh i see the issue

#

you didn't specify target in build command

#

it's trying to build for browser by default

#

bun build --target=bun ...

long moss
#

just did bun upgrade and added --target=bun and still same error

#

I think Bun is just broken and I should use Node until its fixed

old vapor
#

it works fine

#

you are doing something wrong but i can't tell what

#

error: Could not resolve: "./v6" this error only happens if you build for browser

#

maybe you are using strange os?

long moss
#

I'm on Linux Mint