Load an ES2015 module config file
See original GitHub issueI 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:
- Created 6 years ago
- Reactions:1
- Comments:58 (19 by maintainers)
Top 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 >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
Regarding
require
vs require-from-string: I think we should switch to usingrequire
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 synchronousrequire
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.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.