npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cleants

v0.0.3

Published

🧹 Convert TypeScript to a cleaner JavaScript project

Downloads

95

Readme

Cleants

npm version npm downloads

🧹 Convert TypeScript to a cleaner JavaScript project 中文文档

Features

  • 🖖 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

Install

npm install cleants
# or
yarn add cleants
# or
pnpm add cleants

Usage

CLI Usage

npx cleants

Programmatic Usage

import { Cleants } from 'cleants'

const cleaner = new Cleants(inputDir, outputDir, options)
await cleaner.run()

External profile

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: []
}

API

Cleants

The main class used to convert a TypeScript project into a cleaner JavaScript project.

Constructor

constructor(inputDir: string, outputDir: string, options?: CleantsOptions)

Parameters
  • inputDir: string - The input directory path
  • outputDir: string - The output directory path
  • options?: CleantsOptions - Optional configuration options

CleantsOptions

progressCallback?: Function

Progress callback function. Default: undefined

compilerOptions?: Object

TypeScript compiler options. Default: {}

ignoredCopyPatterns?: Array<string | RegExp | Function>

Patterns to ignore during the copy phase. Default:

[
  '.git',
  'dist',
  /\.d\.ts$/,
  file => file.includes('node_modules'),
  file => file.endsWith('.log')
]
ignoredConversionPatterns?: Array<string | RegExp | Function>

Patterns to ignore during the conversion phase. Default:

[
  'vendor',
  /\.min\.js$/,
  file => file.includes('legacy')
]
getOutputDir?: Function

Function to get the output directory. Default: inputDir => `${path.basename(inputDir)}.cleants`

removeDependencies?: Array<string>

Dependencies to remove. Default: ['typescript', 'vue-tsc', '@types/node']

replaceInternalImports?: boolean

Whether to replace internal imports. Default: true

plugins?: Array<Plugin>

List of plugins to use. Default: [basePlugin, vuePlugin]

Notice

  • actualOutputDir is set to path.join(outputDir, options.getOutputDir(inputDir))
  • If no options.plugins are provided, the default is [basePlugin, vuePlugin]

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

Support

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:

Contributors

Thanks for all their contributions!

📚 Keywords

typescript javascript converter vue cli

License

This project is licensed under the MIT License.