BayLang Compiler

raw JSON →
1.2.2 verified Fri May 01 auth: no javascript

BayLang Compiler (v1.2.2) is the core compiler for the BayLang programming language, a full-stack language that automatically splits code into backend and frontend, supporting reactivity and server-side rendering. This package compiles BayLang to Node.js. Release cadence is irregular, with recent updates adding frontend component support (1.2.2), HTML template translation (1.2.1), and async/await features (1.2). Key differentiator: single codebase for both client and server with automatic platform adaptation. Designed for web application, website, and CRM development with an integrated constructor and widget ecosystem.

error Cannot find module 'bay-lang'
cause Package not installed or ESM import used in CommonJS environment.
fix
Run 'npm install bay-lang' and use dynamic import: 'const bayLang = await import('bay-lang');'
error TypeError: bayLang.compile is not a function
cause Default import instead of named import for compile.
fix
Use 'import { compile } from 'bay-lang';' instead of default import.
error SyntaxError: The requested module 'bay-lang' does not provide an export named 'compile'
cause Using named import with a version that exports differently (pre-1.0).
fix
Check package version; upgrade to >=1.0 or use default import 'import bayLang from 'bay-lang'' then bayLang.compile.
error Error: Unsupported target 'react'
cause Only 'nodejs' and 'php' targets supported; 'react' is not valid.
fix
Use target 'nodejs' for frontend or 'php' for backend.
breaking Version 1.0 removed legacy runtime core; existing projects must update imports.
fix Use new Runtime from 'bay-lang' instead of separate 'bay-lang-runtime' package.
deprecated The CLI command 'bay-lang-nodejs version' is deprecated; use 'bay-lang version'.
fix Use 'npx bay-lang version' or call programmatically.
gotcha ESM-only from version 1.0; CommonJS require() will fail.
fix Use import statements or dynamic import().
breaking Version 0.7.0 changed lambda syntax from 'fn' to 'pure' for functions.
fix Replace 'fn' keyword with 'pure' in BayLang source.
gotcha BayLang compiler requires Node.js >=14; older versions may have runtime issues.
fix Upgrade Node.js to version 14 or higher.
npm install bay-lang
yarn add bay-lang
pnpm add bay-lang

Compiles a simple BayLang function to Node.js JavaScript.

import { compile, version } from 'bay-lang';
import fs from 'fs';

const sourceCode = `
function greet(name: string) {
  return "Hello, " + name;
}
`;

try {
  const result = compile(sourceCode, { target: 'nodejs' });
  console.log('Compiled JS:', result.code);
  console.log('BayLang version:', version);
} catch (err) {
  console.error('Compilation failed:', err.message);
}