Registry / web-framework / oc-template-esm-compiler

oc-template-esm-compiler

JSON →
library3.0.4jsnpmunverified

Compiler for ESM OC (OpenComponents) templates. This package provides the build/compile step for components using the oc-template-esm template type. It is part of the OpenComponents ecosystem, which enables server-side rendering of composable UI components. Current stable version is 3.0.4, with a release cadence aligned with the OC monorepo. Key differentiator: it specifically handles ESM (ES Module) output, targeting modern bundlers and runtimes. It requires oc-server ^4.0.0 as a peer dependency and ships TypeScript types.

npm install oc-template-esm-compiler
INSTALL
IMPORT
SIG · OC-TEMPLATE-ESM-CO
O
oc-template-esm-compiler
web-frameworkjavascriptv3.0.4
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.

compile
import { compile } from 'oc-template-esm-compiler'
const compile = require('oc-template-esm-compiler').compile
This package is ESM-only. CommonJS require will not work; use static import.
CompileOptions
import type { CompileOptions } from 'oc-template-esm-compiler'
import { CompileOptions } from 'oc-template-esm-compiler'
TypeScript type import only; not a runtime value.
CompileResult
import type { CompileResult } from 'oc-template-esm-compiler'
import { CompileResult } from 'oc-template-esm-compiler'
TypeScript type import only; not a runtime value.

Demonstrates compiling an ESM OC component with minimal options, showing the async compile function and typical result.

import { compile } from 'oc-template-esm-compiler'; const result = await compile({ componentPath: '/path/to/component', componentName: 'my-component', ocServerUrl: 'http://localhost:3000/', ocTemplate: 'oc-template-esm', production: true, watch: false }); console.log('Compiled files:', result.files); console.log('Hash:', result.hash);
Debug
Known issues
breakingThe compile function is now async. Calling without await will return a Promise.
fix
Use await compile(...) or .then() to get the result.
affects: >=3.0.0
deprecatedThe option 'componentDir' is deprecated in favor of 'componentPath'.
fix
Rename 'componentDir' to 'componentPath' in the options object.
affects: >=2.0.0 <3.0.0
Errors
Common errors & fixes
Cannot find module 'oc-template-esm-compiler'
Package not installed or module resolution failure.
fix
Run npm install oc-template-esm-compiler --save-dev
compile is not a function
CommonJS require instead of ESM import.
fix
Use import { compile } from 'oc-template-esm-compiler' instead of require.
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies
oc-serverrequiredPeer dependency required for runtime compatibility with OpenComponents server infrastructure.
Agent activity
2 hits · last 30 days
node
2
Resources
oc-template-esm-compiler — npm install oc-template-esm-compiler · libregistry