Emacs port of the VS Code plugin (WIP)
PRE-ALPHA
Minor mode for displaying JavaScript module sizes inline.
This is an Emacs port of the Import Cost plugin for Visual Studio Code.
emacs >=24.4
node >=8.0.0
First clone this project:
$ git clone git@github.com:madeleinedaly/import-cost.git
Then add something like this to your Emacs config:
(add-to-list 'load-path "path/to/import-cost.el")
(require 'import-cost)
;; you can access config options once the package has loaded:
(with-eval-after-load 'import-cost
(setq import-cost-bundle-size-decoration 'gzipped))
You can enable import-cost-mode
for the current buffer interactively with M-x import-cost-mode
.
Or hook into your preferred JavaScript modes:
(add-hook 'js2-mode-hook #'import-cost-mode)
(add-hook 'rjsx-mode-hook #'import-cost-mode)
The following variables are customizable (see M-x customize-group import-cost
):
import-cost-small-package-size
: numberUpper size limit, in KB, that will count a package as a small package.
50
import-cost-medium-package-size
: numberUpper size limit, in KB, that will count a package as a medium package. Any package size above this limit will be considered large.
100
import-cost-small-package-color
: color | faceDecoration color for small packages.
"#7cc36e"
import-cost-medium-package-color
: color | faceDecoration color for medium packages.
"#7cc36e"
import-cost-large-package-color
: color | faceDecoration color for large packages.
"#d44e40"
import-cost-typescript-extensions
: list (regexp)File extensions to be parsed by the TypeScript parser.
'("\\.tsx?$")
import-cost-javascript-extensions
: list (regexp)File extensions to be parsed by the JavaScript parser.
'("\\.jsx?$")
import-cost-bundle-size-decoration
: symbolWhich bundle size to display.
Default: 'both
Possible values:
'both
'minified
'gzipped
import-cost-cache-filename
: stringThe name of the file in which import size decoration data gets persisted across sessions.
"import-cost.cache"
import-cost-cache-filepath
: stringThe path to the file where import size decoration data gets persisted across sessions.
user-emacs-directory
import-cost-lighter
: stringLighter used in the mode-line while import-cost-mode
is active.
" ₵"
MIT