Additional usage: flow style comment
See original GitHub issueHey cool project! 😄
I was thinking another usage could be to have flow (// @flow
) style comments at the start of a file to be ran through preval
.
That way the consumer of a file would not need to annotate an import. Instead a module would have the scope defined to be pre-evaluated, without the need to explicitly import babel-plugin-preval
.
Example:
foo.js
// @preval
const fs = require('fs');
module.exports = fs.readFileSync(require.resolve('./foo.txt'), 'utf8');
// ↓ ↓ ↓ ↓ ↓ ↓
module.exports = "Hello world!"
bar.js
const foo = require('./foo');
console.log(foo); // Hello world!
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
No results found
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 Free
Top 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
Supported!
Nice one lets see how I get on 😉