@jsheaven/read-config-file
Tiny library to read config files like
your.config.js
,your.config.mjs
,your.config.ts
,your.conifg.json
oryour.config.json5
from disk.
User Stories
- As a developer, I want to read config files for my project/library/framework
- As a developer, I don't want to write that code again and again
Features
✅ Reads and evalutates config files from disk:.js
,.mjs
,.ts
,.json
and.json5
✅ Available as a simple API and simple to use CLI✅ Just636 bytes
nano sized (ESM, gizpped)✅ Tree-shakable and side-effect free✅ Runs on Windows, Mac, Linux, CI tested✅ First class TypeScript support✅ 100% Unit Test coverage
Example usage (CLI)
NODE_OPTIONS='--experimental-vm-modules' npx @jsheaven/read-config-file --config ./test/some.config.ts
You need at least version 18 of Node.js installed.
Example usage (API, as a library)
- yarn:
yarn add @jsheaven/read-config-file
- npm:
npm install @jsheaven/read-config-file
Setup
yarn add @jsheaven/read-config-file
npm install @jsheaven/read-config-file
import { readConfigFile } from '@jsheaven/read-config-file'
const result = await readConfigFile({
configFilePath: './test/some.config.ts',
})
ESM
import { readConfigFile } from '@jsheaven/read-config-file'
const result = await readConfigFile({
configFilePath: './test/some.config.ts',
})
const { readConfigFile } = require('@jsheaven/read-config-file')
// same API like ESM variant
CommonJS
const { readConfigFile } = require('@jsheaven/read-config-file')
// same API like ESM variant