Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack verbose #401

Merged
merged 3 commits into from
Mar 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cli/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ module.exports = {
boolean: true,
description: 'Enables hot reloading. Note: when hot reloading is set to true, each request to the component will make the registry to create a new instance for the javascript closures to be loaded, while when false the instance will be recycled between components executions',
default: true
},
verbose: {
boolean: true,
description: 'Verbosity',
default: false
}
},
usage: 'Usage: $0 dev <dirName> [port] [baseUrl] [options]'
Expand Down
11 changes: 5 additions & 6 deletions src/cli/domain/package-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ var getUnixUtcTimestamp = require('../../utils/get-unix-utc-timestamp');
var validator = require('../../registry/domain/validators');

module.exports = function(){
return function(componentPath, minify, callback){
return function(options, callback){
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this signature to accept an options parameter instead of adding another one

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if we should have a minify option at all, but probably I'm missing some context. Why would we want to set minify, what are we trying to solve?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minify is been there for a long time. It is not referred to server.js, not to template.js, but to actual static contents in the static folders. It is set component based on the package.json, and we use it for some components at opentable. I can show you some examples on Monday.


if(_.isFunction(minify)){
callback = minify;
minify = true;
}
var componentPath = options.componentPath;
var minify = options.minify || true;

var files = fs.readdirSync(componentPath),
publishPath = path.join(componentPath, '_package');
Expand Down Expand Up @@ -72,7 +70,8 @@ module.exports = function(){
componentPath: componentPath,
dependencies: component.dependencies,
ocOptions: component.oc,
publishPath: publishPath
publishPath: publishPath,
verbose: options.verbose
}, function(err, packagedServerScriptInfo){
if(err){ return cb(err); }

Expand Down
7 changes: 5 additions & 2 deletions src/cli/domain/package-server-script/bundle/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*jshint camelcase:false */
'use strict';
var webpackConfig = require('./config');
var console = require('console');
var MemoryFS = require('memory-fs');
var webpack = require('webpack');

Expand Down Expand Up @@ -32,7 +31,11 @@ module.exports = function bundle(params, callBack) {
warning = info.warnings.toString();
}

console.log(stats.toString(params.webpack.stats));
var log = stats.toString(params.webpack.stats);

if(!!log){
console.log(log);
}

var serverContentBundled = memoryFs.readFileSync('/build/server.js', 'UTF8');
callBack(warning, serverContentBundled);
Expand Down
15 changes: 4 additions & 11 deletions src/cli/domain/package-server-script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@

var fs = require('fs-extra');
var path = require('path');
var hashBuilder = require('../../../utils/hash-builder');
var bundle = require('./bundle');

var webpackDefaults = {
stats: {
chunks: false,
colors: true,
version: false,
hash: false
}
};
var bundle = require('./bundle');
var hashBuilder = require('../../../utils/hash-builder');

module.exports = function packageServerScript(params, callback){
var fileName = 'server.js';
var publishPath = params.publishPath;
var webpackParams = { stats: params.verbose ? 'verbose' : 'errors-only' };

var bundleParams = {
webpack: params.webpack || webpackDefaults,
webpack: params.webpack || webpackParams,
dependencies: params.dependencies || {},
fileName: fileName,
dataPath: path.join(params.componentPath, params.ocOptions.files.data)
Expand Down
9 changes: 8 additions & 1 deletion src/cli/facade/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ module.exports = function(dependencies){
log.warn(strings.messages.cli.PACKAGING_COMPONENTS, true);

async.eachSeries(componentsDirs, function(dir, cb){
local.package(dir, false, function(err){

var packageOptions = {
componentPath: dir,
minify: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does minify do ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minification of js/css static assets

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the PR for webpack verbosity? Or the PR scope changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I changed the signature there, not altering the behaviour. The false there was for minify

verbose: opts.verbose
};

local.package(packageOptions, function(err){
if(!err){ i++; }
cb(err);
});
Expand Down
8 changes: 6 additions & 2 deletions tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ module.exports = function(grunt){
fs.writeFileSync(path.join(__dirname, '../client/src/oc-client.min.js'), compressedCode);

var Local = require('../src/cli/domain/local'),
local = new Local({ logger: { log: grunt.log.writeln }});
local = new Local({ logger: { log: grunt.log.writeln }}),
packageOptions = {
componentPath: path.join(__dirname, clientComponentDir),
verbose: false
};

local.package(path.join(__dirname, clientComponentDir), function(err, res){
local.package(packageOptions, function(err, res){
grunt.log[!!err ? 'error' : 'ok'](!!err ? err : 'Client has been built and packaged');
done();
});
Expand Down
6 changes: 5 additions & 1 deletion test/unit/cli-domain-package-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ var initialise = function(){
};

var executePackaging = function(local, callback){
return local('.', false, callback);
return local({
componentPath: '.',
minify: false,
verbose: false
}, callback);
};

describe('cli : domain : local', function(){
Expand Down