Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@drewigg/agadoo
Advanced tools
Ag-a-doo-doo-doo, push pineapple, shake the tree
Tells you whether the JavaScript library you're building is tree-shakeable.
Tell you why tree-shaking fails, if it does. Maybe in a future version.
With the advent of JavaScript modules (import
and export
), it's possible to build libraries that are tree-shakeable. This means that a user of your library can import just the bits they need, without burdening their users with all the code you're not using.
For example, the eases-jsnext library contains a grab-bag of Robert Penner's easing equations, presented as a JavaScript module. I can use it like this in my code...
import * as eases from 'eases-jsnext';
for (let t = 0; t <= 1; t += 0.05) {
const eased = eases.cubicInOut(t)
const str = repeat('*', eased * 20);
console.log(str);
}
function repeat(str, num) {
let result = '';
num = Math.round(num);
while (num--) result += str;
return result;
}
...and all the easing functions that I haven't used will get removed during bundling, if I'm using a modern bundler such as Rollup, webpack or Parcel. Here's what that bundle would look like with Rollup:
'use strict';
function cubicInOut(t) {
return t < 0.5
? 4.0 * t * t * t
: 0.5 * Math.pow(2.0 * t - 2.0, 3.0) + 1.0
}
for (let t = 0; t <= 1; t += 0.05) {
const eased = cubicInOut(t);
const str = repeat('*', eased * 20);
console.log(str);
}
function repeat(str, num) {
let result = '';
num = Math.round(num);
while (num--) result += str;
return result;
}
...and here's the result of running it:
*
*
**
***
*****
*******
**********
*************
***************
*****************
******************
*******************
*******************
********************
********************
********************
But I digress. The point is that this works because eases-jsnext is a tree-shakeable library.
Inside your project folder, run Agadoo like so:
npx agadoo
You can install it as a development dependency and run it each time you npm publish
— if tree-shaking fails, publishing will be aborted:
npm install -D agadoo
// package.json
{
"scripts": {
"prepublishOnly": "agadoo"
}
}
You can specify the module if necessary:
agadoo dist/my-library.js
Firstly, make sure you're exposing a JavaScript module using the "module" field of your package.json (aka pkg.module).
If tree-shaking still fails, it's because Rollup thinks that there are side-effects somewhere in your code. Follow these guidelines:
LIL.
FAQs
Check whether a package is tree-shakeable
The npm package @drewigg/agadoo receives a total of 2 weekly downloads. As such, @drewigg/agadoo popularity was classified as not popular.
We found that @drewigg/agadoo 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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.