Registry / serialization / refs-compiler

refs-compiler

JSON →
library2.0.2jsnpmunverified

Compiler for YAML, JSON and INI files using path references. Version 2.0.2 is the latest stable release. The library resolves $ref references in configuration files, enabling modular composition of templates. Designed for Node.js 8+ with native Promises and async/await. Key differentiator: supports YAML, JSON, and INI formats with CLI and programmatic API. Active development with security fixes for js-yaml and handlebars dependencies.

npm install refs-compiler
INSTALL
IMPORT
SIG · REFS-COMPILER
R
refs-compiler
serializationjavascriptv2.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import compiler from 'refs-compiler'
✗ const compiler = require('refs-compiler')
ESM default export; CommonJS requires .default: const { default: compiler } = require('refs-compiler')
compiler
✓ import compiler from 'refs-compiler'
✗ import { compiler } from 'refs-compiler'
Default export, not named export since v2
default (via CommonJS)
✓ const { default: compiler } = require('refs-compiler')
✗ const compiler = require('refs-compiler')
CommonJS requires destructuring default; plain require returns the module object

Resolves $ref references in a YAML template and writes the compiled output to a file.

import path from 'path'; import compiler from 'refs-compiler'; const inputTemplate = path.resolve('/path/to/template.yaml'); const outputFile = path.resolve('/path/to/output.yaml'); try { const results = await compiler(inputTemplate, outputFile); console.log(`file created in ${results.outputFile}`); } catch (error) { console.error(`An error occurred: ${error.message}`); }
refs-compiler --version
Debug
Known issues
breakingESM-only since v2; CommonJS require must use .default
fix
Use import compiler from 'refs-compiler' or const { default: compiler } = require('refs-compiler')
affects: >=2.0.0
deprecatedNode.js <8 is not supported
fix
Upgrade Node.js to version 8 or higher
affects: <2.0.0
gotchaThe package uses native Promises; callbacks not supported
fix
Use async/await or .then() instead of callbacks
affects: >=2.0.0
breakingDefault export is the compiler function, not an object
fix
Do not destructure named exports; import the default export
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: compiler is not a function
CommonJS require without accessing .default
fix
const { default: compiler } = require('refs-compiler');
Cannot find module 'refs-compiler'
Package not installed or not in node_modules
fix
Run npm install refs-compiler --save-dev
SyntaxError: Unexpected token 'export'
Using ESM import in a CommonJS environment without transpilation
fix
Use CommonJS require with .default or set type: module in package.json
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
js-yamlrequiredYAML parsing and dumping
inioptionalINI file parsing
Agent activity
4 hits · last 30 days
node
4
Resources
refs-compiler — npm install refs-compiler · libregistry