This plugins helps with annotating top level functions calls with #__PURE__ comment.
Installations
npm install babel-plugin-annotate-pure-calls
Releases
Unable to fetch releases
Developer
Andarist
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
10.5.0
NPM Version
6.1.0
Statistics
93 Stars
47 Commits
7 Forks
2 Watching
1 Branches
1 Contributors
Updated on 30 Jun 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
14,470,560
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
babel-plugin-annotate-pure-calls
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.
Pure calls
1// pure call 2var inc = add(1) 3 4// clearly impure - no assignment context 5mutate({ prop: 'value' })
Top level calls
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})()
Installation
1npm install --save-dev babel-plugin-annotate-pure-calls
Usage
Via .babelrc
(Recommended)
.babelrc
1{ 2 "plugins": ["annotate-pure-calls"] 3}
Via CLI
1babel --plugins annotate-pure-calls script.js
Via Node API
1require('babel-core').transform('var inc = add(1)', { 2 plugins: ['annotate-pure-calls'], 3})
Usage with babel@6
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
.
Similar projects
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
- 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 7 are checked with a SAST tool
Score
2.6
/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