UNPKG

aroma-jsx-engine

Version:

A lightweight and flexible JSX/TSX engine for rendering React components in Node.js applications. Designed to work seamlessly with the [`aroma.js`](https://www.npmjs.com/package/aroma.js) framework, this package allows you to compile and render JSX/TSX co

19 lines (14 loc) 510 B
const fs = require('fs'); const path = require('path'); const { compile } = require('./jsxCompiler'); function loadFromFile(filePath) { try { const absolutePath = path.resolve(filePath); const jsxCode = fs.readFileSync(absolutePath, 'utf-8'); const jsxComponent = compile(jsxCode); return jsxComponent; } catch (error) { throw new Error(`Failed to load JSX from file: ${error.message}`); } } module.exports = { compile, loadFromFile };