flow-runtime
flow-runtime copied to clipboard
Use `require` instead of `import`
I just started to use flow-runtime & babel-plugin-flow-runtime, because these are very powerful packages.
This is a:
- [ ] Bug Report
- [x] Feature Request
- [ ] Question
- [ ] Other
Which concerns:
- [ ] flow-runtime
- [X] babel-plugin-flow-runtime
- [ ] flow-runtime-validators
- [ ] flow-runtime-mobx
- [ ] flow-config-parser
- [ ] The documentation website
What is the current behaviour?
Currently babel-plugin-flow-runtime generates code like this:
import t from 'flow-runtime';
const User = t.type('User', t.object(
t.property('id', t.number()),
t.property('name', t.string())
));
What is the expected behaviour?
My proposal is generating code like this:
const t = require('flow-runtime');
const User = t.type('User', t.object(
t.property('id', t.number()),
t.property('name', t.string())
));
If I can use flow-runtime & babel-plugin-flow-runtime without adding another plugin to transpile import, it becomes non-intrusive.
Which package versions are you using?
IssueHunt Summary
Backers (Total: $40.00)
issuehunt ($40.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
IssueHunt has been backed by the following sponsors. Become a sponsor
I would say an option to choose between import and require is best. There are also cases where one would prefer to output import statements (e.g. for webpack)
I agree with an option is best. So I try to add the option and will make a PR.
@tnayuki, I know this was a long time ago, but have you managed to make a fix? Even when I add another plugin those damn imports flow-runtime generates are not transpiled for me and I get a crash of my RN app...
@issuehunt has funded $40.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
@tnayuki you can :
Save files with ES6 modules with .mjs extension and run it like:
node --experimental-modules my-app.mjs