I am trying to run simple test case in TypeScript project but I am getting
> mocha
/myApp/node_modules/react-native-testing-library/src/index.js:2
import render from './render';
^^^^^^
SyntaxError: Unexpected token import
This means that you guys are publishing the project code in ES6 even though node_modules should be released as ES5.
Could you compile the library code to ES5 and republish that :)
You should ask Babel-jest to transpile this library instead
I am using mocha. I think the library code should be available as possible like other libraries are doing. If you really really really want to have library code in ES6 then there should be some steps on the README on how to run it. But that doesn't make any sense since that would require different guides to all different tests runners
We mainly target React Native, where projects are released as source. Before you feed this lib to your TS compiler, you'll need to run it through Babel with metro-react-native-babel-preset.
I think we could compile it to ES5 though, I'm happy to review and accept the PR with that change :)
Why would you make accessability of this library harder than it should be? I think it could be made widely accessible, and no need for unneccessary steps. Making it work right out of the box would help the library spread.
Feel free to fix it, this is an open source project and I didn't say no to this kind of improvement 馃槂.
@thymikee Okay do you have something in mind that you would use to compile this to ES5?
Yup, I'd go with @babel/preset-env with a target of Node 8 (that's the minimum required by React Native right now).
Or actually we could just go with metro-react-native-babel-preset, already available in dev deps. I think that will be simpler to set up
So should the compilation be in release-it? Looks like you guys are using that but I don't have experience with it
Don't worry about release-it. There should just be a git-ignored (but not npm-ignored) build folder with compiled sources, that would get created/updated on pre-release npm hook.
@thymikee I made a PR based on your tips, can you check it out?
Just published @1.4.1-es5.0 with compiled sources. Let me know if it works for you, both TS and Flow users
@henrikra @Jukkish ping ^