Use `require` instead of `import`
See original GitHub issueI 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)
- 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Difference between node.js require and ES6 import and export
Require is Non-lexical, it stays where they have put the file. Import is lexical, it gets sorted to the top of the file....
Read more >Using Node.js require vs. ES6 import/export - Stack Overflow
See when we require the component in asynchronous way, then we use import it in some async manner as in const variable using...
Read more >JavaScript Require vs. Import - Bits and Pieces
1. Require statements can be called anywhere in the code · 2. Require can be called conditionally · 3. Import statements are asynchronous...
Read more >Require vs Import | Know The 4 Most Amazing Comparisons
Require is more of dynamic analysis, and import is more of static analysis. · Require Throws error at runtime and Import throws error...
Read more >Compare require() vs import() in JavaScript | by Sumeet Bhalla
require () statements are called synchronously one by one whereas import() are called asynchronously and they are known to perform well compared ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 you can : Save files with ES6 modules with .mjs extension and run it like:
node --experimental-modules my-app.mjs