Unimod is a versatile tool designed to automate the conversion between CommonJS (CJS), ES Modules (ESM), and TypeScript (TS). It supports all possible combinations of these formats and includes additional functionalities such as logging, backups, dependency type installations, and automatic interface creation for classes.
- Module Conversion: Convert between CJS, ESM, and TS effortlessly.
- Syntax Transformations: Automatically handle syntax changes during conversion.
- Type Conversions: Convert JavaScript to TypeScript with type annotations.
- File Renaming: Rename files appropriately based on the target module system.
- Automated Backups: Create backups of original files before modification.
- Logging: Enable detailed logging of the conversion process.
- Dependency Type Installation: Automatically locate
package.json
and install types for all dependencies when converting to TypeScript. - Interface Creation: Generate interfaces for classes when converting to TypeScript.
You can run Unimod using one of the following methods:
npm run dev
npm run start
For Windows users, an executable file is available in the releases section. Download the .exe
file and run it directly.
If the executable does not work for you, or if you wish to compile Unimod for another platform, follow the instructions below:
Visit the Bun Bundler Executables Documentation for detailed steps on compiling the tool for your desired environment.
When you run Unimod, it will prompt you with a series of questions to guide the conversion process:
- Target Files Location
Are target files in this directory? (Y/n)
- If
No
, it will ask:Please provide the directory path:
- Select Files to Convert:
Which files do you want to convert?
◯ JS
◯ MJS
◯ TS
- TypeScript Specific Prompt (Only if TS is selected):
Do you want me to automatically install types for your project (from package.json)? (y/N)
- Choose Transformation Format:
Which format do you want to transform to? (Use arrow keys)
JS
MJS
TS
- Backup Option:
Do you want to create backups for each modified file? (y/N)
- Enable Logging:
Do you want to enable logging? (Y/n)
- Simple CJS to TS transformation
-
✅ Current Features:
- Conversion between CJS, ESM, and TS
- Syntax and type transformations
- File renaming
- Automated backups and logging
-
🚧 Upcoming Features:
- Feature to automatically create interfaces for classes when converted to TS
- Feature to add automatic typing for the whole project when converted to TS
- Publish as an NPM package
- Suggest changes to file/class/function/var... naming conventions based on the selected option
- Feature to automatically add public / private modifiers to class properties / methods based on their name.
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
Contributing guidelines