Skip to content
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

Use require instead of import #207

Open
2 of 10 tasks
tnayuki opened this issue Jun 4, 2018 · 5 comments
Open
2 of 10 tasks

Use require instead of import #207

tnayuki opened this issue Jun 4, 2018 · 5 comments
Labels
💵 Funded on Issuehunt This issue has been funded on Issuehunt

Comments

@tnayuki
Copy link

tnayuki commented Jun 4, 2018

Issuehunt badges

I just started to use flow-runtime & babel-plugin-flow-runtime, because these are very powerful packages.

This is a:

  • Bug Report
  • Feature Request
  • Question
  • Other

Which concerns:

  • flow-runtime
  • 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)

Become a backer now!

Or submit a pull request to get the deposits!

Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

@jedwards1211
Copy link
Collaborator

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)

@tnayuki
Copy link
Author

tnayuki commented Jun 5, 2018

I agree with an option is best.
So I try to add the option and will make a PR.

@terreb
Copy link

terreb commented Jul 10, 2019

@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-oss
Copy link

issuehunt-oss bot commented Jul 24, 2019

@issuehunt has funded $40.00 to this issue.


@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label Jul 24, 2019
@bu7ch
Copy link

bu7ch commented Aug 7, 2019

@tnayuki you can :
Save files with ES6 modules with .mjs extension and run it like:
node --experimental-modules my-app.mjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💵 Funded on Issuehunt This issue has been funded on Issuehunt
Projects
None yet
Development

No branches or pull requests

4 participants