bun icon indicating copy to clipboard operation
bun copied to clipboard

Change bunfig.toml to bun.json

Open Jarred-Sumner opened this issue 2 years ago • 4 comments

Jarred-Sumner avatar Jan 16 '23 20:01 Jarred-Sumner

I'm really interested in the reasoning here (any tweet threads / notes on why)?

Or is it just familiarity in the JS ecosystem + easier schema/autocomplete? (not sure if there is a JSON-schema TOML equivalent)

Zeko369 avatar Apr 26 '23 15:04 Zeko369

Actually, when i installed bun extension in vscode, i also expected autocompletions for configuration file.

And for json it's made quite simple: https://code.visualstudio.com/api/references/contribution-points#contributes.jsonValidation

b-fett avatar Oct 09 '23 11:10 b-fett

The JSON Schema format can actually be used to specify TOML (and YAML) configuration files as well with no major issues, since the data structures being described are close enough to being the same.

For example, Starship's TOML configuration file comes with an associated schema, and that schema can be used to validate and autocomplete your configuration with the appropriate tooling in your editor. Similarly there are a range of schemata available for YAML configuration files such as kustomization.yaml and yamllint.yaml.

Providing a suitable JSON Schema for bunfig.toml should enable the autocompletion @b-fett was hoping for, without needing to actually change the configuration format to JSON if TOML is still preferred for its human-friendliness. 🐱

00dani avatar Oct 21 '23 06:10 00dani

Does this schema exist yet? (Came here from Google looking for one)

mnpenner avatar Feb 10 '24 03:02 mnpenner

How about a code config file? bun.config.ts / bun.config.js. Very flexible but it could present a chicken-and-egg problem 😆.

silverwind avatar Mar 14 '24 00:03 silverwind

How about a code config file? bun.config.ts / bun.config.js. Very flexible but it could present a chicken-and-egg problem 😆.

We generally want to avoid any config which has to be interpreted/executed (for instance, JavaScript). That's because it will increase startup time.

Electroid avatar Mar 14 '24 00:03 Electroid

JS/TS files are also annoying for other tools that want to integrate. For example, I've wanted to tinker with some Babel configs before feeding it back to Babel but it's really hard to do when they have several different formats. Also my IDE likes to read configs to provide better tooling support and I bet they wouldn't be thrilled about having to execute another config file either.

On Wed, Mar 13, 2024, 5:50 PM Ashcon Partovi @.***> wrote:

How about a code config file? bun.config.ts / bun.config.js. Very flexible but it could present a chicken-and-egg problem 😆.

We generally want to avoid any config which has to be interpreted/executed (for instance, JavaScript). That's because it will increase startup time.

— Reply to this email directly, view it on GitHub https://github.com/oven-sh/bun/issues/1805#issuecomment-1996199818, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIPXJVR5JIV7AJYCVY2BZ3YYDX67AVCNFSM6AAAAAAT5DPOV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJWGE4TSOBRHA . You are receiving this because you commented.Message ID: @.***>

mnpenner avatar Mar 14 '24 01:03 mnpenner

Looks like they have a good reason to stick with what they have.

But to disagree with the comment above, more and more JS tooling now allows for js/ts configs (e.g. eslint & prettier enabled it recently, Playwright, Jest, framework configs, etc). The benefit of JS/TS is easier reuse of a common config among multiple projects, to provide consistency across projects within an organization, bc they can be exported and imported easily. As opposed to needing to copy & paste and then having them eventually become inconsistent across repos. This is a big benefit.

jasongitmail avatar Mar 14 '24 04:03 jasongitmail

Another benefit of TS/JS config is that it enables easily shareable configs via npm package.

silverwind avatar Mar 14 '24 09:03 silverwind

Let me also give a concrete example why bun.config.ts is needed: In Vitest, I like to configure the snapshot directory path via resolveSnapshotPath function. While bun does not have this option yet, it would never be possible to do with a non-code config format.

.config.ts files are already a quasi-standard among modern JS/TS tooling, and I definitely think bun should follow too.

silverwind avatar Mar 16 '24 15:03 silverwind