You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After implementing some new APIs that weren't used in any place (except for unit tests of those) in #883, expected that bundle size of production apps wouldn't change. Because those APIs weren't used. So they'd be tree-shaken... right? Well turns out they aren't:
So first thought it would have to do with the recent re-organization of files and directories and the index.ts files around exporting module's features. See #862.
Found this evanw/esbuild#1420 But doesn't seem to be the issue as we don't use export * as x. Also tried reverting that change back and the issue still appears again.
However, if we export something like const FOO = 'foo'. It doesn't appear in the production build if unused.
Tried then exporting partially until seeing which is the part that can't get tree shaken. Used the v18 app as reference. Exporting the helpers withNameAttribute, withContentAttribute ... but not using them just adds 4 bytes to the bundle* I was expecting 0, but definitely 4 is something acceptable and probably related to bundler internals.
After checking, seems it's due to var added. Not sure why. Bundler mysteries. Maybe var can't declare at once more than x things at once? Given the output is var x=[...],y=[...],... Anywaysssss
What if the new InjectionToken is the issue? Tried exporting const FOO = new InjectionToken('foo'). It gets in the production bundle despite unused! Why? Probably because new X may come with side effects so it's not 100% to tree shake it.
Tried then removing usages of _HEAD_ELEMENT_UPSERT_OR_REMOVE (standard & json ld modules) from the example app. Built again and... yup, the token and it's factory are still in the production bundle. How can then an injection token be defined in a manner that if it's unused doesn't end up in the production bundle?
The text was updated successfully, but these errors were encountered:
After implementing some new APIs that weren't used in any place (except for unit tests of those) in #883, expected that bundle size of production apps wouldn't change. Because those APIs weren't used. So they'd be tree-shaken... right? Well turns out they aren't:
(Not only v18, but also rest of versions)
So first thought it would have to do with the recent re-organization of files and directories and the
index.ts
files around exporting module's features. See #862.Found this evanw/esbuild#1420 But doesn't seem to be the issue as we don't use
export * as x
. Also tried reverting that change back and the issue still appears again.However, if we export something like
const FOO = 'foo'
. It doesn't appear in the production build if unused.Tried then exporting partially until seeing which is the part that can't get tree shaken. Used the v18 app as reference. Exporting the helpers
withNameAttribute
,withContentAttribute
... but not using them just adds 4 bytes to the bundle* I was expecting 0, but definitely 4 is something acceptable and probably related to bundler internals.What if the
new InjectionToken
is the issue? Tried exportingconst FOO = new InjectionToken('foo')
. It gets in the production bundle despite unused! Why? Probably becausenew X
may come with side effects so it's not 100% to tree shake it.Tried then removing usages of
_HEAD_ELEMENT_UPSERT_OR_REMOVE
(standard & json ld modules) from the example app. Built again and... yup, the token and it's factory are still in the production bundle. How can then an injection token be defined in a manner that if it's unused doesn't end up in the production bundle?The text was updated successfully, but these errors were encountered: