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

babel-plugin-formatjs

Package Overview
Dependencies
Maintainers
0
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-formatjs

Extracts string messages for translation from modules that use formatjs.

  • 10.5.24
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
178K
decreased by-8.9%
Maintainers
0
Weekly downloads
 
Created

What is babel-plugin-formatjs?

babel-plugin-formatjs is a Babel plugin that transforms message descriptors for the FormatJS library, which is used for internationalization (i18n) in JavaScript applications. It helps in extracting, compiling, and optimizing messages for different locales.

What are babel-plugin-formatjs's main functionalities?

Message Extraction

This feature allows you to extract message descriptors from your code. The extracted messages can then be used to generate translation files for different locales.

/* Babel configuration file (babel.config.js) */
module.exports = {
  plugins: [
    [
      'babel-plugin-formatjs',
      {
        idInterpolationPattern: '[sha512:contenthash:base64:6]',
        extractFromFormatMessageCall: true,
        ast: true
      }
    ]
  ]
};

Message Compilation

This feature allows you to compile message descriptors into a format that can be used at runtime. This is useful for optimizing the performance of your application by pre-compiling messages.

/* Example of compiling messages */
import { compile } from 'babel-plugin-formatjs';

const messages = {
  'greeting': 'Hello, {name}!'
};

const compiledMessages = compile(messages);
console.log(compiledMessages);

Optimizing Messages

This feature allows you to optimize message descriptors for better performance. This can include removing unnecessary whitespace, minifying the messages, and other optimizations.

/* Example of optimizing messages */
import { optimize } from 'babel-plugin-formatjs';

const messages = {
  'greeting': 'Hello, {name}!'
};

const optimizedMessages = optimize(messages);
console.log(optimizedMessages);

Other packages similar to babel-plugin-formatjs

Keywords

FAQs

Package last updated on 04 Nov 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