Code Monkey home page Code Monkey logo

Comments (11)

ai avatar ai commented on July 24, 2024 1

There is two way to do it:

  1. Run Size Limit on your dist/ dir with compiled JS files. It is recommended way.
  2. Use custom webpack config. Not recommended because result could be a little different from real npm package.

from size-limit.

ai avatar ai commented on July 24, 2024 1

Yeap. For app you should add files to path manually depends on your needs 👍😊

from size-limit.

thasmo avatar thasmo commented on July 24, 2024

@ai, thanks for the quick response. Does that mean size-limit simply sums up all files' sizes and displays the total size?

from size-limit.

ai avatar ai commented on July 24, 2024

Nope. Size Limit emulates “simple user”. It creates empty and simple webpack project in the memory, install your library and calculates project size difference.

Because it emulates simple user, it doesn't have TS support. Since your library users will not add special TS loaders for your library.

from size-limit.

thasmo avatar thasmo commented on July 24, 2024

But for Run Size Limit on your dist/ dir with compiled JS files. It is recommended way. it would just sum up all files' sizes, I guess?

from size-limit.

ai avatar ai commented on July 24, 2024

Nope. It will load dist/index.js in that empty project in the memory.

from size-limit.

ai avatar ai commented on July 24, 2024

Sum all files is not the best way to control size. In my experience the most popular problems with the size happen because of dependencies and webpack's polyfills for Node modules (like when you are using process).

This is why we always try to calculate real cost of your library.

(If you really need just files sum you can do it by webpack: false, path: "dist/*", but I don't recommend it)

from size-limit.

thasmo avatar thasmo commented on July 24, 2024

I'm not sure I understand this. In my final dist directory I have these files:

  • main.js
  • main.js.gz
  • main.js.br
  • vendor.js
  • vendor.js.gz
  • vendor.js.br
  • main.css
  • main.css.gz
  • main.css.br
  • chunks/0.js
  • chunks/0.js.gz
  • chunks/0.js.br
  • icons/{multiple}.png
  • sprites/{multiple}.svg
  • sprites/{multiple}.svg.gz
  • sprites/{multiple}.svg.br
  • fonts/{multiple}.woff
  • fonts/{multiple}.woff2

How do I have to configure size-limit to have it analyze the size correctly?
I'm working on an application, not a library. Does that even work then?

from size-limit.

ai avatar ai commented on July 24, 2024

If you are using Size Limit for app, you should have config like:

  webpack: false,
  path: "dist/main.js"
  limit: "100 KB"

from size-limit.

thasmo avatar thasmo commented on July 24, 2024

@ai, thanks for the answer. Running size-limit prints this:

Package size: 5.11 KB
With all dependencies, minified and gzipped

This seems to be the gzipped file-size of main.js itself.
That probably means it does not include vendor.js and any other assets.

So, I guess, to get the desired size, I will have to configure path to include all files.

from size-limit.

thasmo avatar thasmo commented on July 24, 2024

Thanks for the help!

from size-limit.

Related Issues (20)

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.