Skip to content

Commit

Permalink
Merge pull request #2 from taehwanno/next
Browse files Browse the repository at this point in the history
Support webpack v4
  • Loading branch information
taehwanno committed Jun 12, 2018
2 parents 637b3e4 + 8aa494a commit dbdf219
Show file tree
Hide file tree
Showing 10 changed files with 4,291 additions and 786 deletions.
9 changes: 8 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ jobs:
key: dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Install Dependency
command: yarn install
command: |
yarn install
cd ./test
cd ./v2-3 && yarn install && cd ..
cd ./v4 && yarn install && cd ..
cd ..
- save_cache:
key: dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- ./test/v2-3/node_modules
- ./test/v4/node_modules
- ~/.yarn-cache
- run:
name: Test
Expand Down
28 changes: 17 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@

class WarningsToErrorsPlugin {
apply(compiler) {
compiler.plugin('should-emit', (compilation) => {
if (compilation.warnings.length > 0) {
compilation.errors = compilation.errors.concat(compilation.warnings);
compilation.warnings = [];
}
if ('hooks' in compiler) {
compiler.hooks.shouldEmit.tap('WarningsToErrorsPlugin', this.handleHook);
} else {
compiler.plugin('should-emit', this.handleHook);
}
}

compilation.children.forEach((child) => {
if (child.warnings.length > 0) {
child.errors = child.errors.concat(child.warnings);
child.warnings = [];
}
});
handleHook(compilation) {
if (compilation.warnings.length > 0) {
compilation.errors = compilation.errors.concat(compilation.warnings);
compilation.warnings = [];
}

compilation.children.forEach((child) => {
if (child.warnings.length > 0) {
child.errors = child.errors.concat(child.warnings);
child.warnings = [];
}
});
}
}
Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"name": "warnings-to-errors-webpack-plugin",
"version": "1.0.0",
"version": "2.0.0-alpha.1",
"description": "Change every warning as error to ensure safe build",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/taehwanno/warnings-to-errors-webpack-plugin"
},
"author": "Taehwan, No <taehwanno.dev@gmail.com>",
"author": "Taehwan Noh <taehwanno.dev@gmail.com>",
"bugs": {
"url": "https://github.com/taehwanno/warnings-to-errors-webpack-plugin/issues"
},
"homepage": "https://github.com/taehwanno/warnings-to-errors-webpack-plugin",
"keywords": ["webpack", "plugin", "webpack-plugin"],
"keywords": [
"webpack",
"plugin",
"webpack-plugin"
],
"license": "MIT",
"scripts": {
"test": "cross-env NODE_ENV=test jest",
Expand All @@ -22,10 +26,9 @@
"devDependencies": {
"cross-env": "^5.1.3",
"jest": "^22.1.4",
"should": "^13.2.1",
"webpack": "^3.10.0"
"should": "^13.2.1"
},
"peerDependencies": {
"webpack": "^2.2.0-rc || ^3"
"webpack": "^2.2.0-rc || ^3 || ^4"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const path = require('path');
const should = require('should');
const webpack = require('webpack');
const WarningsToErrorsPlugin = require('../');
const WarningsToErrorsPlugin = require('../../');

const base = path.join(__dirname, 'fixtures');
const base = path.join(__dirname, '../fixtures');

describe('WarningsToErrorsPlugin', () => {
function customOutputFilesystem(c) {
Expand Down
10 changes: 10 additions & 0 deletions test/v2-3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "v2-3",
"version": "0.0.0",
"main": "index.spec.js",
"license": "MIT",
"private": true,
"dependencies": {
"webpack": "2.2.0-rc.0"
}
}
Loading

0 comments on commit dbdf219

Please sign in to comment.