What tool did they use: Browserify, Webpack, Gulp, Rollup, Babel, Parcel, ESBuild, etc.
And this looks like the PR for the icons update: https://github.com/Linen-dev/linen.dev/pull/1001
Unfortunately, the current state of ESM in Node is such a mess that you can't assume most packages are tree-shakeable. There is package.json metadata to do that.
It's more likely to be a "simple" bug (with far reaching consequences) in react-icons' package.json and/or build process.
Taking a quick glance at https://github.com/react-icons/react-icons/blob/master/packa...
Yeah, it's using the old non-standardized "module" field as opposed to the modern and mostly standard (now at least) "exports" field [1] or "type" field.
"exports" would be a quick fix of the existing package.json file with no other changes to the build process, but given this is a UI package intended primarily for browser usage I'm having a hard time understanding why it bothers to include CommonJS at all and isn't just `"type": "module"` and remove CommonJS from the build entirely.
That probably points to why this hasn't been done yet: it gets into a bikeshed argument and a lot of potential discussion on big changes to a presumably "not broke" build system.
[1] https://nodejs.org/api/packages.html#packages_exports
(ETA: Existing Issue on this subject in that repo: https://github.com/react-icons/react-icons/issues/717)
The bus gets fixed eventually. This doesn't (unless somebody fixes it).
https://webpack.js.org/guides/tree-shaking/#mark-the-file-as...
All popular bundlers (webpack, rollup, esbuild) respect that field.
The intro community discussion page at https://www.linen.dev/s/linen does need to load 20+ javascript files for some reason to show the latest messages.
Whereas messages still show up even if javascript is entirely blocked, just starting from the beginning in 10/2022 (?).
So I'm not quite sure if it's as optimized as it can be.
They provide a full framework but you can also download SVGs.
ex, an s3 only Java sdk:
https://stackoverflow.com/questions/35591248/aws-sdk-for-s3-...
You need to have two calls at least, generate a signed URL and then actually uploading it. How many lines on the client would you guess that requires? My guess is less than 30, and you cover 100% of your use case without putting in any 3rd party code what so ever. Sounds like a solid win with few drawbacks.
Is there an easier way to verify this than, say, observing the final bundle size and looking inside the JS bundle? I'm not a frontend developer so this is outside my usual area of knowledge.
[source-map-explorer]: https://github.com/danvk/source-map-explorer
[Lighthouse Treemap]: https://umaar.com/dev-tips/270-devtools-lighthouse-treemap/
I notice that if I lower the bar and allow half baked hackish solutions to slip in, beyond some point, upkeep consumes infinite time. There seems no way back from that besides starting from scratch.
There is no good reason for front end things to break. I can only think of document.writeln() but who in his right mind...
Any possibility of you sharing your "codemod script" so others can potentially implement it too? :)
Always fascinated when I hear that JS term for what's essentially dead code elimination.
Tree shaking only looks at the imports and removes code that isn't imported from the bundle. If code is imported but not executed, then tree shaking won't remove this code, even though it is dead code.
Using a different term is reasonable to avoid confusion, in this case.
For one particular microsoft product, this is brought to attention by documentation: https://learn.microsoft.com/en-us/power-apps/developer/compo...
> We found that react-icons had an issue that lead to everything being imported. This meant that we were including every single react-icon in our package whether we need it or not.
Kudos to the Linen team for proactively finding this - I have a feeling tons of projects blindly trust that tree-shaking their dependencies will "just work" even though for many libraries it won't!
> We also noticed that we were only using AWS client for s3 upload on the client side and it was taking up significantly more bundle size we need so we replaced the entire client side package with a 2 api calls to the AWS api.
For such a minimal use case, this feels like a logical choice even if it's slightly more work to implement.
> We ended up moving the code highlight code to a backend api that would cache the results.
Love seeing websites make smart choices about which work to handle in the server versus the client.