Error checking package import bundle size for node packages with size-limit-preset-node-lib

Author: slavik-chapelskyiCreated Dec 13, 2022Updated Dec 13, 2022

I have tried to implement this tool in our monorepo containing only node specific packages or both browser/node compatible.

I'm facing issues using @size-limit/preset-small-lib preset of a node library, which is using node-fetch package. After running check the bundle was surprisingly small. After investigation I have figured out that whole node-fetch package was replace with some small esbuild global.fetch polyfill. That probably because it was build for web, not node platform. So I have switched preset to https://github.com/un-ts/size-limit/tree/main/packages/preset-node-lib and try to run bundle check with it. But it refuses to working with import option. I have also tried to change the CLI --save-bundler option to check the output without import option, but it had the same error, so its impossible to properly check the bundle size for node packages.

CleanShot 2022-12-13 at 18 16 01@2x CleanShot 2022-12-13 at 18 16 59@2x