Static scope analysis and transpilation of ES6 block-scoped const and let variables to ES3 var.
defs.js is a static scope analyzer and transpiler that converts ES6 block-scoped `const` and `let` declarations into ES3-compatible `var` statements. It enables developers to use modern JavaScript block scoping in browser environments before native support was widespread, while also serving as a scope analysis tool for linting.
JavaScript developers working on browser-based projects that need to use ES6 block scoping features in environments without native support, such as older browsers, and those who require static analysis for variable scoping and linting.
Developers choose defs.js for its accurate and minimally intrusive transpilation of ES6 block scope semantics to ES3, focusing on correctness and compatibility, and its additional utility as a static scope analyzer for detecting errors like duplicated definitions or unknown references.
Static scope analysis and transpilation of ES6 block scoped const and let variables to ES3 vars
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Transforms ES6 const and let to ES3 var with semantic accuracy, as shown in examples where inner variables are renamed (e.g., y to y$0) to avoid scope conflicts.
Serves as a linter to detect scoping errors like duplicated definitions or unknown references, configurable via defs-config.json with options like disallowDuplicated.
Supports environment definitions (e.g., node, browser) and global variable settings borrowed from jshint, allowing customization for different project setups.
Can be used as a Node.js library to process code strings or ASTs, enabling integration into custom build tools and scripts, as documented in the README.
The README explicitly states defs.js is 'done' and recommends migrating to TypeScript's tsc, indicating no future updates, bug fixes, or support.
Only handles const and let declarations, lacking support for other ES6+ features like arrow functions or modules, making it insufficient for modern JavaScript development.
Requires manual setup of a defs-config.json file for environments and rules, which can be tedious and error-prone compared to zero-config tools like Babel.