Code Monkey home page Code Monkey logo

export-size's Introduction

export-size

Analysis bundle cost for each export of an ESM package

Install

npx export-size [package-name]

Usage

Calculate local package

npx export-size .

Calculate npm package

npx export-size @vueuse/core

More options

npx export-size --help

Example output

@vueuse/core v4.0.0-beta.20
sha 8ef798bf7d22f9cca7681c3bb717af59e6b1685d

┌───────────────────────────┬──────────┐
│ export                    │ min+gzip │
│                           │          │
│ useWebWorkerFn            │   1.1 KB │
│ useTransition             │   1007 B │
│ useParallax               │    987 B │
│ asyncComputed             │    924 B │
│ useShare                  │    817 B │
│ useIdle                   │    651 B │
│ useSessionStorage         │    604 B │
│ useLocalStorage           │    600 B │
│ useStoragePlain           │    597 B │
│ useStorage                │    586 B │
│ useDeviceMotion           │    559 B │
│ useMouseInElement         │    542 B │
│ useElementVisibility      │    503 B │
│ useDevicePixelRatio       │    489 B │
│ onStartTyping             │    471 B │
│ useEventSource            │    471 B │
│ useOnline                 │    467 B │
│ useNetwork                │    455 B │
│ useRefHistory             │    451 B │
│ useGeolocation            │    408 B │
│ useBrowserLocation        │    405 B │
│ useMouse                  │    403 B │
│ useBattery                │    395 B │
│ useAsyncState             │    367 B │
│ usePermission             │    365 B │
│ useWindowSize             │    347 B │
│ useWindowScroll           │    344 B │
│ useClipboard              │    337 B │
│ usePreferredColorScheme   │    333 B │
│ useWebSocket              │    329 B │
│ useDeviceOrientation      │    324 B │
│ useThrottle               │    318 B │
│ usePageLeave              │    300 B │
│ useDocumentVisibility     │    291 B │
│ usePreferredDark          │    285 B │
│ useCssVar                 │    284 B │
│ usePreferredLanguages     │    282 B │
│ useTimeoutFn              │    282 B │
│ useWebWorker              │    277 B │
│ useDeviceLight            │    273 B │
│ useInterval               │    273 B │
│ useDebounce               │    262 B │
│ useThrottleFn             │    258 B │
│ useMediaQuery             │    247 B │
│ useRaf                    │    244 B │
│ useTitle                  │    243 B │
│ useIntersectionObserver   │    239 B │
│ useTimeout                │    227 B │
│ useRafFn                  │    224 B │
│ useEventListener          │    222 B │
│ useNow                    │    207 B │
│ useDebounceFn             │    204 B │
│ useFullscreen             │    201 B │
│ useIntervalFn             │    199 B │
│ createGlobalState         │    197 B │
│ useResizeObserver         │    195 B │
│ useMutationObserver       │    190 B │
│ useCounter                │    183 B │
│ explicitComputed          │    146 B │
│ isWindow                  │    144 B │
│ tryOnMounted              │    143 B │
│ assert                    │    137 B │
│ isObject                  │    122 B │
│ DEVICE_PIXEL_RATIO_SCALES │    109 B │
│ tryOnUnmounted            │    107 B │
│ clamp                     │     98 B │
│ isBoolean                 │     92 B │
│ isNumber                  │     91 B │
│ isString                  │     91 B │
│ timestamp                 │     87 B │
│ isFunction                │     86 B │
│ isDef                     │     84 B │
│ isClient                  │     83 B │
│ now                       │     79 B │
│ noop                      │     65 B │
└───────────────────────────┴──────────┘

TODO

  • Support JSON output
  • Support custom output path

Sponsors

This project is part of my Sponsor Program

License

MIT

export-size's People

Contributors

antfu avatar hyrious avatar sibbng avatar sxzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

export-size's Issues

`yargs.scriptName is not a function`

Describe the bug

This is the first time I'm trying it locally and it's not working at all. I tried:

  • bunx export-size mlly
  • npx export-size mlly
  • npm install -g export-size; export-size mlly

Reproduction

export-size mlly

System Info

System:
    OS: macOS 13.6
    CPU: (16) x64 Intel(R) Core(TM) i9
    Memory: 56.81 MB / 16.00 GB
    Shell: 3.6.1 - /usr/local/bin/fish
  Binaries:
    Node: 18.17.0 - /usr/local/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 9.6.7 - /usr/local/bin/npm
  Browsers:
    Chrome: 117.0.5938.132

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Online version? Like bundlephobia.com

Clear and concise description of the problem

When exploring packages on the web, it's nice to be able to find this information without context switching or to share the results with others. For example I added several links to such services in https://npmhub.org and I regularly link to bundlephobia from my own packages’ readme.

Suggested solution

I think this is a good extension of bundlephobia, what do you think about either adding it to bundlephobia or creating a standalone website for it?

Alternative

No response

Additional context

No response

Validations

Error when using this with React

Describe the bug

When bundler is rollup, there is some error when trying to execute export packages

I think this issue might be fixed if @rollup/plugin-commonjs is used


npx export-size . --bundler "rollup"
████████████████████████████████████████ 0/0 Error: 'jsx' is not exported by node_modules/react/jsx-runtime.js, imported by dist/coms
    at error (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:198:30)
    at Module.error (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:12543:16)
    at Module.traceVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:12902:29)
    at ModuleScope.findVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:11554:39)
    at FunctionScope.findVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:6486:38)
    at ChildScope.findVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:6486:38)
    at Identifier.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:7553:40)
    at CallExpression.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:5383:23)
    at CallExpression.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:9049:15)
    at ReturnStatement.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:5383:23) {
  code: 'MISSING_EXPORT',
  url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module',
  id: '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Alert/index.js',
  pos: 9,
  loc: {
    column: 9,
    file: '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Alert/index.js',
    line: 1
  },
  frame: "1: import { jsx } from 'react/jsx-runtime';\n" +
    '            ^\n' +
    "2: import { Alert } from 'antd';",
  watchFiles: [
    'export-size-virtual',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Heyo.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Hello/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/World/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Counter/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/CurrentUserBio/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/CashAppsQueryClient/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/pages/Payments/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/utils/fetcher.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/utils/query-client.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Alert/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/node_modules/react/jsx-runtime.js'
  ]

Reproduction

https://github.com/ma101an/cashapps

System Info

System:
    OS: macOS 12.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 36.62 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/Library/Caches/fnm_multishells/73842_1659985333292/bin/node
    Yarn: 1.22.15 - ~/Library/Caches/fnm_multishells/73842_1659985333292/bin/yarn
    npm: 8.12.1 - ~/Library/Caches/fnm_multishells/73842_1659985333292/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 103.1.41.100
    Firefox Developer Edition: 104.0
    Safari: 15.6

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.