#Including Bun APIs for a script executable with NPX

1 messages · Page 1 of 1 (latest)

lucid pier
#

I'd like to build an script using bun APIs suitable for use by npx (e.g. no assumption on bun version or overall availability by the consumer).

As far as I can tell there's one maybe two approaches to this today but maybe some folks here have other insights.

Approach 1: pre-compile the matrix of supported OS architectures and have the primary executable script entrypoint select the correct binary to run.

E.g. npx my-thing would run the my-thing script in the my-thing package which would then depending on OS spawn the actual-my-thing executable.

My suspicion is that approach 1 is the only working approach today (unless node-gyp or similar is used to achieve effectively the same)

Possible Approach 2: build without compile and set --target=node. I see in the docs that the plan is for bun APIs to eventually get included into such a bundle but as far as I can tell that doesn't seem to have gotten implemented so far.

lucid pier
astral bear
#

Possible Approach 2: build without compile and set --target=node. I see in the docs that the plan is for bun APIs to eventually get included into such a bundle but as far as I can tell that doesn't seem to have gotten implemented so far.
If I have bun installed I don't want to pay the cost of this tho 😭