Gathering detailed insights and metrics for @zibuthe7j11/alias-rem-consequuntur
Gathering detailed insights and metrics for @zibuthe7j11/alias-rem-consequuntur
Gathering detailed insights and metrics for @zibuthe7j11/alias-rem-consequuntur
Gathering detailed insights and metrics for @zibuthe7j11/alias-rem-consequuntur
npm install @zibuthe7j11/alias-rem-consequuntur
Typescript
Module System
Node Version
NPM Version
68
Supply Chain
99.2
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
241
Last Day
9
Last Week
77
Last Month
111
Last Year
185
MIT License
9 Commits
1 Branches
Updated on Apr 27, 2024
Latest Version
1.0.0
Package Id
@zibuthe7j11/alias-rem-consequuntur@1.0.0
Unpacked Size
12.66 kB
Size
5.46 kB
File Count
10
NPM Version
10.5.0
Node Version
20.12.2
Published on
Apr 26, 2024
Cumulative downloads
Total Downloads
Last Day
-18.2%
9
Compared to previous day
Last Week
220.8%
77
Compared to previous week
Last Month
2,120%
111
Compared to previous month
Last Year
230.4%
185
Compared to previous year
Marks all side-effects in module initialization that will interfere with tree-shaking
This plugin is intended as a means for library developers to identify patterns that will interfere with the tree-shaking algorithm of their module bundler (i.e. rollup or webpack).
JavaScript:
1myGlobal = 17; 2const x = { [globalFunction()]: "myString" }; 3 4export default 42;
Rollup output:
1myGlobal = 17; 2const x = { [globalFunction()]: "myString" }; 3 4var index = 42; 5 6export default index;
ESLint output:
1:1 error Cannot determine side-effects of assignment to global variable
2:13 error Cannot determine side-effects of calling global function
This plugin is most useful when you integrate ESLint with your editor.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install @zibuthe7j11/alias-rem-consequuntur
:
$ npm install @zibuthe7j11/alias-rem-consequuntur --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install @zibuthe7j11/alias-rem-consequuntur
globally.
Add tree-shaking
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
1{ 2 "plugins": ["tree-shaking"] 3}
Then add the rule no-side-effects-in-initialization
to the rules section:
1{ 2 "rules": { 3 "tree-shaking/no-side-effects-in-initialization": 2 4 } 5}
To prevent false positives, configure like this:
1{ 2 "rules": { 3 "tree-shaking/no-side-effects-in-initialization": [ 4 2, 5 { 6 "noSideEffectsWhenCalled": [ 7 { "function": "Object.freeze" }, 8 { 9 "module": "react", 10 "functions": ["createContext", "createRef"] 11 }, 12 { 13 "module": "zod", 14 "functions": ["array", "string", "nativeEnum", "number", "object", "optional"] 15 }, 16 { 17 "module": "my/local/module", 18 "functions": ["foo", "bar", "baz"] 19 } 20 ] 21 } 22 ] 23 } 24}
ESLint only ever analyzes one file at a time and by default, this plugin assumes that all imported functions have side-effects. If this is not the case, this plugin supports magic comments you can add before identifiers in imports and exports to specify that you assume an import or export to be a pure function. Examples:
By default, imported functions are assumed to have side-effects:
JavaScript:
1import { x } from "./some-file"; 2x();
ESLint output:
1:9 error Cannot determine side-effects of calling imported function
You can mark a side-effect free import with a magic comment:
JavaScript:
1import { /* tree-shaking no-side-effects-when-called */ x } from "./some-file"; 2x();
No ESLint errors
By default, exported functions are not checked for side-effects:
JavaScript:
1export const x = globalFunction;
No ESLint errors
You can check exports for side-effects with a magic comment:
JavaScript:
1export const /* tree-shaking no-side-effects-when-called */ x = globalFunction;
ESLint output:
1:65 error Cannot determine side-effects of calling global function
This plugin is in development. If you want to contribute, please read CONTRIBUTING.md.
This plugin implements a side-effect detection algorithm similar to what rollup uses to determine if code can be removed safely. However, there is no one-to-one correspondence. If you find that you have code that
please--if no-one else has done so yet--check the guidelines and file an issue!
No vulnerabilities found.
No security vulnerabilities found.