webpack 2.1.0-beta.24 → 2.1.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config-yargs.js +0 -5
- package/bin/webpack.js +6 -0
- package/lib/AbstractPlugin.js +22 -22
- package/lib/ArrayMap.js +50 -50
- package/lib/DelegatedModuleFactoryPlugin.js +51 -51
- package/lib/EntryOptionPlugin.js +28 -28
- package/lib/ModuleParserHelpers.js +21 -21
- package/lib/NamedModulesPlugin.js +21 -21
- package/lib/RuleSet.js +369 -369
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +33 -33
- package/lib/WebpackOptionsValidationError.js +13 -0
- package/lib/dependencies/ContextDependencyTemplateAsId.js +22 -22
- package/lib/node/NodeSourcePlugin.js +84 -84
- package/lib/node/NodeWatchFileSystem.js +65 -65
- package/lib/optimize/OccurrenceOrderPlugin.js +96 -96
- package/lib/webpack.web.js +27 -27
- package/package.json +1 -1
- package/schemas/webpackOptionsSchema.json +2 -1
- package/README.md +0 -315
@@ -1,33 +1,33 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
6
|
-
|
7
|
-
function SourceMapDevToolModuleOptionsPlugin(options) {
|
8
|
-
this.options = options;
|
9
|
-
}
|
10
|
-
|
11
|
-
module.exports = SourceMapDevToolModuleOptionsPlugin;
|
12
|
-
|
13
|
-
SourceMapDevToolModuleOptionsPlugin.prototype.apply = function(compilation) {
|
14
|
-
var options = this.options;
|
15
|
-
if(options.module !== false) {
|
16
|
-
compilation.plugin("build-module", function(module) {
|
17
|
-
module.useSourceMap = true;
|
18
|
-
});
|
19
|
-
}
|
20
|
-
if(options.lineToLine === true) {
|
21
|
-
compilation.plugin("build-module", function(module) {
|
22
|
-
module.lineToLine = true;
|
23
|
-
});
|
24
|
-
} else if(options.lineToLine) {
|
25
|
-
compilation.plugin("build-module", function(module) {
|
26
|
-
if(!module.resource) return;
|
27
|
-
var resourcePath = module.resource;
|
28
|
-
var idx = resourcePath.indexOf("?");
|
29
|
-
if(idx >= 0) resourcePath = resourcePath.substr(0, idx);
|
30
|
-
module.lineToLine = ModuleFilenameHelpers.matchObject(options.lineToLine, resourcePath);
|
31
|
-
});
|
32
|
-
}
|
33
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
|
6
|
+
|
7
|
+
function SourceMapDevToolModuleOptionsPlugin(options) {
|
8
|
+
this.options = options;
|
9
|
+
}
|
10
|
+
|
11
|
+
module.exports = SourceMapDevToolModuleOptionsPlugin;
|
12
|
+
|
13
|
+
SourceMapDevToolModuleOptionsPlugin.prototype.apply = function(compilation) {
|
14
|
+
var options = this.options;
|
15
|
+
if(options.module !== false) {
|
16
|
+
compilation.plugin("build-module", function(module) {
|
17
|
+
module.useSourceMap = true;
|
18
|
+
});
|
19
|
+
}
|
20
|
+
if(options.lineToLine === true) {
|
21
|
+
compilation.plugin("build-module", function(module) {
|
22
|
+
module.lineToLine = true;
|
23
|
+
});
|
24
|
+
} else if(options.lineToLine) {
|
25
|
+
compilation.plugin("build-module", function(module) {
|
26
|
+
if(!module.resource) return;
|
27
|
+
var resourcePath = module.resource;
|
28
|
+
var idx = resourcePath.indexOf("?");
|
29
|
+
if(idx >= 0) resourcePath = resourcePath.substr(0, idx);
|
30
|
+
module.lineToLine = ModuleFilenameHelpers.matchObject(options.lineToLine, resourcePath);
|
31
|
+
});
|
32
|
+
}
|
33
|
+
};
|
@@ -27,6 +27,18 @@ WebpackOptionsValidationError.formatValidationError = function formatValidationE
|
|
27
27
|
var baseMessage = dataPath + " has an unknown property '" + err.params.additionalProperty + "'. These properties are valid:\n" +
|
28
28
|
getSchemaPartText(err.parentSchema);
|
29
29
|
if(!err.dataPath) {
|
30
|
+
switch(err.params.additionalProperty) {
|
31
|
+
case "debug":
|
32
|
+
return baseMessage + "\n" +
|
33
|
+
"The 'debug' property was removed in webpack 2.\n" +
|
34
|
+
"Loaders should be updated to allow passing this option via loader options in module.rules.\n" +
|
35
|
+
"Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:\n" +
|
36
|
+
"plugins: {\n" +
|
37
|
+
" new webpack.LoaderOptionsPlugin({\n" +
|
38
|
+
" debug: true\n" +
|
39
|
+
" })\n" +
|
40
|
+
"}";
|
41
|
+
}
|
30
42
|
return baseMessage + "\n" +
|
31
43
|
"For typos: please correct them.\n" +
|
32
44
|
"For loader options: webpack 2 no longer allows custom properties in configuration.\n" +
|
@@ -34,6 +46,7 @@ WebpackOptionsValidationError.formatValidationError = function formatValidationE
|
|
34
46
|
" Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
|
35
47
|
" plugins: {\n" +
|
36
48
|
" new webpack.LoaderOptionsPlugin({\n" +
|
49
|
+
" // test: /\\.xxx$/, // may apply this only for some modules\n" +
|
37
50
|
" options: {\n" +
|
38
51
|
" " + err.params.additionalProperty + ": ...\n" +
|
39
52
|
" }\n" +
|
@@ -1,22 +1,22 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function ContextDependencyTemplateAsId() {}
|
6
|
-
module.exports = ContextDependencyTemplateAsId;
|
7
|
-
|
8
|
-
ContextDependencyTemplateAsId.prototype.apply = function(dep, source, outputOptions, requestShortener) {
|
9
|
-
var comment = "";
|
10
|
-
if(outputOptions.pathinfo) comment = "/*! " + requestShortener.shorten(dep.request) + " */ ";
|
11
|
-
if(dep.module && dep.module.dependencies && dep.module.dependencies.length > 0) {
|
12
|
-
if(dep.valueRange) {
|
13
|
-
source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
|
14
|
-
source.replace(dep.range[0], dep.valueRange[0] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ").resolve(" + (typeof dep.prepend === "string" ? JSON.stringify(dep.prepend) : "") + "");
|
15
|
-
} else {
|
16
|
-
source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ").resolve");
|
17
|
-
}
|
18
|
-
} else {
|
19
|
-
var content = require("./WebpackMissingModule").module(dep.request);
|
20
|
-
source.replace(dep.range[0], dep.range[1] - 1, content);
|
21
|
-
}
|
22
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function ContextDependencyTemplateAsId() {}
|
6
|
+
module.exports = ContextDependencyTemplateAsId;
|
7
|
+
|
8
|
+
ContextDependencyTemplateAsId.prototype.apply = function(dep, source, outputOptions, requestShortener) {
|
9
|
+
var comment = "";
|
10
|
+
if(outputOptions.pathinfo) comment = "/*! " + requestShortener.shorten(dep.request) + " */ ";
|
11
|
+
if(dep.module && dep.module.dependencies && dep.module.dependencies.length > 0) {
|
12
|
+
if(dep.valueRange) {
|
13
|
+
source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
|
14
|
+
source.replace(dep.range[0], dep.valueRange[0] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ").resolve(" + (typeof dep.prepend === "string" ? JSON.stringify(dep.prepend) : "") + "");
|
15
|
+
} else {
|
16
|
+
source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ").resolve");
|
17
|
+
}
|
18
|
+
} else {
|
19
|
+
var content = require("./WebpackMissingModule").module(dep.request);
|
20
|
+
source.replace(dep.range[0], dep.range[1] - 1, content);
|
21
|
+
}
|
22
|
+
};
|
@@ -1,84 +1,84 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var AliasPlugin = require("enhanced-resolve/lib/AliasPlugin");
|
6
|
-
var ModuleParserHelpers = require("../ModuleParserHelpers");
|
7
|
-
var nodeLibsBrowser = require("node-libs-browser");
|
8
|
-
|
9
|
-
function NodeSourcePlugin(options) {
|
10
|
-
this.options = options;
|
11
|
-
}
|
12
|
-
module.exports = NodeSourcePlugin;
|
13
|
-
NodeSourcePlugin.prototype.apply = function(compiler) {
|
14
|
-
var options = this.options;
|
15
|
-
|
16
|
-
function getPathToModule(module, type) {
|
17
|
-
if(type === true || (type === undefined && nodeLibsBrowser[module])) {
|
18
|
-
if(!nodeLibsBrowser[module]) throw new Error("No browser version for node.js core module '" + module + "' available");
|
19
|
-
return nodeLibsBrowser[module];
|
20
|
-
} else if(type === "mock") {
|
21
|
-
return require.resolve("node-libs-browser/mock/" + module);
|
22
|
-
} else if(type === "empty") {
|
23
|
-
return require.resolve("node-libs-browser/mock/empty");
|
24
|
-
} else return module;
|
25
|
-
}
|
26
|
-
compiler.plugin("compilation", function(compilation, params) {
|
27
|
-
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
|
28
|
-
|
29
|
-
if(parserOptions.node === false)
|
30
|
-
return;
|
31
|
-
|
32
|
-
var localOptions = options;
|
33
|
-
if(parserOptions.node)
|
34
|
-
localOptions = Object.assign({}, localOptions, parserOptions.node);
|
35
|
-
|
36
|
-
if(localOptions.process) {
|
37
|
-
var processType = localOptions.process;
|
38
|
-
parser.plugin("expression process", function() {
|
39
|
-
return ModuleParserHelpers.addParsedVariable(this, "process", "require(" + JSON.stringify(getPathToModule("process", processType)) + ")");
|
40
|
-
});
|
41
|
-
}
|
42
|
-
if(localOptions.global) {
|
43
|
-
parser.plugin("expression global", function() {
|
44
|
-
return ModuleParserHelpers.addParsedVariable(this, "global", "require(" + JSON.stringify(require.resolve("../../buildin/global.js")) + ")");
|
45
|
-
});
|
46
|
-
}
|
47
|
-
if(localOptions.console) {
|
48
|
-
var consoleType = localOptions.console;
|
49
|
-
parser.plugin("expression console", function() {
|
50
|
-
return ModuleParserHelpers.addParsedVariable(this, "console", "require(" + JSON.stringify(getPathToModule("console", consoleType)) + ")");
|
51
|
-
});
|
52
|
-
}
|
53
|
-
var bufferType = localOptions.Buffer;
|
54
|
-
if(bufferType) {
|
55
|
-
parser.plugin("expression Buffer", function() {
|
56
|
-
return ModuleParserHelpers.addParsedVariable(this, "Buffer", "require(" + JSON.stringify(getPathToModule("buffer", bufferType)) + ").Buffer");
|
57
|
-
});
|
58
|
-
}
|
59
|
-
if(localOptions.setImmediate) {
|
60
|
-
var setImmediateType = localOptions.setImmediate;
|
61
|
-
parser.plugin("expression setImmediate", function() {
|
62
|
-
return ModuleParserHelpers.addParsedVariable(this, "setImmediate", "require(" + JSON.stringify(getPathToModule("timers", setImmediateType)) + ").setImmediate");
|
63
|
-
});
|
64
|
-
parser.plugin("expression clearImmediate", function() {
|
65
|
-
return ModuleParserHelpers.addParsedVariable(this, "clearImmediate", "require(" + JSON.stringify(getPathToModule("timers", setImmediateType)) + ").clearImmediate");
|
66
|
-
});
|
67
|
-
}
|
68
|
-
});
|
69
|
-
});
|
70
|
-
compiler.plugin("after-resolvers", function(compiler) {
|
71
|
-
var alias = {};
|
72
|
-
Object.keys(nodeLibsBrowser).forEach(function(lib) {
|
73
|
-
if(options[lib] !== false) {
|
74
|
-
compiler.resolvers.normal.apply(
|
75
|
-
new AliasPlugin("described-resolve", {
|
76
|
-
name: lib,
|
77
|
-
onlyModule: true,
|
78
|
-
alias: getPathToModule(lib, options[lib])
|
79
|
-
}, "resolve")
|
80
|
-
);
|
81
|
-
}
|
82
|
-
});
|
83
|
-
});
|
84
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var AliasPlugin = require("enhanced-resolve/lib/AliasPlugin");
|
6
|
+
var ModuleParserHelpers = require("../ModuleParserHelpers");
|
7
|
+
var nodeLibsBrowser = require("node-libs-browser");
|
8
|
+
|
9
|
+
function NodeSourcePlugin(options) {
|
10
|
+
this.options = options;
|
11
|
+
}
|
12
|
+
module.exports = NodeSourcePlugin;
|
13
|
+
NodeSourcePlugin.prototype.apply = function(compiler) {
|
14
|
+
var options = this.options;
|
15
|
+
|
16
|
+
function getPathToModule(module, type) {
|
17
|
+
if(type === true || (type === undefined && nodeLibsBrowser[module])) {
|
18
|
+
if(!nodeLibsBrowser[module]) throw new Error("No browser version for node.js core module '" + module + "' available");
|
19
|
+
return nodeLibsBrowser[module];
|
20
|
+
} else if(type === "mock") {
|
21
|
+
return require.resolve("node-libs-browser/mock/" + module);
|
22
|
+
} else if(type === "empty") {
|
23
|
+
return require.resolve("node-libs-browser/mock/empty");
|
24
|
+
} else return module;
|
25
|
+
}
|
26
|
+
compiler.plugin("compilation", function(compilation, params) {
|
27
|
+
params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
|
28
|
+
|
29
|
+
if(parserOptions.node === false)
|
30
|
+
return;
|
31
|
+
|
32
|
+
var localOptions = options;
|
33
|
+
if(parserOptions.node)
|
34
|
+
localOptions = Object.assign({}, localOptions, parserOptions.node);
|
35
|
+
|
36
|
+
if(localOptions.process) {
|
37
|
+
var processType = localOptions.process;
|
38
|
+
parser.plugin("expression process", function() {
|
39
|
+
return ModuleParserHelpers.addParsedVariable(this, "process", "require(" + JSON.stringify(getPathToModule("process", processType)) + ")");
|
40
|
+
});
|
41
|
+
}
|
42
|
+
if(localOptions.global) {
|
43
|
+
parser.plugin("expression global", function() {
|
44
|
+
return ModuleParserHelpers.addParsedVariable(this, "global", "require(" + JSON.stringify(require.resolve("../../buildin/global.js")) + ")");
|
45
|
+
});
|
46
|
+
}
|
47
|
+
if(localOptions.console) {
|
48
|
+
var consoleType = localOptions.console;
|
49
|
+
parser.plugin("expression console", function() {
|
50
|
+
return ModuleParserHelpers.addParsedVariable(this, "console", "require(" + JSON.stringify(getPathToModule("console", consoleType)) + ")");
|
51
|
+
});
|
52
|
+
}
|
53
|
+
var bufferType = localOptions.Buffer;
|
54
|
+
if(bufferType) {
|
55
|
+
parser.plugin("expression Buffer", function() {
|
56
|
+
return ModuleParserHelpers.addParsedVariable(this, "Buffer", "require(" + JSON.stringify(getPathToModule("buffer", bufferType)) + ").Buffer");
|
57
|
+
});
|
58
|
+
}
|
59
|
+
if(localOptions.setImmediate) {
|
60
|
+
var setImmediateType = localOptions.setImmediate;
|
61
|
+
parser.plugin("expression setImmediate", function() {
|
62
|
+
return ModuleParserHelpers.addParsedVariable(this, "setImmediate", "require(" + JSON.stringify(getPathToModule("timers", setImmediateType)) + ").setImmediate");
|
63
|
+
});
|
64
|
+
parser.plugin("expression clearImmediate", function() {
|
65
|
+
return ModuleParserHelpers.addParsedVariable(this, "clearImmediate", "require(" + JSON.stringify(getPathToModule("timers", setImmediateType)) + ").clearImmediate");
|
66
|
+
});
|
67
|
+
}
|
68
|
+
});
|
69
|
+
});
|
70
|
+
compiler.plugin("after-resolvers", function(compiler) {
|
71
|
+
var alias = {};
|
72
|
+
Object.keys(nodeLibsBrowser).forEach(function(lib) {
|
73
|
+
if(options[lib] !== false) {
|
74
|
+
compiler.resolvers.normal.apply(
|
75
|
+
new AliasPlugin("described-resolve", {
|
76
|
+
name: lib,
|
77
|
+
onlyModule: true,
|
78
|
+
alias: getPathToModule(lib, options[lib])
|
79
|
+
}, "resolve")
|
80
|
+
);
|
81
|
+
}
|
82
|
+
});
|
83
|
+
});
|
84
|
+
};
|
@@ -1,65 +1,65 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var Watchpack = require("watchpack");
|
6
|
-
|
7
|
-
function NodeWatchFileSystem(inputFileSystem) {
|
8
|
-
this.inputFileSystem = inputFileSystem;
|
9
|
-
this.watcherOptions = {
|
10
|
-
aggregateTimeout: 0
|
11
|
-
};
|
12
|
-
this.watcher = new Watchpack(this.watcherOptions);
|
13
|
-
}
|
14
|
-
|
15
|
-
module.exports = NodeWatchFileSystem;
|
16
|
-
|
17
|
-
NodeWatchFileSystem.prototype.watch = function watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
18
|
-
if(!Array.isArray(files))
|
19
|
-
throw new Error("Invalid arguments: 'files'");
|
20
|
-
if(!Array.isArray(dirs))
|
21
|
-
throw new Error("Invalid arguments: 'dirs'");
|
22
|
-
if(!Array.isArray(missing))
|
23
|
-
throw new Error("Invalid arguments: 'missing'");
|
24
|
-
if(typeof callback !== "function")
|
25
|
-
throw new Error("Invalid arguments: 'callback'");
|
26
|
-
if(typeof startTime !== "number" && startTime)
|
27
|
-
throw new Error("Invalid arguments: 'startTime'");
|
28
|
-
if(typeof options !== "object")
|
29
|
-
throw new Error("Invalid arguments: 'options'");
|
30
|
-
if(typeof callbackUndelayed !== "function" && callbackUndelayed)
|
31
|
-
throw new Error("Invalid arguments: 'callbackUndelayed'");
|
32
|
-
var oldWatcher = this.watcher;
|
33
|
-
this.watcher = new Watchpack(options);
|
34
|
-
|
35
|
-
if(callbackUndelayed)
|
36
|
-
this.watcher.once("change", callbackUndelayed);
|
37
|
-
|
38
|
-
this.watcher.once("aggregated", function(changes) {
|
39
|
-
if(this.inputFileSystem && this.inputFileSystem.purge) {
|
40
|
-
this.inputFileSystem.purge(changes);
|
41
|
-
}
|
42
|
-
var times = this.watcher.getTimes();
|
43
|
-
callback(null, changes.filter(function(file) {
|
44
|
-
return files.indexOf(file) >= 0;
|
45
|
-
}).sort(), changes.filter(function(file) {
|
46
|
-
return dirs.indexOf(file) >= 0;
|
47
|
-
}).sort(), changes.filter(function(file) {
|
48
|
-
return missing.indexOf(file) >= 0;
|
49
|
-
}).sort(), times, times);
|
50
|
-
}.bind(this));
|
51
|
-
|
52
|
-
this.watcher.watch(files.concat(missing), dirs, startTime);
|
53
|
-
|
54
|
-
if(oldWatcher) {
|
55
|
-
oldWatcher.close();
|
56
|
-
}
|
57
|
-
return {
|
58
|
-
close: function() {
|
59
|
-
this.watcher.close();
|
60
|
-
}.bind(this),
|
61
|
-
pause: function() {
|
62
|
-
this.watcher.pause();
|
63
|
-
}.bind(this)
|
64
|
-
};
|
65
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var Watchpack = require("watchpack");
|
6
|
+
|
7
|
+
function NodeWatchFileSystem(inputFileSystem) {
|
8
|
+
this.inputFileSystem = inputFileSystem;
|
9
|
+
this.watcherOptions = {
|
10
|
+
aggregateTimeout: 0
|
11
|
+
};
|
12
|
+
this.watcher = new Watchpack(this.watcherOptions);
|
13
|
+
}
|
14
|
+
|
15
|
+
module.exports = NodeWatchFileSystem;
|
16
|
+
|
17
|
+
NodeWatchFileSystem.prototype.watch = function watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
18
|
+
if(!Array.isArray(files))
|
19
|
+
throw new Error("Invalid arguments: 'files'");
|
20
|
+
if(!Array.isArray(dirs))
|
21
|
+
throw new Error("Invalid arguments: 'dirs'");
|
22
|
+
if(!Array.isArray(missing))
|
23
|
+
throw new Error("Invalid arguments: 'missing'");
|
24
|
+
if(typeof callback !== "function")
|
25
|
+
throw new Error("Invalid arguments: 'callback'");
|
26
|
+
if(typeof startTime !== "number" && startTime)
|
27
|
+
throw new Error("Invalid arguments: 'startTime'");
|
28
|
+
if(typeof options !== "object")
|
29
|
+
throw new Error("Invalid arguments: 'options'");
|
30
|
+
if(typeof callbackUndelayed !== "function" && callbackUndelayed)
|
31
|
+
throw new Error("Invalid arguments: 'callbackUndelayed'");
|
32
|
+
var oldWatcher = this.watcher;
|
33
|
+
this.watcher = new Watchpack(options);
|
34
|
+
|
35
|
+
if(callbackUndelayed)
|
36
|
+
this.watcher.once("change", callbackUndelayed);
|
37
|
+
|
38
|
+
this.watcher.once("aggregated", function(changes) {
|
39
|
+
if(this.inputFileSystem && this.inputFileSystem.purge) {
|
40
|
+
this.inputFileSystem.purge(changes);
|
41
|
+
}
|
42
|
+
var times = this.watcher.getTimes();
|
43
|
+
callback(null, changes.filter(function(file) {
|
44
|
+
return files.indexOf(file) >= 0;
|
45
|
+
}).sort(), changes.filter(function(file) {
|
46
|
+
return dirs.indexOf(file) >= 0;
|
47
|
+
}).sort(), changes.filter(function(file) {
|
48
|
+
return missing.indexOf(file) >= 0;
|
49
|
+
}).sort(), times, times);
|
50
|
+
}.bind(this));
|
51
|
+
|
52
|
+
this.watcher.watch(files.concat(missing), dirs, startTime);
|
53
|
+
|
54
|
+
if(oldWatcher) {
|
55
|
+
oldWatcher.close();
|
56
|
+
}
|
57
|
+
return {
|
58
|
+
close: function() {
|
59
|
+
this.watcher.close();
|
60
|
+
}.bind(this),
|
61
|
+
pause: function() {
|
62
|
+
this.watcher.pause();
|
63
|
+
}.bind(this)
|
64
|
+
};
|
65
|
+
};
|
@@ -1,96 +1,96 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function OccurrenceOrderPlugin(preferEntry) {
|
6
|
-
if(preferEntry !== undefined && typeof preferEntry !== "boolean") {
|
7
|
-
throw new Error("Argument should be a boolean.\nFor more info on this plugin, see https://webpack.github.io/docs/list-of-plugins.html");
|
8
|
-
}
|
9
|
-
this.preferEntry = preferEntry;
|
10
|
-
}
|
11
|
-
module.exports = OccurrenceOrderPlugin;
|
12
|
-
OccurrenceOrderPlugin.prototype.apply = function(compiler) {
|
13
|
-
var preferEntry = this.preferEntry;
|
14
|
-
compiler.plugin("compilation", function(compilation) {
|
15
|
-
compilation.plugin("optimize-module-order", function(modules) {
|
16
|
-
function entryChunks(m) {
|
17
|
-
return m.chunks.map(function(c) {
|
18
|
-
var sum = (c.isInitial() ? 1 : 0) + (c.entryModule === m ? 1 : 0);
|
19
|
-
return sum;
|
20
|
-
}).reduce(function(a, b) {
|
21
|
-
return a + b;
|
22
|
-
}, 0);
|
23
|
-
}
|
24
|
-
|
25
|
-
function occursInEntry(m) {
|
26
|
-
return m.reasons.map(function(r) {
|
27
|
-
if(!r.module) return 0;
|
28
|
-
return entryChunks(r.module);
|
29
|
-
}).reduce(function(a, b) {
|
30
|
-
return a + b;
|
31
|
-
}, 0) + entryChunks(m);
|
32
|
-
}
|
33
|
-
|
34
|
-
function occurs(m) {
|
35
|
-
return m.reasons.map(function(r) {
|
36
|
-
if(!r.module) return 0;
|
37
|
-
return r.module.chunks.length;
|
38
|
-
}).reduce(function(a, b) {
|
39
|
-
return a + b;
|
40
|
-
}, 0) + m.chunks.length + m.chunks.filter(function(c) {
|
41
|
-
c.entryModule === m;
|
42
|
-
}).length;
|
43
|
-
}
|
44
|
-
modules.sort(function(a, b) {
|
45
|
-
if(preferEntry) {
|
46
|
-
var aEntryOccurs = occursInEntry(a);
|
47
|
-
var bEntryOccurs = occursInEntry(b);
|
48
|
-
if(aEntryOccurs > bEntryOccurs) return -1;
|
49
|
-
if(aEntryOccurs < bEntryOccurs) return 1;
|
50
|
-
}
|
51
|
-
var aOccurs = occurs(a);
|
52
|
-
var bOccurs = occurs(b);
|
53
|
-
if(aOccurs > bOccurs) return -1;
|
54
|
-
if(aOccurs < bOccurs) return 1;
|
55
|
-
if(a.identifier() > b.identifier()) return 1;
|
56
|
-
if(a.identifier() < b.identifier()) return -1;
|
57
|
-
return 0;
|
58
|
-
});
|
59
|
-
});
|
60
|
-
compilation.plugin("optimize-chunk-order", function(chunks) {
|
61
|
-
function occursInEntry(c) {
|
62
|
-
return c.parents.filter(function(p) {
|
63
|
-
return p.isInitial();
|
64
|
-
}).length;
|
65
|
-
}
|
66
|
-
|
67
|
-
function occurs(c) {
|
68
|
-
return c.blocks.length;
|
69
|
-
}
|
70
|
-
chunks.forEach(function(c) {
|
71
|
-
c.modules.sort(function(a, b) {
|
72
|
-
if(a.identifier() > b.identifier()) return 1;
|
73
|
-
if(a.identifier() < b.identifier()) return -1;
|
74
|
-
return 0;
|
75
|
-
});
|
76
|
-
});
|
77
|
-
chunks.sort(function(a, b) {
|
78
|
-
var aEntryOccurs = occursInEntry(a);
|
79
|
-
var bEntryOccurs = occursInEntry(b);
|
80
|
-
if(aEntryOccurs > bEntryOccurs) return -1;
|
81
|
-
if(aEntryOccurs < bEntryOccurs) return 1;
|
82
|
-
var aOccurs = occurs(a);
|
83
|
-
var bOccurs = occurs(b);
|
84
|
-
if(aOccurs > bOccurs) return -1;
|
85
|
-
if(aOccurs < bOccurs) return 1;
|
86
|
-
if(a.modules.length > b.modules.length) return -1;
|
87
|
-
if(a.modules.length < b.modules.length) return 1;
|
88
|
-
for(var i = 0; i < a.modules.length; i++) {
|
89
|
-
if(a.modules[i].identifier() > b.modules[i].identifier()) return -1;
|
90
|
-
if(a.modules[i].identifier() < b.modules[i].identifier()) return 1;
|
91
|
-
}
|
92
|
-
return 0;
|
93
|
-
});
|
94
|
-
});
|
95
|
-
});
|
96
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function OccurrenceOrderPlugin(preferEntry) {
|
6
|
+
if(preferEntry !== undefined && typeof preferEntry !== "boolean") {
|
7
|
+
throw new Error("Argument should be a boolean.\nFor more info on this plugin, see https://webpack.github.io/docs/list-of-plugins.html");
|
8
|
+
}
|
9
|
+
this.preferEntry = preferEntry;
|
10
|
+
}
|
11
|
+
module.exports = OccurrenceOrderPlugin;
|
12
|
+
OccurrenceOrderPlugin.prototype.apply = function(compiler) {
|
13
|
+
var preferEntry = this.preferEntry;
|
14
|
+
compiler.plugin("compilation", function(compilation) {
|
15
|
+
compilation.plugin("optimize-module-order", function(modules) {
|
16
|
+
function entryChunks(m) {
|
17
|
+
return m.chunks.map(function(c) {
|
18
|
+
var sum = (c.isInitial() ? 1 : 0) + (c.entryModule === m ? 1 : 0);
|
19
|
+
return sum;
|
20
|
+
}).reduce(function(a, b) {
|
21
|
+
return a + b;
|
22
|
+
}, 0);
|
23
|
+
}
|
24
|
+
|
25
|
+
function occursInEntry(m) {
|
26
|
+
return m.reasons.map(function(r) {
|
27
|
+
if(!r.module) return 0;
|
28
|
+
return entryChunks(r.module);
|
29
|
+
}).reduce(function(a, b) {
|
30
|
+
return a + b;
|
31
|
+
}, 0) + entryChunks(m);
|
32
|
+
}
|
33
|
+
|
34
|
+
function occurs(m) {
|
35
|
+
return m.reasons.map(function(r) {
|
36
|
+
if(!r.module) return 0;
|
37
|
+
return r.module.chunks.length;
|
38
|
+
}).reduce(function(a, b) {
|
39
|
+
return a + b;
|
40
|
+
}, 0) + m.chunks.length + m.chunks.filter(function(c) {
|
41
|
+
c.entryModule === m;
|
42
|
+
}).length;
|
43
|
+
}
|
44
|
+
modules.sort(function(a, b) {
|
45
|
+
if(preferEntry) {
|
46
|
+
var aEntryOccurs = occursInEntry(a);
|
47
|
+
var bEntryOccurs = occursInEntry(b);
|
48
|
+
if(aEntryOccurs > bEntryOccurs) return -1;
|
49
|
+
if(aEntryOccurs < bEntryOccurs) return 1;
|
50
|
+
}
|
51
|
+
var aOccurs = occurs(a);
|
52
|
+
var bOccurs = occurs(b);
|
53
|
+
if(aOccurs > bOccurs) return -1;
|
54
|
+
if(aOccurs < bOccurs) return 1;
|
55
|
+
if(a.identifier() > b.identifier()) return 1;
|
56
|
+
if(a.identifier() < b.identifier()) return -1;
|
57
|
+
return 0;
|
58
|
+
});
|
59
|
+
});
|
60
|
+
compilation.plugin("optimize-chunk-order", function(chunks) {
|
61
|
+
function occursInEntry(c) {
|
62
|
+
return c.parents.filter(function(p) {
|
63
|
+
return p.isInitial();
|
64
|
+
}).length;
|
65
|
+
}
|
66
|
+
|
67
|
+
function occurs(c) {
|
68
|
+
return c.blocks.length;
|
69
|
+
}
|
70
|
+
chunks.forEach(function(c) {
|
71
|
+
c.modules.sort(function(a, b) {
|
72
|
+
if(a.identifier() > b.identifier()) return 1;
|
73
|
+
if(a.identifier() < b.identifier()) return -1;
|
74
|
+
return 0;
|
75
|
+
});
|
76
|
+
});
|
77
|
+
chunks.sort(function(a, b) {
|
78
|
+
var aEntryOccurs = occursInEntry(a);
|
79
|
+
var bEntryOccurs = occursInEntry(b);
|
80
|
+
if(aEntryOccurs > bEntryOccurs) return -1;
|
81
|
+
if(aEntryOccurs < bEntryOccurs) return 1;
|
82
|
+
var aOccurs = occurs(a);
|
83
|
+
var bOccurs = occurs(b);
|
84
|
+
if(aOccurs > bOccurs) return -1;
|
85
|
+
if(aOccurs < bOccurs) return 1;
|
86
|
+
if(a.modules.length > b.modules.length) return -1;
|
87
|
+
if(a.modules.length < b.modules.length) return 1;
|
88
|
+
for(var i = 0; i < a.modules.length; i++) {
|
89
|
+
if(a.modules[i].identifier() > b.modules[i].identifier()) return -1;
|
90
|
+
if(a.modules[i].identifier() < b.modules[i].identifier()) return 1;
|
91
|
+
}
|
92
|
+
return 0;
|
93
|
+
});
|
94
|
+
});
|
95
|
+
});
|
96
|
+
};
|