Skip to content

Commit 6abf46c

Browse files
authored
Merge pull request webpack#3546 from webpack/test/watch-ignore-plugin
watch ignore plugin
2 parents 692143c + bd10fca commit 6abf46c

File tree

15 files changed

+36
-26
lines changed

15 files changed

+36
-26
lines changed

lib/WebpackOptionsApply.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ WebpackOptionsApply.prototype.constructor = WebpackOptionsApply;
5656

5757
WebpackOptionsApply.prototype.process = function(options, compiler) {
5858
var ExternalsPlugin;
59-
compiler.context = options.context;
60-
if(options.plugins && Array.isArray(options.plugins)) {
61-
compiler.apply.apply(compiler, options.plugins);
62-
}
6359
compiler.outputPath = options.output.path;
6460
compiler.recordsInputPath = options.recordsInputPath || options.recordsPath;
6561
compiler.recordsOutputPath = options.recordsOutputPath || options.recordsPath;

lib/WebpackOptionsDefaulter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ function WebpackOptionsDefaulter() {
7373

7474
this.set("performance.maxAssetSize", 250000);
7575
this.set("performance.maxEntrypointSize", 250000);
76-
this.set("performance.errorOnHint", false);
7776
this.set("performance.hints", "make", function(options) {
7877
if(options.target === "web" || options.target === "webworker")
7978
return "warning";

lib/webpack.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ function webpack(options, callback) {
2525
new WebpackOptionsDefaulter().process(options);
2626

2727
compiler = new Compiler();
28+
compiler.context = options.context;
29+
compiler.options = options;
2830
new NodeEnvironmentPlugin().apply(compiler);
31+
if(options.plugins && Array.isArray(options.plugins)) {
32+
compiler.apply.apply(compiler, options.plugins);
33+
}
2934
compiler.applyPlugins("environment");
3035
compiler.applyPlugins("after-environment");
31-
compiler.options = options;
3236
compiler.options = new WebpackOptionsApply().process(options, compiler);
3337
} else {
3438
throw new Error("Invalid argument: options");

test/Compiler-caching.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var path = require("path");
33
var fs = require("fs");
44

55
var NodeEnvironmentPlugin = require("../lib/node/NodeEnvironmentPlugin");
6-
var Compiler = require("../lib/Compiler");
6+
var webpack = require("../");
77
var WebpackOptionsApply = require("../lib/WebpackOptionsApply");
88
var WebpackOptionsDefaulter = require("../lib/WebpackOptionsDefaulter");
99

@@ -22,9 +22,7 @@ describe("Compiler (caching)", function() {
2222
writeFile: [],
2323
};
2424

25-
var c = new Compiler();
26-
new NodeEnvironmentPlugin().apply(c);
27-
c.options = new WebpackOptionsApply().process(options, c);
25+
var c = webpack(options);
2826
var files = {};
2927
c.outputFileSystem = {
3028
join: path.join.bind(path),

test/Compiler.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var should = require("should");
22
var path = require("path");
33

44
var NodeEnvironmentPlugin = require("../lib/node/NodeEnvironmentPlugin");
5-
var Compiler = require("../lib/Compiler");
5+
var webpack = require("../");
66
var WebpackOptionsApply = require("../lib/WebpackOptionsApply");
77
var WebpackOptionsDefaulter = require("../lib/WebpackOptionsDefaulter");
88

@@ -19,9 +19,7 @@ describe("Compiler", function() {
1919
writeFile: [],
2020
};
2121

22-
var c = new Compiler();
23-
new NodeEnvironmentPlugin().apply(c);
24-
c.options = new WebpackOptionsApply().process(options, c);
22+
var c = webpack(options);
2523
var files = {};
2624
c.outputFileSystem = {
2725
join: path.join.bind(path),

test/WatchTestCases.test.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ describe("WatchTestCases", function() {
7070
describe(testName, function() {
7171
var tempDirectory = path.join(__dirname, "js", "watch-src", category.name, testName);
7272
var testDirectory = path.join(casesPath, category.name, testName);
73-
var runs = fs.readdirSync(testDirectory).sort().map(function(name) {
73+
var runs = fs.readdirSync(testDirectory).sort().filter(function(name) {
74+
return fs.statSync(path.join(testDirectory, name)).isDirectory();
75+
}).map(function(name) {
7476
return {
7577
name: name,
7678
suite: describe(name, function() {})
@@ -83,15 +85,17 @@ describe("WatchTestCases", function() {
8385
this.timeout(30000);
8486
var outputDirectory = path.join(__dirname, "js", "watch", category.name, testName);
8587

86-
var options = {
87-
context: tempDirectory,
88-
entry: "./index.js",
89-
output: {
90-
path: outputDirectory,
91-
pathinfo: true,
92-
filename: "bundle.js"
93-
}
94-
};
88+
var options = {};
89+
var configPath = path.join(testDirectory, "webpack.config.js");
90+
if(fs.existsSync(configPath))
91+
options = require(configPath);
92+
if(!options.context) options.context = tempDirectory;
93+
if(!options.entry) options.entry = "./index.js";
94+
if(!options.target) options.target = "async-node";
95+
if(!options.output) options.output = {};
96+
if(!options.output.path) options.output.path = outputDirectory;
97+
if(typeof options.output.pathinfo === "undefined") options.output.pathinfo = true;
98+
if(!options.output.filename) options.output.filename = "bundle.js";
9599

96100
var runIdx = 0;
97101
var run = runs[runIdx];

test/configCases/plugins/watch-ignore-plugin/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 0;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 1;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import value from "./file"
2+
import a from "./a"
3+
it("should ignore change to file", function() {
4+
a.should.be.eql(+WATCH_STEP);
5+
value.should.be.eql(1);
6+
});

0 commit comments

Comments
 (0)