Isomor Transpiler

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

The isomor-transpiler package (v3.0.4) is the Babel-based transpiler for isomor, a full-stack framework that automatically generates API layers between frontend and backend in a single TypeScript project. Instead of writing REST/GraphQL endpoints, isomor transpiler extracts server-side function calls from client code and creates the necessary communication stubs. This package handles the actual transpilation of .ts/.tsx files, converting decorated functions into fetch calls. It is part of the isomor ecosystem, which aims to reduce boilerplate and enforce type safety across the stack. Release cadence is irregular but maintained. Key differentiator: seamless integration with TypeScript, allowing direct imports of server functions without manual API definition.

error Error: Cannot find module 'isomor-transpiler'
cause Package not installed or ESM-only; requires 'type': 'module' in package.json or .mjs extension.
fix
npm install isomor-transpiler (and ensure ESM context). If using CommonJS, use dynamic import.
error TypeError: isomor_transpiler_1.default is not a function
cause Using require() on ESM-only package; the package exports a default function but is not wrapped for CJS.
fix
Switch to import syntax: import transpiler from 'isomor-transpiler'
error SyntaxError: Unexpected token 'export'
cause The input code has top-level export but the transpiler may be configured in a non-module mode.
fix
Set sourceType: 'module' in Babel config or pass options to transpiler: { sourceType: 'module' }
breaking Node.js >=11 required; requires ESM support.
fix Update Node.js to v11 or later. If using older Node, stick with v2.x.
gotcha The transpiler output is designed to be used in a browser context; some Node.js specific APIs may not be polyfilled.
fix Ensure any server functions used in client code are side-effect free and do not rely on Node built-ins.
deprecated The 'transform' function is deprecated in favor of 'transformSync' for synchronous usage.
fix Replace transpiler.transform with transpiler.transformSync for synchronous use, or use async APIs.
gotcha TypeScript decorators may not be fully supported; ensure @isomor decorator is used correctly.
fix Enable Babel decorator plugin and set isomor-related options in babel config.
gotcha Source maps may be inaccurate if input code contains multiple imports from isomor server modules.
fix Use inline source maps or verify with tool-specific settings.
npm install isomor-transpiler
yarn add isomor-transpiler
pnpm add isomor-transpiler

Demonstrates how to use the transpiler to process a TypeScript file, transforming server imports into API calls. Requires Babel core.

import transpiler from 'isomor-transpiler';
import { transformSync } from '@babel/core';

const code = `
  import { getUsers } from '../server/user';
  // @isomor is added automatically by the transpiler
  export default function MyComponent() {
    getUsers().then(console.log);
  }
`;

const result = transpiler.transform(code, {
  filename: 'MyComponent.tsx',
  sourceMaps: true
});

console.log(result.code);