isomor-babel

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

Babel integration for isomor, a framework that abstracts frontend-backend communication by allowing direct function calls from UI code. v2.0.2 (stable, maintained), ships TypeScript types, requires Node >=11. Unlike REST or GraphQL, isomor uses Babel transpilation to automatically separate client and server code within a single project directory. This package provides the Babel plugin that transforms imports and generates the necessary layers. Key differentiator: eliminates API boilerplate by keeping frontend and backend code together, with TypeScript support.

error Error: Requires Babel 7+
cause Using Babel version 6 or lower with isomor-babel v2.
fix
Upgrade Babel to version 7 or later.
error Error: Cannot find module '@babel/core'
cause Missing peer dependency @babel/core.
fix
Run npm install @babel/core --save-dev.
error TypeError: (0 , _isomorBabel.default) is not a function
cause Using CommonJS require() on an ESM default export.
fix
Use import isomorBabel from 'isomor-babel' instead of require().
error Error: Plugin configuration must be an array
cause Using v1.x object syntax in v2.x config.
fix
Change to ['isomor-babel', { ... }] in plugins array.
breaking Breaking change v1.x to v2.x: Plugin options format changed from object to array-tuple.
fix Update babel config to use ['isomor-babel', options] syntax.
deprecated Deprecated: v1.x is no longer maintained.
fix Upgrade to v2.x.
gotcha Missing peer dependency @babel/core causes runtime errors on 'Cannot find module'
fix Install @babel/core as a devDependency.
gotcha ESM-only package: require() fails with 'ERR_REQUIRE_ESM'
fix Use import syntax or dynamic import().
gotcha Node version <11 unsupported: throws 'Error: requires node >=11'
fix Upgrade Node.js to version 11 or later.
npm install isomor-babel
yarn add isomor-babel
pnpm add isomor-babel

Configure Babel plugin for isomor-babel, enabling direct server function calls from client code.

// babel.config.js
module.exports = {
  plugins: [
    ['isomor-babel', {
      client: 'src/client',
      server: 'src/server',
      shared: 'src/shared'
    }]
  ]
};

// Then, in your client code, call server functions directly:
// client/src/app.ts
import { greet } from '../server/hello';
const response = await greet('World');
console.log(response);