-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to ignore lazy loaded code #76
Comments
Hi. I think Size Limit supports it out of box. Show your Size Limit version and be config. |
It's the size-limit version 0.21.0 (newest) my code: function crossBrowserFetch(url: string, init?: RequestInit): Promise<Response> {
if (typeof fetch === 'undefined') {
// Lazy load ponyfill if necessary
return import(/* webpackChunkName: "lazy-fetch-ponyfill" */ 'fetch-ponyfill' as any).then(
(fetchPonyfill) => fetchPonyfill.default().fetch(url, init) as Response
);
}
return fetch(url, init);
} Default configurationWith the default configuration it does not exclude lazy loaded scripts
Result:
Explicitly ignoredIf I ignore the package explicitly it seems to work.
Result
|
Hm. Can you show your webpack config? |
I don't have any webpack config. The code after transpiling which is is given to size-limit is the following:
|
Is it a JS library (so you will deliver it to users by npm) or an application? |
A library just image it would only be this code: index.js
|
Can you debug here https://github.com/ai/size-limit/blob/master/index.js#L155 What will be in |
It looks like everything is correct. The result of compiling the file above is:
So the main code is the webpack load code from here: |
I need a list of |
|
My confusion was because of the large size but it is the webpack code which is added to the code. |
Seems like Do you have a project to repeat the error. I afraid that webpack just do not move polyfill to that file. |
Sure - but I guess your tool is delivering the "correct" result unfortunately it counts also the size of the webpack dynamic module loader. I attached a demo project: size-limit-demo.zip You will see that the
Especially for such a small library (4 lines of code) that's a quite huge number |
Yeap, it is by design. Your user may not have dynamic
Yeap, Size Limit was specially designed to detect this case. Here is another example when Size Limit helped to decrease library real cost by one LOC theKashey/react-focus-lock#48 Here is what I suggest or your case:
|
It would be interesting to know the initial load size as well.
Would it be possible to skip the file sizes of dynamic imports (e.g. skip
demoLibrary
inonClick=async() => await import('demoLibrary').doSth
)?The text was updated successfully, but these errors were encountered: