OC ES6 Template Compiler
raw JSON → 8.0.0 verified Fri May 01 auth: no javascript
Compiles OC (OpenComponents) components using ES6 templates. Version 8.0.0 is the latest stable release. Part of the OpenComponents ecosystem, it provides a compiler for the oc-template-es6 template type. Differentiates from other template compilers by integrating specifically with OC's component architecture. Release cadence follows the OC ecosystem updates.
Common errors
error Cannot find module 'oc-template-es6-compiler' ↓
cause Package not installed.
fix
npm install oc-template-es6-compiler
error compiler.compile is not a function ↓
cause Using named import incorrectly on default export.
fix
Use default import: import compiler from 'oc-template-es6-compiler'
error TypeError: Cannot read properties of undefined (reading 'type') ↓
cause Passing undefined or null object to compile.
fix
Ensure a valid component object is passed.
error SyntaxError: Unexpected token '`' ↓
cause Require() used in ESM-only context or string not using backticks.
fix
Use import syntax and ensure template is a string literal.
Warnings
breaking Version 8.0.0 drops CommonJS support; use ESM imports only. ↓
fix Replace require() with import statements.
deprecated The 'compile' function will be removed in v9; use 'compiler' default export. ↓
fix Switch to default import: import compiler from 'oc-template-es6-compiler'.
gotcha Ensure 'oc' runtime is available; otherwise compile will fail silently. ↓
fix Install oc as a peer dependency: npm install oc.
gotcha Template strings must be valid ES6 syntax; otherwise compiler throws a generic error. ↓
fix Use backtick literals for templates.
Install
npm install oc-template-es6-compiler yarn add oc-template-es6-compiler pnpm add oc-template-es6-compiler Imports
- default wrong
const compiler = require('oc-template-es6-compiler')correctimport compiler from 'oc-template-es6-compiler' - Compiler
import { Compiler } from 'oc-template-es6-compiler' - compile wrong
const compile = require('oc-template-es6-compiler').compilecorrectimport { compile } from 'oc-template-es6-compiler' - TemplateType
import type { TemplateType } from 'oc-template-es6-compiler'
Quickstart
import compiler from 'oc-template-es6-compiler';
import oc from 'oc';
const component = {
type: 'oc-template-es6',
view: '<div>Hello {{name}}</div>',
model: { name: 'World' }
};
const compiled = compiler.compile(component);
console.log(compiled);
// Output: rendered HTML string