{"id":26031,"library":"oc-template-esm-compiler","title":"oc-template-esm-compiler","description":"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.","status":"active","version":"3.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/opencomponents/vite-templates","tags":["javascript","oc","opencomponents","esm","oc-template","typescript"],"install":[{"cmd":"npm install oc-template-esm-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add oc-template-esm-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add oc-template-esm-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for runtime compatibility with OpenComponents server infrastructure.","package":"oc-server","optional":false}],"imports":[{"note":"This package is ESM-only. CommonJS require will not work; use static import.","wrong":"const compile = require('oc-template-esm-compiler').compile","symbol":"compile","correct":"import { compile } from 'oc-template-esm-compiler'"},{"note":"TypeScript type import only; not a runtime value.","wrong":"import { CompileOptions } from 'oc-template-esm-compiler'","symbol":"CompileOptions","correct":"import type { CompileOptions } from 'oc-template-esm-compiler'"},{"note":"TypeScript type import only; not a runtime value.","wrong":"import { CompileResult } from 'oc-template-esm-compiler'","symbol":"CompileResult","correct":"import type { CompileResult } from 'oc-template-esm-compiler'"}],"quickstart":{"code":"import { compile } from 'oc-template-esm-compiler';\n\nconst result = await compile({\n  componentPath: '/path/to/component',\n  componentName: 'my-component',\n  ocServerUrl: 'http://localhost:3000/',\n  ocTemplate: 'oc-template-esm',\n  production: true,\n  watch: false\n});\n\nconsole.log('Compiled files:', result.files);\nconsole.log('Hash:', result.hash);","lang":"typescript","description":"Demonstrates compiling an ESM OC component with minimal options, showing the async compile function and typical result."},"warnings":[{"fix":"Use await compile(...) or .then() to get the result.","message":"The compile function is now async. Calling without await will return a Promise.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Rename 'componentDir' to 'componentPath' in the options object.","message":"The option 'componentDir' is deprecated in favor of 'componentPath'.","severity":"deprecated","affected_versions":">=2.0.0 <3.0.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 oc-template-esm-compiler --save-dev","cause":"Package not installed or module resolution failure.","error":"Cannot find module 'oc-template-esm-compiler'"},{"fix":"Use import { compile } from 'oc-template-esm-compiler' instead of require.","cause":"CommonJS require instead of ESM import.","error":"compile is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}