-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add simple vite plugin #73
base: master
Are you sure you want to change the base?
Conversation
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. Comparing it with Vite and TypeScript:
I update the |
@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:
|
* @returns Vite plugin | ||
*/ | ||
function rescript() { | ||
let rescriptProcressRef = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let rescriptProcressRef = null; | |
let rescriptProcessRef = null; |
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.
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. |
@cknitt I found other vite-plugin-rescript https://github.com/jihchi/vite-plugin-rescript, it can add simply and like vite can load .ts file, this plugin can load .res files, rather than res.mjs as before
|
@illusory0x0 Thanks! I will test that one. |
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.