{"id":21632,"library":"oc-vite-compiler","title":"OC Vite Compiler","description":"OC-Vite-Compiler is an OC (OpenComponents) module that compiles view and server code using Vite. Version 6.0.0 is the latest stable release, with a focus on providing fast builds and HMR for OC components. It integrates Vite's bundling capabilities into the OC ecosystem, enabling ESM and TypeScript support. The package ships TypeScript types and is part of the OpenComponents toolchain. Release cadence is sporadic, tied to OC updates. Key differentiator: leverages Vite for modern, fast development experience versus traditional webpack-based compilers.","status":"active","version":"6.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/opencomponents/vite-templates","tags":["javascript","oc","opencomponents","typescript"],"install":[{"cmd":"npm install oc-vite-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add oc-vite-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add oc-vite-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; require() will fail.","wrong":"const compiler = require('oc-vite-compiler')","symbol":"default","correct":"import compiler from 'oc-vite-compiler'"},{"note":"Named export, not default.","wrong":"import ViteCompiler from 'oc-vite-compiler'","symbol":"ViteCompiler","correct":"import { ViteCompiler } from 'oc-vite-compiler'"},{"note":"Type-only export; use import type to avoid runtime overhead.","wrong":"import { ViteCompilerOptions } from 'oc-vite-compiler'","symbol":"type ViteCompilerOptions","correct":"import type { ViteCompilerOptions } from 'oc-vite-compiler'"}],"quickstart":{"code":"import compiler from 'oc-vite-compiler';\n\nconst options = {\n  componentPath: './src/components/my-component',\n  server: './src/server.js',\n  view: './src/view.js',\n  viteConfig: {}\n};\n\nexport async function compileComponent() {\n  try {\n    const result = await compiler(options);\n    console.log('Compiled successfully:', result.outputPath);\n  } catch (error) {\n    console.error('Compilation failed:', error);\n  }\n}\n\ncompileComponent();","lang":"typescript","description":"Demonstrates compiling an OC component using oc-vite-compiler with options for component path, server, and view files."},"warnings":[{"fix":"Upgrade Node.js to 16+.","message":"v6 drops support for Node.js < 16.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update from import compiler from 'oc-vite-compiler/legacy' to new API.","message":"v6 changed default export from object to function.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Use default export directly from 'oc-vite-compiler'.","message":"Using 'oc-vite-compiler/legacy' path is deprecated since v6.","severity":"deprecated","affected_versions":">=6.0.0 <7.0.0"},{"fix":"Remove 'root' and 'build.outDir' from viteConfig option.","message":"Vite config must not include 'root' or 'build.outDir' as they are overridden.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use dynamic import() or switch to ESM.","message":"ESM-only package: cannot be required() in CommonJS modules.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import statement or dynamic import() in ESM context.","cause":"Package is ESM-only, cannot be used with require().","error":"require() of ES Module /path/to/oc-vite-compiler/index.js from /path/to/project/index.js not supported."},{"fix":"Use default import from 'oc-vite-compiler'.","cause":"Legacy path removed in v6.","error":"Cannot find module 'oc-vite-compiler/legacy'"},{"fix":"Use 'import compiler from 'oc-vite-compiler'' for default export.","cause":"Importing default incorrectly (e.g., using ViteCompiler named export as default).","error":"TypeError: compiler is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}