0.3.9-3 • Published 10 months ago

bun-unconfig v0.3.9-3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

bun-unconfig

NPM version

Forked from unconfig

Changes in this fork
  • Adds Bun compatibility

Get Started

npm i bun-unconfig

unconfig supports loading ts, mjs, js, json by default.

import { loadConfig } from 'unconfig'

const { config, sources } = await loadConfig({
  sources: [
    // load from `my.config.xx`
    {
      files: 'my.config',
      // default extensions
      extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json', ''],
    },
    // load `my` field in `package.json` if no above config files found
    {
      files: 'package.json',
      extensions: [],
      rewrite(config) {
        return config?.my
      },
    },
    // load inline config from `vite.config`
    {
      files: 'vite.config',
      async rewrite(config) {
        const resolved = await (typeof config === 'function' ? config() : config)
        return resolved?.my
      },
    },
    // ...
  ],
  // if false, the only the first matched will be loaded
  // if true, all matched will be loaded and deep merged
  merge: false,
})
0.3.9-3

10 months ago

0.3.9-1

10 months ago