jsdc

raw JSON →
0.6.13 verified Fri May 01 auth: no javascript maintenance

jsdc is a JavaScript transpiler that converts ES6/ES2015 code to ES5 for backward compatibility. Current stable version is 0.6.13, last released in 2017. It focuses on safe transformations preserving line numbers for debugging, supports CommonJS/AMD/CMD, and includes features like let/const, arrow functions, classes, generators, destructuring, template literals, and modules. Unlike Babel or Traceur, jsdc is lightweight, has no runtime dependencies, and aims for simplicity. The project appears to be in maintenance mode with no recent updates.

error Cannot find module 'homunculus'
cause jsdc depends on the `homunculus` parser, which may not be installed automatically in all environments.
fix
Run npm install homunculus alongside jsdc to install the dependency.
error TypeError: Jsdc is not a constructor
cause Using `require('jsdc')` returns an object with a default export, not the constructor directly.
fix
Use const Jsdc = require('jsdc').default or switch to ES6 import syntax.
error Error: Cannot find module 'jsdc'
cause jsdc is not installed or is not in the project's node_modules.
fix
Run npm install jsdc --save-dev to install it as a dev dependency.
error ReferenceError: regeneratorRuntime is not defined
cause jsdc transpiles generators to regenerator runtime, which must be included separately.
fix
Add import 'regenerator-runtime/runtime' before using any generator code.
error Unexpected token '=>' (or similar ES6 syntax)
cause jsdc is not being called on the code; the code is running directly in an environment that doesn't support ES6.
fix
Ensure jsdc.parse() is executed before running the code in an ES5-only environment.
gotcha jsdc does NOT provide polyfills for ES6 built-ins like Set, Map, or Promise. You must include your own polyfill library (e.g., es6-shim) if your code depends on them.
fix Add a polyfill such as `import 'es6-shim'` before using Set/Map/Promise.
gotcha The `runtime(flag)` method modifies Node.js's require mechanism globally, which can cause unexpected behavior in larger projects or when combined with other transpilers.
fix Avoid using runtime in production; instead, transpile files ahead of time.
deprecated This package is no longer actively maintained. The last release was in 2017. For new projects, consider using Babel or SWC.
fix Migrate to Babel: `npm install @babel/core @babel/preset-env`
gotcha jsdc uses `Object.defineProperty` for some transformations, which may not be fully supported in older JavaScript engines (IE < 9).
fix Ensure your target environment supports Object.defineProperty or use a polyfill.
npm install jsdc
yarn add jsdc
pnpm add jsdc

Shows basic usage: transpile ES6 code (arrow function, template literal) to ES5 using jsdc.

import Jsdc from 'jsdc';

const es6Code = `
const greet = (name) => {
  console.log(`Hello, ${name}!`);
};
`;

const es5Code = Jsdc.parse(es6Code);
console.log(es5Code);
// Output: var greet = function(name) {
//   console.log('Hello, ' + name + '!');
// };