PlasmoHQ / plasmo

🧩 The Browser Extension Framework
https://www.plasmo.com
MIT License
10.65k stars 370 forks source link

[RFC] Support ReScript #367

Open louisgv opened 1 year ago

louisgv commented 1 year ago

How do you envision this feature/change to look/work like?

User can create UI component using the .res file extension, which get compiled using https://rescript-lang.org/

What is the purpose of this change/feature? Why?

Follow up on #356 - Some folks love ReScript it seems

(OPTIONAL) Example implementations

No response

(OPTIONAL) Contact Details

No response

Verify canary release

Code of Conduct

pd4d10 commented 1 year ago

Thanks for the quick feedback!

Comment from https://github.com/PlasmoHQ/plasmo/pull/363#issuecomment-1367667135

@pd4d10 For rescript - you can create a rescript parcel transformer, that incorporates the .res file extension. We can incorporate it in our config and that will allow you to use the .res extension for rescript with zero external bundlings needed.

AFAIK, ReScript's build system may be a little different from common JS transformers like Babel. Instead of compiling files one by one, it seems treat all files (from its perspective, also modules) as a whole.

So I'm not sure if the "rescript parcel transformer" way would work

louisgv commented 1 year ago

Thanks for the quick feedback!

Comment from #363 (comment) @pd4d10 For rescript - you can create a rescript parcel transformer, that incorporates the .res file extension. We can incorporate it in our config and that will allow you to use the .res extension for rescript with zero external bundlings needed.

AFAIK, ReScript's build system may be a little different from common JS transformers like Babel. Instead of compiling files one by one, it seems treat all files (from its perspective, also modules) as a whole.

So I'm not sure if the "rescript parcel transformer" way would work

A parcel transformer basically takes a file and resolve any reference within it and turn them into an usable bundle (js/css)

Basically, a .res file can be transformed by rescript into .js, and any source referenced inside that rescript file can either be handled by the rescript transformer (to replace url reference), OR be handled by the rescript build system itself (basically you just add rescript into this transformer and it can do whatever it need to do).

The transformation step is handled by Rescript itself, and I imagine it can be configured to align with parcel or just do everything on its own.