question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load an ES2015 module config file

See original GitHub issue

I am writing a CLI tool where I want my end users to be able to write their config file in ES6/7/Next, how can I accomplish this?

Eg, my foo.config.js file:

import foo from './foo'

export default {  foo, someOtherOption: true }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:58 (19 by maintainers)

github_iconTop GitHub Comments

3reactions
davidtheclarkcommented, Mar 16, 2018

Regarding require vs require-from-string: I think we should switch to using require directly unless we come up with some solid reasons not to.

The only one I think there was in the fast was that when you run across a JS config file, you end up having to look at it twice: once to see that it exists, then you require it and it gets read again. (As opposed to the other loaders, which try to read the file and parse it in one move.) But I don’t think that’s a serious performance, really, because the synchronous require call that duplicates a little bit of work only happens once and only if a JS config file is found.

So, to reiterate, if there aren’t better reasons than that to use require-from-string, I think we should cut the dependency and use require directly.

3reactions
shellscapecommented, Mar 13, 2018

I’d like to contribute a vote to not bundling babel with comiconfig. webpack-serve is being integrated into some rather larger packages that have some prominent users that are frankly, a bit overly sensitive about package cost.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >
How to transpile ES modules with webpack and Node.js
The babel-loader loads ES2015+ code and transpiles it to ES5 using Babel. As you can also see in the config file, we have...
Read more >
How can I use ES6 in webpack.config.js? - Stack Overflow
Try naming your config as webpack.config.babel.js . You should have babel-register included in the project. Example at react-router-bootstrap.
Read more >
Using ES2015 (ES6) Modules with Babel 6 | by Leon Revill
This will convert any JavaScript file within the src folder to ES5, plus converting any ES2015 module related code into the SystemJS equivalent...
Read more >
16. Modules - Exploring JS
ES6 modules are stored in files. ... Programmatic loader API: to configure how modules are loaded and to conditionally load modules ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found