Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[fixed] webpack warnings are purely for informational purposes and do…
Browse files Browse the repository at this point in the history
… not abort the compilation
  • Loading branch information
thealjey committed Jan 26, 2016
1 parent 70613d2 commit cf43b9f
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 48 deletions.
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"transform-property-literals",
"transform-merge-sibling-variables",
"transform-remove-debugger",
"transform-react-constant-elements",
"transform-react-inline-elements"
"transform-react-constant-elements"
]
}
}
Expand Down
16 changes: 9 additions & 7 deletions docs/JSCompiler.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,18 @@ <h1 class="page-title">Source: JSCompiler.js</h1>

compiler.outputFileSystem = fakeFS;

compiler.run((error, stats) => {
if (error) {
return console.error(error);
compiler.run((err, stats) => {
if (err) {
return console.error(err);
}
const jsonStats = stats.toJson(),
errors = jsonStats.errors.concat(jsonStats.warnings);
const {warnings, errors} = stats.toJson();

forEach(warnings, warning => {
console.log('\x1b[33m%s\x1b[0m', warning);
});
if (errors.length) {
return forEach(errors, err => {
console.error(err);
return forEach(errors, error => {
console.error(error);
});
}
this.optimize(inPath, outPath, {
Expand Down
2 changes: 1 addition & 1 deletion docs/quicksearch.html

Large diffs are not rendered by default.

File renamed without changes.
8 changes: 0 additions & 8 deletions interfaces/clean-css.js

This file was deleted.

23 changes: 18 additions & 5 deletions interfaces/lodash.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
type LoDashIteratee = (value: any, key: number|string, collection: Array<any>|Object) => void;

declare module 'lodash/forEach' {
declare var exports: (collection: Array<any>|Object, iteratee: ?LoDashIteratee) => Array<any>|Object;
}
type LoDashCallback = (value: any, key: number|string, collection: Array<any>|Object) => any;
type LoDashIteratee = LoDashCallback|Object|Array<any>|string;

declare module 'lodash/noop' {
declare var exports: (...args: Array<any>) => void;
Expand All @@ -11,3 +8,19 @@ declare module 'lodash/noop' {
declare module 'lodash/constant' {
declare var exports: (value: any) => any;
}

declare module 'lodash/forEach' {
declare var exports: (collection: Array<any>|Object, iteratee: ?LoDashIteratee) => Array<any>|Object;
}

declare module 'lodash/filter' {
declare var exports: (collection: Array<any>|Object, iteratee: ?LoDashIteratee) => Array<any>;
}

declare module 'lodash/map' {
declare var exports: (collection: Array<any>|Object, iteratee: ?LoDashIteratee) => Array<any>;
}

declare module 'lodash/find' {
declare var exports: (collection: Array<any>|Object, iteratee: ?LoDashIteratee) => any;
}
3 changes: 0 additions & 3 deletions interfaces/uglify-js.js

This file was deleted.

20 changes: 13 additions & 7 deletions lib/JSCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,22 @@ var JSCompiler = exports.JSCompiler = function (_Compiler) {

compiler.outputFileSystem = fakeFS;

compiler.run(function (error, stats) {
if (error) {
return console.error(error);
compiler.run(function (err, stats) {
if (err) {
return console.error(err);
}
var jsonStats = stats.toJson(),
errors = jsonStats.errors.concat(jsonStats.warnings);

var _stats$toJson = stats.toJson();

var warnings = _stats$toJson.warnings;
var errors = _stats$toJson.errors;

(0, _forEach2.default)(warnings, function (warning) {
console.log('\x1b[33m%s\x1b[0m', warning);
});
if (errors.length) {
return (0, _forEach2.default)(errors, function (err) {
console.error(err);
return (0, _forEach2.default)(errors, function (error) {
console.error(error);
});
}
_this6.optimize(inPath, outPath, {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"babel-plugin-transform-property-literals": "^6.3.13",
"babel-plugin-transform-react-constant-elements": "^6.4.0",
"babel-plugin-transform-react-display-name": "^6.4.0",
"babel-plugin-transform-react-inline-elements": "^6.4.0",
"babel-plugin-transform-remove-debugger": "^6.3.13",
"babel-plugin-transform-runtime": "^6.4.3",
"babel-preset-es2015": "^6.3.13",
Expand All @@ -71,7 +70,7 @@
"eslint-config-airbnb": "^4.0.0",
"eslint-plugin-babel": "^3.0.0",
"eslint-plugin-flow-vars": "^0.1.3",
"eslint-plugin-lodash": "^1.0.1",
"eslint-plugin-lodash": "^1.0.2",
"eslint-plugin-react": "^3.16.1",
"fb-watchman": "^1.8.0",
"ink-docstrap": "^1.1.0",
Expand All @@ -93,7 +92,7 @@
"chai": "^3.4.1",
"coveralls": "^2.11.6",
"isparta": "^4.0.0",
"mocha": "^2.3.4",
"mocha": "^2.4.1",
"mt-changelog": "^0.6.2",
"proxyquire": "^1.7.3",
"release-script": "^1.0.2",
Expand Down
16 changes: 9 additions & 7 deletions src/JSCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,18 @@ export class JSCompiler extends Compiler {

compiler.outputFileSystem = fakeFS;

compiler.run((error, stats) => {
if (error) {
return console.error(error);
compiler.run((err, stats) => {
if (err) {
return console.error(err);
}
const jsonStats = stats.toJson(),
errors = jsonStats.errors.concat(jsonStats.warnings);
const {warnings, errors} = stats.toJson();

forEach(warnings, warning => {
console.log('\x1b[33m%s\x1b[0m', warning);
});
if (errors.length) {
return forEach(errors, err => {
console.error(err);
return forEach(errors, error => {
console.error(error);
});
}
this.optimize(inPath, outPath, {
Expand Down
15 changes: 10 additions & 5 deletions test/JSCompiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ describe('JSCompiler', () => {
beforeEach(() => {
callback = spy();
stub(console, 'error');
stub(console, 'log');
stub(OptionManager.prototype, 'init').returns({resolved: 'options'});
});

afterEach(() => {
console.error.restore();
console.log.restore();
OptionManager.prototype.init.restore();
});

Expand Down Expand Up @@ -190,14 +192,17 @@ describe('JSCompiler', () => {
cmp.optimize.restore();
});

it('prints the error on screen', () => {
it('prints the warnings on screen', () => {
expect(console.log).calledWith('\x1b[33m%s\x1b[0m', 'you');
expect(console.log).calledWith('\x1b[33m%s\x1b[0m', 'cannot');
expect(console.log).calledWith('\x1b[33m%s\x1b[0m', 'do');
expect(console.log).calledWith('\x1b[33m%s\x1b[0m', 'that');
});

it('prints the errors on screen', () => {
expect(console.error).calledWith('something');
expect(console.error).calledWith('bad');
expect(console.error).calledWith('happened');
expect(console.error).calledWith('you');
expect(console.error).calledWith('cannot');
expect(console.error).calledWith('do');
expect(console.error).calledWith('that');
});

it('does not call cmp.optimize', () => {
Expand Down

0 comments on commit cf43b9f

Please sign in to comment.