-
Notifications
You must be signed in to change notification settings - Fork 213
Neutrino webpack #127
Neutrino webpack #127
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving this so far!
packages/neutrino/src/neutrino.js
Outdated
} | ||
|
||
test(args) { | ||
return this.runCommand('test', args); | ||
} | ||
|
||
runCommand(command, args = {}, fn) { | ||
runCommand(command, args = {}, fn = noop) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need a special noop
here, we can either use identity
from Ramda, or Function.prototype
:
runCommand(command, args = {}, fn = identity) {
runCommand(command, args = {}, fn = Function.prototype) {
const DevServer = require('webpack-dev-server'); | ||
|
||
module.exports = _config => new Promise((resolve) => { | ||
const config = merge({}, _config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be consolidated to some defaults:
const config = merge({
devServer: {
https: false,
host: 'localhost',
port: 5000,
noInfo: true
}
}, _config);
const protocol = config.devServer.https ? 'https' : 'http';
const { host, port } = config.devServer;
const url = `${protocol}://${host}:${port}`;
@@ -0,0 +1,24 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing this makes me wish we had ES modules here. sigh
Maybe we can save some nesting by just naming them:
module.exports.handle = /* ... */
module.exports.logStats = /* ... */
module.exports.logErrors = /* ... */
We could also use object shorthand to reduce nesting:
function handle() {}
function logStats() {}
function logErrors() {}
module.exports = {
handle,
logStats,
logErrors
};
Testing the stuff that touches Webpack is hard, mostly because we want to avoid actually building something, and if we do, how would we ensure the output is correct, or that is starts as expected? Half that battle is just making sure Webpack operates as expected, and I'm not sure that is a road we even want to go down. |
I don't think the output is necessary to test. It would be great however, if we could test if the command runs without errors. I think this WOULD require actually building assets. Could be similar to the setup in requireMIddleware tests? |
fc35c64
to
9826301
Compare
This is the least tested functionality in the
neutrino
package. Hard to make changes with a high degree of confidence. I am willing to write tests around this, but wanted to discuss what it would look like first. Any thoughts? I don't see a path to mocking the tests. May actually have to compile?