Quick and dirty project to test the claim default exports defeat tree-shaking. Indicates that no, default exports themselves don't defeat tree-shaking. (An anti-pattern using them would, but not defaults themselves.)
Note: I dislike default exports and strongly recommend not using them when you can avoid them (which is always, other than when interface with some libraries/packages that require them).
To replicate:
-
Grab these files into a local directory.
-
Do
npm i
-
Do
npm run build
-
Look at the generated JavaScript file in the
dist
directory. The textunused
doesn't appear, because the unused function was removed by tree-shaking.