Skip to content

nyxblabs/buildkarium

Repository files navigation

cover npm version npm downloads bundle License

Buildkarium

🧱 An enchanting JavaScript build ecosystem!

πŸ“¦ Optimized bundler

Robust rollup based bundler that supports typescript and generates commonjs and module formats + type declarations.

πŸͺ„ Automated config

Automagically infer build config and entries from package.json.

πŸ“ Bundleless build

Integration with mimikra for generating bundleless dists with file-to-file transpilation.

✨ Passive watcher

Stub dist once using dynot and you can try and link your project without needing to watch and rebuild during development.

✍ Typiqus Generator

Integration with typiqus.

πŸ›‘οΈ Secure builds

Automatically check for various build issues such as potential missing and unused dependencies and fail CI.

CLI output also includes output size and exports for quick inspection.

βš™οΈ Usage

πŸ“„ Create src/index.ts:

export const log = (...args) => { console.log(...args) }

πŸ”„ Update package.json:

{
  "type": "module",
  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    }
  },
  "main": "./dist/index.cjs",
  "types": "./dist/index.d.ts",
  "files": [
    "dist"
  ]
}

πŸ”¨ Build with buildkarium:

npx buildkarium

βœ… Configuration is automatically inferred from fields in package.json mapped to src/ directory. For more control, continue with the next section.

βš™οΈ Configuration

πŸ“„ Create karium.config.ts:

export default {
  entries: [
    './src/index'
  ]
}

βœ… You can either use the buildkarium key in package.json or create a karium.config.{js,ts,json} file to specify the configuration.

βœ… See options here. πŸ“š

πŸ’‘ Example:

import { defineBuildConfig } from 'buildkarium'

export default defineBuildConfig({
    // If entries is not provided, will be automatically inferred from package.json
    entries: [
        // default
        './src/index',
        // mkdist builder transpiles file-to-file keeping original sources structure
        {
            builder: 'mimikra',
            input: './src/package/components/',
            outDir: './build/components'
        },
    ],

    // Change outDir, default is 'dist'
    outDir: 'build',

    // Generates .d.ts declaration file
    declaration: true,
})

🌱 Development

  • πŸ™ Clone this repository
  • πŸ”§ Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • πŸ“¦ Install dependencies using nyxi
  • πŸƒ Run interactive tests using nyxr dev

πŸ“œ License

MIT - Made with πŸ’ž