size-limit icon indicating copy to clipboard operation
size-limit copied to clipboard

Recommended way to limit total size of an ESM library

Open silvenon opened this issue 3 years ago • 4 comments

Hello! In my library I have a root ESM index file exporting everything, so I would like to use that to limit the total size of my library. Simply specifying the file with path doesn't appear to be enough, as the size ends up being zero or next to zero, so is there a way to import all exports somehow, for example import: "*"? What is generally the recommended way to limit total size in an ESM library?

silvenon avatar Oct 26 '21 22:10 silvenon

One easy workaround I can think of is to create a measurer.js file:

import * as everything from './lib'

export { everything }

then in .size-limit.js:

{
  name: 'Total',
  path: `${__dirname}/measurer.js`,
  import: '{ everything }',
}

but I'm wondering if there's a more straightforward way.

silvenon avatar Oct 26 '21 23:10 silvenon

We had some discussion here https://github.com/ai/size-limit/issues/263

I small PR with extra syntax for import is needed indid. Do you want to help?

ai avatar Oct 27 '21 04:10 ai

We had some discussion here #263

Could you explain how code coverage is related?

I small PR with extra syntax for import is needed indid. Do you want to help?

I do! What syntax do you want? I instinctively went for * when I was trying it out, so that might be good, do you have another idea?

silvenon avatar Oct 27 '21 08:10 silvenon

Could you explain how code coverage is related?

Oops. Wrong link.

Here is right one https://github.com/ai/size-limit/issues/261

ai avatar Oct 27 '21 08:10 ai