react-cosmos / rfcs

Change requests for React Cosmos
MIT License
1 stars 2 forks source link

Unbundled development #18

Closed gunar closed 1 year ago

gunar commented 3 years ago

Hi,

Tools like snowpack and vite make for a much faster feedback loop as they don't bundle code while on development. I'd love if react-cosmos would be made compatible with these tools. Pardon me if this is possible already with some sort of specific configuration.

Thanks in advance.

PS: react-comsos is great, thank you for your work!

ovidiuch commented 3 years ago

Hi @gunar,

I'd love to see this happen. How willing are you to experiment with this? 😅

I don't think it's been done before, but it's definitely possible. There are Parcel and Browserify integrations on the Cosmos org, but unfortunately they're for an older version of Cosmos.

The current webpack entry point is a good starting point for discovering how to Cosmos parts come together. The React Native entry point is also interesting to check out to see the difference, and because it doesn't work with webpack. The Cosmos UI ("Playground") is webpack agnostic, and on the server side webpack is internally abstracted as a plugin.

I'm more than happy to offer answers, even jump into short calls if needed, for anyone willing to take on this challenge.

tsanyqudsi commented 3 years ago

I don't know if this came too late. But i've managed to make it work with vite ( kinda copy it from https://github.com/kazuma1989/react-cosmos-with-vite ) for the most part.

And putting aside that i have to run both vite and react-cosmos server at the same time. I don't see any disadvantage.

my suggestion is to split the builder into different package perhaps ? For example when you run react-cosmos, instead of just doing cosmos, you have to write cosmos --builder='vite' or cosmos --builder='webpack5'

This way, React Cosmos might be able to withstand any custom builder in the future.

ovidiuch commented 3 years ago

my suggestion is to split the builder into different package perhaps ? For example when you run react-cosmos, instead of just doing cosmos, you have to write cosmos --builder='vite' or cosmos --builder='webpack5'

Indeed this is the dream. Cosmos used to have a separate package for webpack initially, which was later merged with the core Cosmos package because everybody in the React community was using webpack back then and it simplified things. But the long term vision is what you're pointing out, to install separate Cosmos plugin packages for specific bundlers.

ovidiuch commented 1 year ago

Cosmos now has react-cosmos-plugin-vite plugin 😇.