Constructuring
raw JSON → 0.0.3 verified Fri May 01 auth: no javascript abandoned
Constructuring is an ES6-to-ES3 transpiler specifically for the destructuring feature. It transforms JavaScript code using ES6 destructuring (arrays and objects) into ES3-compatible code that runs in older browsers. Current version 0.0.3, with no recent updates indicating it is no longer maintained. It operates on source strings or esprima ASTs, making it suitable for integration into build pipelines that already use esprima and escodegen. Compared to broader transpilers like Babel, Constructuring focuses only on destructuring, which may be useful for targeted transformations but lacks active development and broader language feature support.
Common errors
error TypeError: transformSource is not a function ↓
cause Incorrect import: using default import instead of named import in CommonJS.
fix
Use const { transformSource } = require('constructuring');
error SyntaxError: Unexpected token = ↓
cause Source code contains ES6 syntax beyond destructuring (e.g., arrow functions) which constructuring cannot handle.
fix
First transpile with a broader tool like Babel, or ensure input only uses destructuring.
error Module not found: Can't resolve 'constructuring' ↓
cause Package is not installed or name is misspelled.
fix
Run npm install constructuring --save or check spelling: 'constructuring' (note: not 'constructuring').
error Error: Cannot find module 'esprima' ↓
cause When using AST mode, esprima and escodegen must be installed separately.
fix
npm install esprima escodegen
Warnings
deprecated Package is abandoned; last version 0.0.3 released years ago. No support for modern JavaScript or ES6 beyond destructuring. ↓
fix Use a modern transpiler like Babel or SWC for full ES6+ support.
gotcha Package is CommonJS-only; will not work with ESM imports without a bundler or wrapper. ↓
fix Use require() or wrap in a bundler that supports CJS.
gotcha Transform functions mutate the AST if provided; ensure you have a copy if needed. ↓
fix Clone the AST before passing if you need the original for other purposes.
breaking No official TypeScript definitions; any type safety must be manually added. ↓
fix Create your own .d.ts or use @ts-ignore.
deprecated No security patches or updates; known vulnerabilities in dependencies (esprima, escodegen) may be present. ↓
fix Do not use in production; fork and update dependencies if necessary.
Install
npm install constructuring yarn add constructuring pnpm add constructuring Imports
- transformSource wrong
import { transformSource } from 'constructuring';correctconst { transformSource } = require('constructuring'); - transform wrong
const transform = require('constructuring').transform;correctconst { transform } = require('constructuring'); - default wrong
import constructuring from 'constructuring';correctconst constructuring = require('constructuring');
Quickstart
const { transformSource } = require('constructuring');
const fs = require('fs');
const source = fs.readFileSync('module.js', 'utf8');
const result = transformSource(source);
console.log(result);
// Also AST-based:
const esprima = require('esprima');
const escodegen = require('escodegen');
const ast = esprima.parse(source);
const { transform } = require('constructuring');
transform(ast);
console.log(escodegen.generate(ast));