ai / size-limit

Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
MIT License
6.54k stars 1.82k forks source link

plugins are `import`ed with `require.resolve` which will resolve `commonjs` entry for dual package #344

Closed JounQin closed 11 months ago

JounQin commented 11 months ago

https://github.com/ai/size-limit/blob/f2493379fefc00559af2a8c54fc52cedbbc9b0bd/packages/size-limit/load-plugins.js#L30-L34

This is unexpected for third-party plugins.

JounQin commented 11 months ago

Workaround: I publish ESM-only plugin now.

ai commented 11 months ago

Yes, I think let’s move to ESM as a requirement for Size Limit plugin.

It doesn’t look too complicated since we have only a few third-party plugins.

JounQin commented 11 months ago

ESM is not required even when we use import() directly, the current issue is we're preferring commonjs over ESM incorrectly for dual package.

ai commented 11 months ago

The fix was released in 10.0.3.