BS in-source files supports #30
Description
Hey guys,
I've started getting to know reason and reason-react in the last days, so I'm still totally new to the syntax/language and the complementary tooling such as bucklescript.
I do have a side project that I'm working on from time to time which is basically a simple CRA application. So I decided to start putting some reason flavour in it and as far as I could understand it it should be easy to migrate little pieces to reason incrementally.
Long story short:
- I've replaced
react-scripts
withreason-scripts
- I've migrated
index.js
toindex.re
- I've activated the new
in-source
builds in conjunction with.bs.js
suffix (as recommended from the docs) - ...and I bumped into some small issues 🙃
One thing, being that there was a bug in bs-loader
that would ignore the suffix
. I've opened a PR for that rrdelaney/bs-loader#40
However, reason-scripts
still uses version 1.8.0
of bs-loader
and it should be upgraded to version 2
. Not a huge deal, as this issue can be worked around using a resolutions
field with yarn
.
Still, I think reason-scripts
should support this new options out of the box.
Here comes the additional missing feature: if I activate the in-source
option, I'll end up having the compiled file .bs.js
next to the source file
Foo.bs.js
Foo.re
However, the eslint rule used by webpack should exclude those auto generated files ending with .bs.js
. Using a .eslintignore
won't help because it's disabled on purpose on the rule.
A naive "fix" would be something like this:
- test: /\.(js|jsx|mjs)$/,
+ test: function testForJsFilesExcludingBsFiles(fileName) {
+ if (fileName.endsWith('.bs.js')) return false;
+ return /\.(js|jsx|mjs)$/.test(fileName);
+ },
So far those have been the "issues" that I have encountered while getting started with reason.
It would be nice to have them addressed, I'm not sure if there are other things that need to be improved though. But in general, having a good reason/bs support out of the box would be very nice.
Thanks a lot! 🙏
PS: I wanted to open an issue first to discuss those things, I'm also happy to provide a PR if you guys want to 😉