oc-server-compiler is a foundational module within the OpenComponents (OC) micro-frontends framework, designed specifically to compile the server-side logic (`server.js` or `entry.server.ts`) of isomorphic OC components. These components encapsulate HTML, CSS, JavaScript, and optional server-side code, allowing for universal rendering. This package facilitates the transformation of a component's server-side JavaScript/TypeScript into an executable format, typically used by an OC registry for server-side rendering or by the OC CLI during component development and publishing. It is a core utility that ensures the component's data-fetching and model-composition logic is correctly processed for deployment. The current stable version is 4.0.0. While the OpenComponents project itself follows semantic versioning with releases driven by feature development and bug fixes, this compiler module's updates are tightly coupled with the broader framework's evolution. A key differentiator of OpenComponents is its language-agnostic approach to consumption, allowing components compiled by this module to be rendered and consumed by various backend technologies (e.g., C#, PHP, Java, Go) without requiring Node.js on the edge.
npm install oc-server-compilerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically use `oc-server-compiler` to compile a mock OpenComponents `server.js` file, simulating the build process for component server logic.
Upgrade your Node.js environment to version 12 or newer. Node.js 18 LTS or later is strongly recommended for OpenComponents development and production.
Ensure that files passed to the compiler adhere to the OpenComponents component specification, particularly the structure expected for a component's server-side logic. Use the `oc` CLI for standard component development workflows.
Review and update component templates and server-side logic to use modern JavaScript/TypeScript and template engine features. Consult the OpenComponents migration guides for specifics on template updates if issues arise.
When calling the `data` function directly or through a mock, ensure the `context` object is fully populated with all expected properties, including `params` and `headers`, as defined by the OpenComponents runtime environment.
If your `server.js` is intended to be an ESM module, ensure your `package.json` specifies `"type": "module"` in the component directory, or explicitly use `.mjs` extension. Otherwise, use CommonJS `module.exports = { ... };` syntax for compatibility.Ensure all server-side dependencies for the component are correctly installed (e.g., `npm install` in the component's directory) and accessible in the compilation environment. If publishing, confirm the registry supports resolving or bundles these dependencies.
No dependency data recorded yet.