-
-
Notifications
You must be signed in to change notification settings - Fork 948
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
Don't bundle the CJS build #471
Comments
that is, if I understand correctly, the cjs package and the entries about it in |
@codecalm no changes needed in the package.json for this one. The Short Answer: We should make the CJS build like the ESM build -- not bundled into one file. If you pull @mui/icons-material, you can get a demo of this. The Long Answer: Node has CJS as the default module format, but modern browsers all support ESM now. Using an import transform plugin like the one for Next.js / SWC with tabler icons is currently working with ESM, but not working with CJS. Both need to be supported these days because of the popularity of Next.js / server side rendering. The client side bundle it produces has no issues with ESM but the server side bundle does. I believe the future will be all about emitting .mjs files and setting up conditional imports in your package.json, but we arent there yet. I again used material-icons as a reference here to see if they checked off those boxes yet (which they haven't). |
yes pls 🙏 import IconBrandInstagram from '@tabler/icons-react/dist/esm/icons/IconBrandInstagram'; |
@codecalm this should be an easy fix by just not bundling the CSM build |
@anthonyalayo so what should be in |
@codecalm so that can stay the same, here's what I'm thinking:
Here's a blog that talks about this approach in detail with an example: |
@anthonyalayo any update on this? :) |
I am alone in the project, unfortunately I do not have time to do all the issues. If anyone has an idea and willingness to do PR, please feel free to contribute 🙂 |
Is there going to be any progress here or is this the end of the line for using tabler icons in nextjs13? |
I was looking into it today too, would something along these line solve this? (no breaking changes but see note below) note: I see on the config that es <-> esm are the same and this is being done so the generated file isn't overwritten. My solution does something along those lines too so it doesn't introduce breaking changes but eventually it would make sense to prefix the bundled/single files with |
Next js added automatic optimization to some icon libraries but, tabler isn't mentioned there |
Follow up to #359
Adding support for consistent webpack import transforms has been great for performance, thank you!
However with Next.js, server side builds are still built with CJS. The module system with Node is still in its infancy and hasn't yet been widely adopted.
Utilizing
modularizeImports
like so:Results in the following error:
This can be fixed by configuring
@tabler/icons-react
to be transpiled as well:But this is more of a workaround until the library is being emitted in a better format.
Can we update the CJS build to not be bundled?
@mui/icons-material
came to the same conclusion, and that's how their emitting their CJS builds.The text was updated successfully, but these errors were encountered: