size-limit
size-limit copied to clipboard
Recommended way to limit total size of an ESM library
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?
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.
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?
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?
Could you explain how code coverage is related?
Oops. Wrong link.
Here is right one https://github.com/ai/size-limit/issues/261