{"id":25808,"library":"json-mirror-compiler","title":"JSON Mirror Compiler","description":"json-mirror-compiler is a TypeScript library (v0.4.12, pre-1.0, monthly releases) that compiles JSON Mirror specifications into executable code. It provides a compile function to transform JSON Pointer-based schema definitions into runtime implementations. Key differentiator: focuses on mirror patterns for bidirectional data mapping, unlike other JSON Pointer tools that only resolve paths. Ships TypeScript types.","status":"active","version":"0.4.12","language":"javascript","source_language":"en","source_url":"https://github.com/max-team/json-mirror-compiler","tags":["javascript","mirror","json-pointer","typescript"],"install":[{"cmd":"npm install json-mirror-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add json-mirror-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-mirror-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; no CommonJS support.","wrong":"const compile = require('json-mirror-compiler')","symbol":"compile","correct":"import { compile } from 'json-mirror-compiler'"},{"note":"Default export is available but undocumented; named import is preferred.","wrong":"const jsonMirrorCompiler = require('json-mirror-compiler')","symbol":"default export","correct":"import jsonMirrorCompiler from 'json-mirror-compiler'"},{"note":"TypeScript type import recommended for type-only usage.","wrong":"import { MirrorSpec } from 'json-mirror-compiler'","symbol":"MirrorSpec type","correct":"import type { MirrorSpec } from 'json-mirror-compiler'"}],"quickstart":{"code":"import { compile } from 'json-mirror-compiler';\n\nconst spec = {\n  source: { jsonPointer: '/data' },\n  target: { jsonPointer: '/mirrored' }\n};\n\nconst compiledFn = compile(spec);\nconst result = compiledFn({ data: { value: 42 } });\nconsole.log(JSON.stringify(result)); // {\"mirrored\":{\"value\":42}}","lang":"typescript","description":"Demonstrates basic usage of the compile function with a simple mirror spec."},"warnings":[{"fix":"Pin exact version in package.json and review changelog before updating.","message":"Package is pre-1.0 (v0.4.12); API may change without major version bump.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Update code to treat compile() output as a function rather than a static object.","message":"Known breaking change in v0.4.0: Return type of compile changed from object to function.","severity":"gotcha","affected_versions":">=0.4.0 <0.5.0"},{"fix":"Use ES import syntax or switch to a dynamic import if in a CommonJS context.","message":"ESM-only package; CommonJS require will throw an error.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Check type definitions at node_modules/json-mirror-compiler/dist/index.d.ts; contribute fixes if needed.","message":"TypeScript types shipped but may be incomplete in some versions.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install json-mirror-compiler@0.4.12` and ensure node_modules includes it.","cause":"Package not installed or mismatched version.","error":"Cannot find module 'json-mirror-compiler'"},{"fix":"Change to `import { compile } from 'json-mirror-compiler'`.","cause":"Using a CommonJS require() which doesn't work with ESM-only packages.","error":"SyntaxError: The requested module 'json-mirror-compiler' does not provide an export named 'compile'"},{"fix":"Ensure you call the compiled function: compile(spec)(input) or const fn = compile(spec); fn(input).","cause":"Using the return value of compile incorrectly (expecting object instead of function) since v0.4.0.","error":"TypeError: compile is not a function"},{"fix":"Make sure spec has both 'source' and 'target' objects with 'jsonPointer' strings.","cause":"Passing an incomplete spec object without source or target fields.","error":"Cannot read properties of undefined (reading 'jsonPointer')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}