Gathering detailed insights and metrics for babel-plugin-annotate-pure-calls
Gathering detailed insights and metrics for babel-plugin-annotate-pure-calls
Gathering detailed insights and metrics for babel-plugin-annotate-pure-calls
Gathering detailed insights and metrics for babel-plugin-annotate-pure-calls
This plugins helps with annotating top level functions calls with #__PURE__ comment.
npm install babel-plugin-annotate-pure-calls
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
93 Stars
47 Commits
7 Forks
2 Watching
1 Branches
1 Contributors
Updated on 30 Jun 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
7.1%
18,630
Compared to previous day
Last week
25.1%
203,093
Compared to previous week
Last month
97.9%
535,896
Compared to previous month
Last year
-6.6%
3,176,132
Compared to previous year
This plugins helps with automatic #__PURE__ annotation insertion. It add the comment to top level call expressions and new expressions in assignment contexts (those are considered by the plugin as side effect free). This helps UglifyJS to perform dead code elimination more efficiently and therefore reduces the bundle sizes for the consumers.
NOTE: It might break your code, so the caution is advised. Target audience for the plugin are libraries, which in vast major of use cases do not introduce side effects in top level calls. That doesn't mean that application bundles cannot benefit from the plugin.
1// pure call 2var inc = add(1) 3 4// clearly impure - no assignment context 5mutate({ prop: 'value' })
Top level call (in terms of this plugin) is one that gets executed during script initialization. So it is every call located at the root of a file, but also a call in an IIFE that gets executed at startup (including nested ones).
1var a = topLevelCall() 2 3b = function() { 4 noTopLevelCall() 5} 6 7topLevelIIFEs = (function() { 8 var c = (function() { 9 var d = (function() { 10 var e = topLevelCall() 11 })() 12 })() 13})()
1npm install --save-dev babel-plugin-annotate-pure-calls
.babelrc
(Recommended).babelrc
1{ 2 "plugins": ["annotate-pure-calls"] 3}
1babel --plugins annotate-pure-calls script.js
1require('babel-core').transform('var inc = add(1)', { 2 plugins: ['annotate-pure-calls'], 3})
The plugin works with babel@6, you might see unmet peer dependency warning though. If you want to get rid of it, please
install @babel/core@6.0.0-bridge.1
.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
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