Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metro-minify-terser

Package Overview
Dependencies
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-minify-terser

🚇 Minifier for Metro based on Terser.

  • 0.81.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
decreased by-12.1%
Maintainers
2
Weekly downloads
 
Created

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

Package last updated on 14 Oct 2024

Did you know?

Socket

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc