Open nojaf opened 3 months ago
There is a bit of a trade-off between keeping a template as simple and transparent as possible and making it easy to get started. I am concerned that your plugin will break in subtle ways with vite or its react plugin as was sometimes the case already. Does fast refresh work?
All works as before. It is a slight trade-off in terms of transparency. However, I wouldn't underestimate how many devs are used to running the single command to get going.
Comparing it with Vite and TypeScript:
bun create vite
✔ Project name: … some-ts-project
✔ Select a framework: › React
✔ Select a variant: › TypeScript
Scaffolding project in /home/nojaf/projects/some-ts-project...
Done. Now run:
cd some-ts-project
bun install
bun run dev
I update the tsx
file and expect to see my browser reflect the change.
Which is what happens as well with this plugin.
I am still indifferent, what do you think @cknitt or @zth?
@nojaf Sorry for the late feedback, somehow missed this before.
It certainly makes for a nicer experience, especially for someone new to ReScript.
Two concerns:
- How dependent is this solution on the Vite version? E.g., does it still work with Vite 6? Do you think we should update the template to Vite 6 already?
This is unaffected in by the Vite 6 major, their plugin model is pretty stable. This will continue to keep on working. I have upgraded some of my projects to Vite 6, we should do it, this release was more significant for frameworks rather than end users.
- Colors in the ReScript output are lost, this is a bit of a downside.
Hmm, yes, I'm not sure if that can easily be resolved.
Regarding colors, I just tried this and it works:
const env = { ...process.env, FORCE_COLOR: "1", NINJA_ANSI_FORCED: "1" };
if (command === "build") {
logger.info(execSync("rescript", { env }).toString().trim());
} else {
rescriptProcressRef = spawn("rescript", ["-w"], { env });
logger.info(`Spawned rescript -w`);
But there is another remaining problem here: In the build/execSync case, if there is a compilation error, the output from the rescript process is not logged.
I'd propose to streamline the experience by running a single command to start the Vite dev server. I've added a simple plugin that will start the ReScript process as part of the vite pipeline.
Just type
npm run dev
(the default vite experience) and start hacking.(I've also updated the npm packages)
@fhammerschmidt let me know what you think.