Code Monkey home page Code Monkey logo

action's Introduction







Calculate the size of your npm package distribution

⚑️ Try it in your npm package

$ npx pkg-size

Features

  • πŸ” Size analysis Quickly determine the total size of what you're publishing to npm!
  • πŸ”₯ Same behavior as npm pack/publish Collects publish files as specified in your package.json!
  • πŸ™Œ Gzip & Brotli See how your files compress in addition to normal size!
  • πŸ€– Node.js API Integrate size checks to your CI via Node.js API

Support this project by ⭐️ starring and sharing it. Follow me to see what other cool projects I'm working on! ❀️

πŸ™‹β€β™‚οΈ Why?

To quickly determine the uncompressed size, gzip size, and brotli size of your package before publishing it to npm.

πŸš€ Install

npm i pkg-size

🚦 Quick Usage

Get the package size by package path

pkg-size ./package/path

Skip brotli size calculation

pkg-size --sizes=size,gzip

Order files by name

pkg-size --sort-by=name

Use IEC units (insted of metric) for size

pkg-size --unit=iec

βš™οΈ CLI Options

-S, --sizes

Comma separated list of sizes to show (size, gzip, brotli) (default: size,gzip,brotli)

-s, --sort-by

Sort list by (name, size, gzip, brotli) (default: brotli)

-u, --unit

Display units (metric, iec, metric_octet, iec_octet) (default: metric)

-i, --ignore-files

Glob to ignores files from list. Total size will still include them.

--json

JSON output

-h, --help

Display this message

-v, --version

Display version number

πŸ‘·β€β™‚οΈ Node.js API

const pkgSize = require('pkg-size');

// Get the package size of the current working directory
const sizeData = await pkgSize();

// ... Or get the package size of a specific package path
const sizeData = await pkgSize('/path/to/package');

Interface

type FileEntry = {
    path: string;
    size: number;
    sizeGzip: number;
    sizeBrotli: number;
};

type PkgSizeData = {
    pkgPath: string;
    tarballSize: number;
    files: FileEntry[];
};

function pkgSize(pkgPath?: string): Promise<PkgSizeData>;

πŸ‘¨β€πŸ‘©β€πŸ‘¦ Related

A GitHub Action to automate package size regression reports on your pull requestsβ€”great for size-conscious development.

action's People

Contributors

avegancafe avatar privatenumber 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

Watchers

 avatar  avatar  avatar

action's Issues

bug: empty file interpreted as deleted

Bug description

When a file is emptied, the size report interprets it as a deleted file

Reproduction steps

Environment

  • pkg-size-action version:
  • Operating System:
  • Node version:

Warning about set-output deprecated

Bug description

I receive the following warning for this action

The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

From the blog:

Action authors who are using the toolkit should update the @actions/core package to v1.10.0 or greater to get the updated saveState and setOutput functions.

Environment

  • pkg-size-action version: latest
  • Operating System: not relevant
  • Node version: not relevant

Action Needs Permissions to Comment

Bug description

Using the recommended yml from the README.md:

name: Package Size Report

on:
  pull_request:
    branches: [ master, develop ] # β¬… Add other branches you want size checks on

jobs:
  pkg-size-report:
    name: Package Size Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14' # β¬… Specify a version of Node.js to build your app

      - name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

results in the following error when the action is triggered:
Screenshot 2024-03-14 at 10 03 19β€―AM

Solution: add the following to your recommended yml

permissions:
  pull-requests: write

Reproduction steps

See above

Environment

  • pkg-size-action version: v1.1.1
  • Operating System: Local: MacOS 14.2.1, ubuntu-latest on the action itself
  • Node version: 20

feat: check registry connection

Is your feature request related to a problem? Please describe.

Currently, if the registry isn't accessible (eg. proprietary registry behind VPN), the action hangs with no logs.

Describe the solution you'd like

Check if the registry is connectable and log error if not.

Describe alternatives you've considered

Additional context

Feature Request: Print output of the build command

Howdy πŸ‘‹ Firstly, thanks for this amazing action.

I wanted to post a feature request. It would be nice to be able to pass silent: false to the exec options here:

await exec(buildCommand, { cwd }).catch((error) => {

To be able to see the full output of the buildCommand that could help with debugging or prove informative in other ways.

I already changed it in my fork, and it's working pretty nicely. Let me know what you think πŸ™
If you accept contributions, I can shoot you a quick PR for this.

Include package path as option

Is your feature request related to a problem? Please describe.

In monorepo scenario, It would be great if there is package path option so the action will not run against the whole packages

Describe the solution you'd like

name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          path: path/to/package

Describe alternatives you've considered

Additional context

feat: create groups (eg. only CSS)

Is your feature request related to a problem? Please describe.

Ability to create groups with filters

Describe the solution you'd like

Probably a glob filter for each group

Describe alternatives you've considered

Additional context

bug: pnpm to detect which version to use

Bug description

Running pnpm i --frozen-lock with the latest pnpm can fail if the lock was made by a different version (eg. pnpm 6 with pnpm 5 lock).

Should read pnpm version from yaml file instead.

Reproduction steps

Environment

  • pkg-size-action version:
  • Operating System:
  • Node version:

feat: option to report on build time

Is your feature request related to a problem? Please describe.

Build time is an important aspect of a build, and this action can access that data but is not available.

Describe the solution you'd like

An option to enable reporting on build time as well

Describe alternatives you've considered

Additional context

feat: monorepo support

Is your feature request related to a problem? Please describe.

Support for monorepos.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

feat: add ability to specify triggering files

Is your feature request related to a problem? Please describe.

This is a super useful package. In my specific use-case I'm working in a pretty large monolith where there are a significant number of people that only work in ruby, so a significant portion of the PRs opened in the repo don't change any js.

Describe the solution you'd like

It would be cool if we could specify a list of files that would cause this action to only execute and comment and such if those specified files were changed.

Describe alternatives you've considered

Not sure if there is an alternative besides ignoring the comment a majority of the time. It is pretty slow though currently since there's no caching, so might also end up being added noise for a significant percentage of PRs.

feat: report undefined `files` array

Is your feature request related to a problem? Please describe.

When adding this action to a non-library repo, often times the BASE and HEAD branches have different files to package. The initial repo will usually fail because the base branch includes all files which is too excessive for pkg-size to handle.

Describe the solution you'd like

  • Warning on undefined files array (or when HEAD has one defined and BASE doesn't)
  • Warning when detected files count exceeds 50 or 1mb

Describe alternatives you've considered

Additional context

feat: add raw values via title attribute

Is your feature request related to a problem? Please describe.

I see the percentage differences, but I'm also interested in the raw difference values

Describe the solution you'd like

Add the raw byte difference as a title attribute on the percentage change

Describe alternatives you've considered

Additional context

bug: error in the `Comment on PR` phase

Bug description

I'm getting this error in this github action:

Error: Resource not accessible by integration
  Warning: HttpError: Resource not accessible by integration
      at /home/runner/work/_actions/pkg-size/action/v1/dist/index.js:2990:27
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at async to (/home/runner/work/_actions/pkg-size/action/v1/dist/index.js:4591:9)
      at async /home/runner/work/_actions/pkg-size/action/v1/dist/index.js:7912:9

Reproduction steps

The github action log is here:
https://github.com/ant-design/ant-design-mobile/runs/4029511668?check_suite_focus=true

And the related workflow config is here:
https://github.com/ant-design/ant-design-mobile/blob/master/.github/workflows/bundle-size.yml

Environment

  • pkg-size-action version: v1
  • Operating System: ubuntu-18.04
  • Node version: 14

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.