Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
moment-locales-webpack-plugin
Advanced tools
The moment-locales-webpack-plugin is a Webpack plugin designed to optimize the Moment.js library by removing unused locales. This helps reduce the bundle size of your application, making it more efficient.
Remove Unused Locales
This feature allows you to remove all unused locales from Moment.js, reducing the bundle size significantly.
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
module.exports = {
plugins: [
new MomentLocalesPlugin()
]
};
Keep Specific Locales
This feature allows you to specify which locales you want to keep in your bundle. In this example, only 'es-us' and 'ru' locales are kept.
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
module.exports = {
plugins: [
new MomentLocalesPlugin({
localesToKeep: ['es-us', 'ru']
})
]
};
The babel-plugin-lodash is a Babel plugin that cherry-picks Lodash modules to reduce bundle size. While it is not specifically for Moment.js, it serves a similar purpose of optimizing library imports to reduce bundle size.
Easily remove unused Moment.js locales when building with webpack
75% (160 minified KBs)¹ of Moment.js’ size are files used for localization. They are always included when you build your app with webpack.
You don’t need most of these files if your app is only available in a few languages. Use this plugin to strip these KBs and optimize the app!
¹ – tested with Moment.js 2.18.1
npm install --save-dev moment-locales-webpack-plugin
// webpack.config.js
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
module.exports = {
plugins: [
// To strip all locales except “en”
new MomentLocalesPlugin(),
// Or: To strip all locales except “en”, “es-us” and “ru”
// (“en” is built into Moment and can’t be removed)
new MomentLocalesPlugin({
localesToKeep: ['es-us', 'ru'],
}),
],
};
localesToKeep: String[]
An array of locales to keep bundled (other locales would be removed).
Locale names follow Moment.js behavior – if a specific locale name (e.g. ru-ru
) is absent, but a more generic locale (ru
) is available, the generic one will be kept bundled.
ignoreInvalidLocales: Boolean
A flag to ignore invalid or unsupported locales in the localesToKeep
array.
Be careful! A typo in the localesToKeep
array with this flag enabled will silently exclude the desired locale from your bundle.
moment-timezone-data-webpack-plugin
– a plugin optimizing the Moment Timezone library.See CONTRIBUTING.md for how to contribute.
MIT © Ivan Akulov
FAQs
Strip unused locales from Moment.js
The npm package moment-locales-webpack-plugin receives a total of 201,223 weekly downloads. As such, moment-locales-webpack-plugin popularity was classified as popular.
We found that moment-locales-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.