theKashey / react-imported-component

✂️📦Bundler-independent solution for SSR-friendly code-splitting
MIT License
662 stars 39 forks source link

Vite Support #227

Open BennyAlex opened 1 year ago

BennyAlex commented 1 year ago

@theKashey Hello,

I want to know how to use this libary with vite? (Without SSR)

Since there is no babel I cant use the babel plugin, so is this libary not working with vite? (And therefore not bundler independent?)

Thanks, have a good day.

theKashey commented 1 year ago

😃 yeah, independent from a bundler, but not from babel 🤷‍♂️

In any case - babel is not required for anything NOT involving SSR, and you've said you don't have it. The responsibility of babel is to "inline" filenames and might name webpack chunks via magic comments to communicate what was done during SSR and shall be redone on the client. One can easily replicate the same via rollup plugin (especially if rollup plugin can just call a babel one)

So, let me be honest, I never tried imported with Vite. Is it working? Is it not?

BennyAlex commented 1 year ago

I can try it. Is there any config need than or do I just install the package and use the imports?

theKashey commented 1 year ago

Just using should be fine. Marks are important only for hydration phase, later they are used only as fallback - https://github.com/theKashey/react-imported-component/blob/master/src/loadable/loadable.ts#L43

PawanKolhe commented 4 months ago

Hey @theKashey. We are using react-imported-component in our app (with Vite bundler) without SSR (clIent side SPA only). Do I need to worry about the warning about no mark found in the browser console?

Screenshot 2024-05-10 at 8 05 16 AM

theKashey commented 4 months ago

Without SSR marks are not important and I might need to provide a way to suppress this error after hydration as it only creates noise

PawanKolhe commented 4 months ago

@theKashey Right. The warnings are creating a lot of noise in the console. A way to suppress them would be very helpful.