π§Ή Convert TypeScript to a cleaner JavaScript project δΈζζζ‘£
- π Vue-First: Priority support for Vue project conversion
- π Extensible: Plugin system for supporting various file types
- β‘ Lightning Fast: Utilizes ts.transpileModule for rapid transpilation
- π₯οΈ User-Friendly CLI: Quick conversion with a single command
- 𧩠Seamless Integration: Import as an npm package for easy project integration
- π οΈ Customizable: Fine-tune the conversion process with flexible options
- π Progress Tracking: Real-time feedback on conversion status
- π― Selective Conversion: Ignore specific patterns during copy and conversion
- π¦ Dependency Management: Option to remove specified dependencies
- π Import Optimization: Capability to replace internal imports
npm install cleants
# or
yarn add cleants
# or
pnpm add cleants
npx cleants
import { Cleants } from 'cleants'
const cleaner = new Cleants(inputDir, outputDir, options)
await cleaner.run()
You can add a
cleants.config.js
file in the command execution directory to specify more configurations
module.exports = {
inputDir: 'D:\\Projects\\demo',
outputDir: 'C:\\Users\\viarotel\\Downloads',
compilerOptions: {},
ignoredCopyPatterns: [
'.git',
'dist',
/\.d\.ts$/,
file => file.includes('node_modules'),
file => file.endsWith('.log')
],
ignoredConversionPatterns: [
'vendor',
/\.min\.js$/,
file => file.includes('legacy')
],
getOutputDir: inputDir => `${path.basename(inputDir)}.cleants`,
removeDependencies: ['typescript', 'vue-tsc', '@types/node'],
replaceInternalImports: true,
plugins: []
}
The main class used to convert a TypeScript project into a cleaner JavaScript project.
constructor(inputDir: string, outputDir: string, options?: CleantsOptions)
inputDir: string
- The input directory pathoutputDir: string
- The output directory pathoptions?: CleantsOptions
- Optional configuration options
Progress callback function.
Default: undefined
TypeScript compiler options.
Default: {}
Patterns to ignore during the copy phase. Default:
[
'.git',
'dist',
/\.d\.ts$/,
file => file.includes('node_modules'),
file => file.endsWith('.log')
]
Patterns to ignore during the conversion phase. Default:
[
'vendor',
/\.min\.js$/,
file => file.includes('legacy')
]
Function to get the output directory.
Default: inputDir => `${path.basename(inputDir)}.cleants`
Dependencies to remove.
Default: ['typescript', 'vue-tsc', '@types/node']
Whether to replace internal imports.
Default: true
List of plugins to use.
Default: [basePlugin, vuePlugin]
actualOutputDir
is set topath.join(outputDir, options.getOutputDir(inputDir))
- If no
options.plugins
are provided, the default is[basePlugin, vuePlugin]
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
If you find this project helpful for your work or study, please consider starring the project or buying me a cup of coffee through the links below:
Thanks for all their contributions!
typescript
javascript
converter
vue
cli
This project is licensed under the MIT License.