Canner Compiler

raw JSON →
3.2.1 verified Fri May 01 auth: no javascript

Canner Compiler is a compiler for Canner CMS schema that processes schema definitions and generates configurations for CMS rendering. The latest stable version is 3.2.1. It is part of the Canner CMS ecosystem and is used to compile schema written in Canner's declarative format. Key differentiators: integrates deeply with React (>=16.3) and provides validation via ajv, relation HOCs for data fetching, and route management. Releases are sporadic with incremental features.

error Cannot find module 'canner-compiler'
cause Package not installed or incorrect import path.
fix
Run npm install canner-compiler and use import compiler from 'canner-compiler'.
error TypeError: compiler is not a function
cause Using named import incorrectly or using deprecated export.
fix
Use default import: import compiler from 'canner-compiler'.
error Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
cause Compiled output is an object, not a React element.
fix
The 'compiled' object is configuration; it must be used with Canner CMS renderers, not directly rendered as a component.
breaking Upgrade from v1 to v2 changed the export name from 'cannerCompiler' to default export.
fix Use default import: import compiler from 'canner-compiler'.
deprecated The 'compile' function is deprecated in v3.0.0; use default import instead.
fix Use import compiler from 'canner-compiler'.
breaking Dropped support for React <16.3 in v3.0.0. Only React >=16.3 is supported.
fix Upgrade React to >=16.3.
npm install canner-compiler
yarn add canner-compiler
pnpm add canner-compiler

Imports the compiler, compiles a simple CMS schema into a configuration object.

import compiler from 'canner-compiler';
import React from 'react';
import ReactDOM from 'react-dom';

const schema = {
  type: 'object',
  properties: {
    title: { type: 'string' },
    content: { type: 'string' }
  }
};

const compiled = compiler(schema);

function App() {
  return React.createElement('div', null, 'Compiled: ' + JSON.stringify(compiled));
}

ReactDOM.render(React.createElement(App), document.getElementById('root'));