-
Notifications
You must be signed in to change notification settings - Fork 455
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 extra variants for suffixes in bsconfig.json #5631
Add extra variants for suffixes in bsconfig.json #5631
Conversation
That's a lot of extensions. Are they all really strictly needed to solve the issue discussed in the forum? |
There is a problem when you have both a.res and a.res.js, the require will pick the former which isn't what you want |
No. Only But, we are moving out from the
I see no problem with specifying a full path. Like |
We could discourage usage of “old” Bsb_exception.errorf ~loc
"expect .js|.mjs|.cjs or .res.js|.res.mjs|.res.cjs here" But all the users of |
Is there a reason we're extending the existing string enum? Can't we make it a freeform string field where the only constraint is that it starts with a |
Like Well, it can be Wdyt? |
I have no real opinion for user input validation here beyond what's absolutely necessary but I don't see the need for anything beyond
Except for the slash there, that's a valid filename. So I don't know why we'd have to be smarter than operating systems and tools like those provided by GNU.
This misses a whole host of unicode characters that someone may want to use as file extension for a reason we can't fathom yet (similarly to how we previously didn't think of wanting From an actual possible threat perspective (and why I don't think input validation buys us much):
If we're worried about someone adding something malicious here and We could even drop the "must start with |
Another thought but maybe out of scope for this PR and to be done in a follow-up: It may be interesting to allow specifying extensions for different sources and allow sources to have glob expressions. Two example use cases:
That flexibility would also once and for all end any "I need some code to have a specific extension to interop with this new framework" issues. |
Let's only add '.bs.mjs' if that already solves your problem |
If one imports After all, in the ESM land, the extension is mandatory by design:
|
I just migrated a project to .mjs and now feel the need for a .bs.mjs or .res.mjs, too. 🙂
That would also solve the immediate problem for me. But I agree with @Kingdutch and @nkrkv that:
But as there are divergent opinions on this, maybe it would be best to move ahead with just .bs.mjs (and maybe .bs.cjs?) now in order to get this included in release 10.1 and then continue the discussion for bigger changes in 11.0? |
- `.bs.mjs`, `.bs.cjs` to fill the gap between `.bs.js` and `.mjs` - `.res.js`, `.res.mjs`, `.res.cjs` to assist BS → ReScript rebranding
7625235
to
0f3890d
Compare
Makes sense. I’ve updated the PR to remove |
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.
This looks good to me. Just a tiny comment on order.
That looks good. Would you also update the CHANGELOG. |
Sure. Should it be under |
Good question. |
Would definitely like to have this in 10.1! 🙂 @nkrkv Once this is merged to master, would you do a PR to cherry-pick to the |
In fact 10.1 and master changelogs have diverged a bit so no matter what, a bit of cleanup is required. |
Thanks. I'll merge then do the clean up and cherry picking. |
.bs.mjs
,.bs.cjs
to fill the gap between.bs.js
and.mjs
.res.js
,.res.mjs
,.res.cjs
to assist BS → ReScript rebranding