Closed jacobp100 closed 3 years ago
You can see my project over on https://github.com/jacobp100/technicalc-core/tree/esm - make sure you're in the esm branch
Edit: I just got Jest to use es modules directly - which means I can fully remove babel from my project. It's still experimental in Jest, but it's so much faster.
Edit 2: I went with type: module
in my package.json
, and used the .js
extension for my js files, and .mjs
for ReScript's - it made my gitignore much easier
all the bs-platform now have a .mjs extension.
only Es6 has .mjs, the commonjs still has .js extension.
https://github.com/jacobp100/technicalc-core/tree/esm this link seems to be broken. I am a bit confused by your following comment, do you have it work for your examples including react-native?
@bobzhang Sorry - I merged it into master. It's now https://github.com/jacobp100/technicalc-core/
I bundle it and copy the bundles over to my react-native project - since I have very specific bundling requirements
Just to be clear, I fixed all my issues with config changes. I now run using ES modules in node natively, and no Babel
resolved in 9.0.1
Thank you for filing! Check list:
In ReScript 9 using ES6, all the
bs-platform
now have a.mjs
extension. This does mean you can run your files in node without transforming. However, doesn't work out the box for Jest and React Native (although it is possible to configure them to work). There's a little more information over on this thread.This might be more of an issue with the tools though.
Also, as an experiment, I wanted to get my whole project to run in node natively. The only the file extension that would work and was supported in ReScript was
.mjs
. However, I have some of my own JS files where I need to do interop. To have these work in node too, I'd have to give them the.mjs
filename too.This has made my
.gitignore
pretty complicated. In one submodule, I've resorted to.mjs
being ignored with_*.mjs
being not ignored. In another, I've hardcoded it to certain directories. Having a.bs.mjs
(or maybe.res.js
) would really help out here.There might be two separate issues, or they might end up being solved same thing.