Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Add ReasonML plugin #588

Closed
arecvlohe opened this issue Jan 7, 2020 · 0 comments
Closed

Add ReasonML plugin #588

arecvlohe opened this issue Jan 7, 2020 · 0 comments

Comments

@arecvlohe
Copy link

Background

Per @Timer and my discussion on MoOx/phenomic#1286 I am starting to work on a next plugin for ReasonML that is built directly in to next itself. I am now here to discuss the implementation and whether I am on the right path.

Prior Art and Current Issues

There are a few examples already in the next.js examples folder that handle working with ReasonML/ReasonReact, however, there is an issue with them. They use the babel-plugin-bucklescript which is archived on GitHub and out of date. See: https://github.com/mike-engel/babel-plugin-bucklescript. I think for this plugin, and future iterations, it would need to be supported by the the bucklescript platform, i.e. bs-platform. Although I suppose I could fork that repo and update it. However, if I go the route of using bs-platform, this presents another issue: building it to be deployed on now. I have had issues in the past attempting to deploy a ReasonML app on the now platform that does not support the OCaml ecosystem. This would work fine for JAM stack apps, but people would have an issue if they were deploying a server rendered app where it needs to be built to an image and not simply spit out HTML files using next export.

Considerations

For the reasons listed above I think I need to take a different approach whether I work with bs-platform or fork babel-plugin-bucklescript.

Firstly, I will need to add files and pull in dependencies. So my thought process here was to follow the typescript plugin that is now built into next.js: https://github.com/zeit/next.js/blob/canary/packages/next/lib/verifyTypeScriptSetup.ts. This makes sense because I will need to install bs-platform, add a bs-config file, a bindings file, and whatever other files are needed to get it working.

Secondly, in order to get it to build on now, I think I will need to vendor bucklescript and place it into the node module already pre-packaged so that it doesn't need to be installed on the now server image. This is what is done in phenomic: https://github.com/phenomic/phenomic/blob/1a896add371a7903f9633457104f2caff78736c3/packages/bs-platform/package.json#L23. That is what is then installed: https://github.com/phenomic/phenomic/blob/76c8882c52606ab44e61c0502be915aa023634bc/packages/core/package.json#L32. Or something to this effect. Maybe I am misinterpreting what is happening here so I am happy to be corrected.

Next Steps

Anyhow, these are just a few of my ideas for creating a ReasonML/ReasonReact plugin directly into next.js. Let me know what you think and if I am on the correct path. Curious to hear anyone else's thoughts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants