Socket
Socket
Sign inDemoInstall

metro-minify-terser

Package Overview
Dependencies
12
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    metro-minify-terser

๐Ÿš‡ Minifier for Metro based on Terser.


Version published
Weekly downloads
1.7M
increased by0.76%
Maintainers
2
Install size
4.00 MB
Created
Weekly downloads
ย 

Package description

What is metro-minify-terser?

The metro-minify-terser package is a minifier for JavaScript and TypeScript code. It is based on the Terser minification library and is used within the Metro bundler, which is commonly used with React Native applications. The package provides code minification which helps in reducing the size of the codebase, leading to faster load times and better performance in production environments.

What are metro-minify-terser's main functionalities?

Code Minification

This feature allows you to minify JavaScript or TypeScript code, which includes mangling variable names, removing comments, and other optimizations to reduce the size of the code.

const metroMinifyTerser = require('metro-minify-terser');

async function minifyCode(code) {
  const result = await metroMinifyTerser.minify(code, {
    mangle: true, // Change variable names to shorter ones
    keep_classnames: false, // Do not keep class names
    keep_fnames: false, // Do not keep function names
    output: {
      ascii_only: true, // Encode non-ASCII characters as \uXXXX
      comments: false, // Remove comments
      semicolons: true, // Use semicolons to separate statements
    },
  });
  return result.code;
}

// Example usage
const originalCode = 'function add(a, b) { return a + b; }';
minifyCode(originalCode).then(minifiedCode => {
  console.log(minifiedCode);
});

Other packages similar to metro-minify-terser

FAQs

Last updated on 28 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc