Easily remove unused Moment.js locales with webpack
Installations
npm install moment-locales-webpack-plugin
Developer
iamakulov
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
NPM Version
Statistics
434 Stars
122 Commits
11 Forks
6 Watching
9 Branches
5 Contributors
Updated on 18 Sept 2024
Bundle Size
6.83 kB
Minified
2.73 kB
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
67,691,736
Last day
-18.3%
51,401
Compared to previous day
Last week
-12.9%
320,755
Compared to previous week
Last month
58.1%
1,652,833
Compared to previous month
Last year
1.5%
13,406,169
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
8
moment-locales-webpack-plugin
Easily remove unused Moment.js locales when building with webpack
Why
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
Install
1npm install --save-dev moment-locales-webpack-plugin
Usage
1// webpack.config.js 2const MomentLocalesPlugin = require('moment-locales-webpack-plugin'); 3 4module.exports = { 5 plugins: [ 6 // To strip all locales except “en” 7 new MomentLocalesPlugin(), 8 9 // Or: To strip all locales except “en”, “es-us” and “ru” 10 // (“en” is built into Moment and can’t be removed) 11 new MomentLocalesPlugin({ 12 localesToKeep: ['es-us', 'ru'], 13 }), 14 ], 15};
Plugin Options
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.
Related projects
moment-timezone-data-webpack-plugin
– a plugin optimizing the Moment Timezone library.
Contributing
See CONTRIBUTING.md for how to contribute.
License
MIT © Ivan Akulov
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
25 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
1.3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More