@layerfig/parser-json5
This parser allows you to load configuration from .json, .jsonc, or .json5
files.
-
Install the dependency.
Terminal window npm install @layerfig/parser-json5Terminal window pnpm install @layerfig/parser-json5Terminal window bun add @layerfig/parser-json5Terminal window yarn add @layerfig/parser-json5 -
Create your configuration files.
-
Add the parser to your
ConfigBuilder
.import { ConfigBuilder } from "@layerfig/config";import json5Parser from "@layerfig/parser-json5";export const config = new ConfigBuilder({validate: (finalConfig, z) => {const schema = z.object({appURL: z.url(),port: z.number()})return schema.parse(finalConfig)},parser: json5Parser}).addSource("base.jsonc").build();
Your application is now configured to parse these file formats.