Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Neutrino webpack #127

Merged
merged 2 commits into from
Mar 20, 2017
Merged

Conversation

jaridmargolin
Copy link
Contributor

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?

Copy link
Member

@eliperelman eliperelman left a 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!

}

test(args) {
return this.runCommand('test', args);
}

runCommand(command, args = {}, fn) {
runCommand(command, args = {}, fn = noop) {
Copy link
Member

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);
Copy link
Member

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 = {
Copy link
Member

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
};

@eliperelman
Copy link
Member

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.

@jaridmargolin
Copy link
Contributor Author

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?

@eliperelman eliperelman merged commit 3ed24a4 into neutrinojs:master Mar 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants