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
package/bin/config-yargs.js
CHANGED
@@ -190,11 +190,6 @@ module.exports = function(yargs) {
|
|
190
190
|
group: BASIC_GROUP,
|
191
191
|
requiresArg: true
|
192
192
|
},
|
193
|
-
"progress": {
|
194
|
-
type: "boolean",
|
195
|
-
describe: "Print compilation progress in percentage",
|
196
|
-
group: BASIC_GROUP
|
197
|
-
},
|
198
193
|
"resolve-alias": {
|
199
194
|
type: "string",
|
200
195
|
describe: "Setup a module alias for resolving (Example: jquery-plugin=jquery.plugin)",
|
package/bin/webpack.js
CHANGED
@@ -21,6 +21,7 @@ var yargs = require("yargs")
|
|
21
21
|
require("./config-yargs")(yargs);
|
22
22
|
|
23
23
|
var DISPLAY_GROUP = "Stats options:";
|
24
|
+
var BASIC_GROUP = "Basic options:";
|
24
25
|
|
25
26
|
yargs.options({
|
26
27
|
"json": {
|
@@ -28,6 +29,11 @@ yargs.options({
|
|
28
29
|
alias: "j",
|
29
30
|
describe: "Prints the result as JSON."
|
30
31
|
},
|
32
|
+
"progress": {
|
33
|
+
type: "boolean",
|
34
|
+
describe: "Print compilation progress in percentage",
|
35
|
+
group: BASIC_GROUP
|
36
|
+
},
|
31
37
|
"color": {
|
32
38
|
type: "boolean",
|
33
39
|
alias: "colors",
|
package/lib/AbstractPlugin.js
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function AbstractPlugin(plugins) {
|
6
|
-
this._plugins = plugins || {};
|
7
|
-
}
|
8
|
-
module.exports = AbstractPlugin;
|
9
|
-
|
10
|
-
AbstractPlugin.create = function(plugins) {
|
11
|
-
function Plugin() {
|
12
|
-
AbstractPlugin.call(this, plugins);
|
13
|
-
}
|
14
|
-
Plugin.prototype = Object.create(AbstractPlugin.prototype);
|
15
|
-
return Plugin;
|
16
|
-
};
|
17
|
-
|
18
|
-
AbstractPlugin.prototype.apply = function(object) {
|
19
|
-
for(var name in this._plugins) {
|
20
|
-
object.plugin(name, this._plugins[name]);
|
21
|
-
}
|
22
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function AbstractPlugin(plugins) {
|
6
|
+
this._plugins = plugins || {};
|
7
|
+
}
|
8
|
+
module.exports = AbstractPlugin;
|
9
|
+
|
10
|
+
AbstractPlugin.create = function(plugins) {
|
11
|
+
function Plugin() {
|
12
|
+
AbstractPlugin.call(this, plugins);
|
13
|
+
}
|
14
|
+
Plugin.prototype = Object.create(AbstractPlugin.prototype);
|
15
|
+
return Plugin;
|
16
|
+
};
|
17
|
+
|
18
|
+
AbstractPlugin.prototype.apply = function(object) {
|
19
|
+
for(var name in this._plugins) {
|
20
|
+
object.plugin(name, this._plugins[name]);
|
21
|
+
}
|
22
|
+
};
|
package/lib/ArrayMap.js
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function ArrayMap() {
|
6
|
-
this.keys = [];
|
7
|
-
this.values = [];
|
8
|
-
}
|
9
|
-
module.exports = ArrayMap;
|
10
|
-
|
11
|
-
ArrayMap.prototype.get = function(key) {
|
12
|
-
for(var i = 0; i < this.keys.length; i++) {
|
13
|
-
if(this.keys[i] === key) {
|
14
|
-
return this.values[i];
|
15
|
-
}
|
16
|
-
}
|
17
|
-
return;
|
18
|
-
};
|
19
|
-
|
20
|
-
ArrayMap.prototype.set = function(key, value) {
|
21
|
-
for(var i = 0; i < this.keys.length; i++) {
|
22
|
-
if(this.keys[i] === key) {
|
23
|
-
this.values[i] = value;
|
24
|
-
return this;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
this.keys.push(key);
|
28
|
-
this.values.push(value);
|
29
|
-
return this;
|
30
|
-
};
|
31
|
-
|
32
|
-
ArrayMap.prototype.remove = function(key) {
|
33
|
-
for(var i = 0; i < this.keys.length; i++) {
|
34
|
-
if(this.keys[i] === key) {
|
35
|
-
this.keys.splice(i, 1);
|
36
|
-
this.values.splice(i, 1);
|
37
|
-
return true;
|
38
|
-
}
|
39
|
-
}
|
40
|
-
return false;
|
41
|
-
};
|
42
|
-
|
43
|
-
ArrayMap.prototype.clone = function() {
|
44
|
-
var newMap = new ArrayMap();
|
45
|
-
for(var i = 0; i < this.keys.length; i++) {
|
46
|
-
newMap.keys.push(this.keys[i]);
|
47
|
-
newMap.values.push(this.values[i]);
|
48
|
-
}
|
49
|
-
return newMap;
|
50
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function ArrayMap() {
|
6
|
+
this.keys = [];
|
7
|
+
this.values = [];
|
8
|
+
}
|
9
|
+
module.exports = ArrayMap;
|
10
|
+
|
11
|
+
ArrayMap.prototype.get = function(key) {
|
12
|
+
for(var i = 0; i < this.keys.length; i++) {
|
13
|
+
if(this.keys[i] === key) {
|
14
|
+
return this.values[i];
|
15
|
+
}
|
16
|
+
}
|
17
|
+
return;
|
18
|
+
};
|
19
|
+
|
20
|
+
ArrayMap.prototype.set = function(key, value) {
|
21
|
+
for(var i = 0; i < this.keys.length; i++) {
|
22
|
+
if(this.keys[i] === key) {
|
23
|
+
this.values[i] = value;
|
24
|
+
return this;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
this.keys.push(key);
|
28
|
+
this.values.push(value);
|
29
|
+
return this;
|
30
|
+
};
|
31
|
+
|
32
|
+
ArrayMap.prototype.remove = function(key) {
|
33
|
+
for(var i = 0; i < this.keys.length; i++) {
|
34
|
+
if(this.keys[i] === key) {
|
35
|
+
this.keys.splice(i, 1);
|
36
|
+
this.values.splice(i, 1);
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return false;
|
41
|
+
};
|
42
|
+
|
43
|
+
ArrayMap.prototype.clone = function() {
|
44
|
+
var newMap = new ArrayMap();
|
45
|
+
for(var i = 0; i < this.keys.length; i++) {
|
46
|
+
newMap.keys.push(this.keys[i]);
|
47
|
+
newMap.values.push(this.values[i]);
|
48
|
+
}
|
49
|
+
return newMap;
|
50
|
+
};
|
@@ -1,51 +1,51 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var DelegatedModule = require("./DelegatedModule");
|
6
|
-
|
7
|
-
// options.source
|
8
|
-
// options.type
|
9
|
-
// options.context
|
10
|
-
// options.scope
|
11
|
-
// options.content
|
12
|
-
function DelegatedModuleFactoryPlugin(options) {
|
13
|
-
this.options = options;
|
14
|
-
options.type = options.type || "require";
|
15
|
-
options.extensions = options.extensions || ["", ".js"];
|
16
|
-
}
|
17
|
-
module.exports = DelegatedModuleFactoryPlugin;
|
18
|
-
|
19
|
-
DelegatedModuleFactoryPlugin.prototype.apply = function(normalModuleFactory) {
|
20
|
-
var scope = this.options.scope;
|
21
|
-
if(scope) {
|
22
|
-
normalModuleFactory.plugin("factory", function(factory) {
|
23
|
-
return function(data, callback) {
|
24
|
-
var dependency = data.dependencies[0];
|
25
|
-
var request = dependency.request;
|
26
|
-
if(request && request.indexOf(scope + "/") === 0) {
|
27
|
-
var innerRequest = "." + request.substr(scope.length);
|
28
|
-
for(var i = 0; i < this.options.extensions.length; i++) {
|
29
|
-
var requestPlusExt = innerRequest + this.options.extensions[i];
|
30
|
-
if(requestPlusExt in this.options.content) {
|
31
|
-
var resolved = this.options.content[requestPlusExt];
|
32
|
-
return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, requestPlusExt));
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
return factory(data, callback);
|
37
|
-
}.bind(this);
|
38
|
-
}.bind(this));
|
39
|
-
} else {
|
40
|
-
normalModuleFactory.plugin("module", function(module) {
|
41
|
-
if(module.libIdent) {
|
42
|
-
var request = module.libIdent(this.options);
|
43
|
-
if(request && request in this.options.content) {
|
44
|
-
var resolved = this.options.content[request];
|
45
|
-
return new DelegatedModule(this.options.source, resolved, this.options.type, request);
|
46
|
-
}
|
47
|
-
}
|
48
|
-
return module;
|
49
|
-
}.bind(this));
|
50
|
-
}
|
51
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var DelegatedModule = require("./DelegatedModule");
|
6
|
+
|
7
|
+
// options.source
|
8
|
+
// options.type
|
9
|
+
// options.context
|
10
|
+
// options.scope
|
11
|
+
// options.content
|
12
|
+
function DelegatedModuleFactoryPlugin(options) {
|
13
|
+
this.options = options;
|
14
|
+
options.type = options.type || "require";
|
15
|
+
options.extensions = options.extensions || ["", ".js"];
|
16
|
+
}
|
17
|
+
module.exports = DelegatedModuleFactoryPlugin;
|
18
|
+
|
19
|
+
DelegatedModuleFactoryPlugin.prototype.apply = function(normalModuleFactory) {
|
20
|
+
var scope = this.options.scope;
|
21
|
+
if(scope) {
|
22
|
+
normalModuleFactory.plugin("factory", function(factory) {
|
23
|
+
return function(data, callback) {
|
24
|
+
var dependency = data.dependencies[0];
|
25
|
+
var request = dependency.request;
|
26
|
+
if(request && request.indexOf(scope + "/") === 0) {
|
27
|
+
var innerRequest = "." + request.substr(scope.length);
|
28
|
+
for(var i = 0; i < this.options.extensions.length; i++) {
|
29
|
+
var requestPlusExt = innerRequest + this.options.extensions[i];
|
30
|
+
if(requestPlusExt in this.options.content) {
|
31
|
+
var resolved = this.options.content[requestPlusExt];
|
32
|
+
return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, requestPlusExt));
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return factory(data, callback);
|
37
|
+
}.bind(this);
|
38
|
+
}.bind(this));
|
39
|
+
} else {
|
40
|
+
normalModuleFactory.plugin("module", function(module) {
|
41
|
+
if(module.libIdent) {
|
42
|
+
var request = module.libIdent(this.options);
|
43
|
+
if(request && request in this.options.content) {
|
44
|
+
var resolved = this.options.content[request];
|
45
|
+
return new DelegatedModule(this.options.source, resolved, this.options.type, request);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
return module;
|
49
|
+
}.bind(this));
|
50
|
+
}
|
51
|
+
};
|
package/lib/EntryOptionPlugin.js
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var SingleEntryPlugin = require("./SingleEntryPlugin");
|
6
|
-
var MultiEntryPlugin = require("./MultiEntryPlugin");
|
7
|
-
|
8
|
-
function EntryOptionPlugin() {}
|
9
|
-
module.exports = EntryOptionPlugin;
|
10
|
-
|
11
|
-
EntryOptionPlugin.prototype.apply = function(compiler) {
|
12
|
-
compiler.plugin("entry-option", function(context, entry) {
|
13
|
-
function itemToPlugin(item, name) {
|
14
|
-
if(Array.isArray(item))
|
15
|
-
return new MultiEntryPlugin(context, item, name);
|
16
|
-
else
|
17
|
-
return new SingleEntryPlugin(context, item, name);
|
18
|
-
}
|
19
|
-
if(typeof entry === "string" || Array.isArray(entry)) {
|
20
|
-
compiler.apply(itemToPlugin(entry, "main"));
|
21
|
-
} else if(typeof entry === "object") {
|
22
|
-
Object.keys(entry).forEach(function(name) {
|
23
|
-
compiler.apply(itemToPlugin(entry[name], name));
|
24
|
-
});
|
25
|
-
}
|
26
|
-
return true;
|
27
|
-
});
|
28
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var SingleEntryPlugin = require("./SingleEntryPlugin");
|
6
|
+
var MultiEntryPlugin = require("./MultiEntryPlugin");
|
7
|
+
|
8
|
+
function EntryOptionPlugin() {}
|
9
|
+
module.exports = EntryOptionPlugin;
|
10
|
+
|
11
|
+
EntryOptionPlugin.prototype.apply = function(compiler) {
|
12
|
+
compiler.plugin("entry-option", function(context, entry) {
|
13
|
+
function itemToPlugin(item, name) {
|
14
|
+
if(Array.isArray(item))
|
15
|
+
return new MultiEntryPlugin(context, item, name);
|
16
|
+
else
|
17
|
+
return new SingleEntryPlugin(context, item, name);
|
18
|
+
}
|
19
|
+
if(typeof entry === "string" || Array.isArray(entry)) {
|
20
|
+
compiler.apply(itemToPlugin(entry, "main"));
|
21
|
+
} else if(typeof entry === "object") {
|
22
|
+
Object.keys(entry).forEach(function(name) {
|
23
|
+
compiler.apply(itemToPlugin(entry[name], name));
|
24
|
+
});
|
25
|
+
}
|
26
|
+
return true;
|
27
|
+
});
|
28
|
+
};
|
@@ -1,21 +1,21 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var ModuleParserHelpers = exports;
|
6
|
-
|
7
|
-
ModuleParserHelpers.addParsedVariable = function(parser, name, expression) {
|
8
|
-
if(!parser.state.current.addVariable) return false;
|
9
|
-
var deps = [];
|
10
|
-
parser.parse(expression, {
|
11
|
-
current: {
|
12
|
-
addDependency: function(dep) {
|
13
|
-
dep.userRequest = name;
|
14
|
-
deps.push(dep);
|
15
|
-
}
|
16
|
-
},
|
17
|
-
module: parser.state.module
|
18
|
-
});
|
19
|
-
parser.state.current.addVariable(name, expression, deps);
|
20
|
-
return true;
|
21
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var ModuleParserHelpers = exports;
|
6
|
+
|
7
|
+
ModuleParserHelpers.addParsedVariable = function(parser, name, expression) {
|
8
|
+
if(!parser.state.current.addVariable) return false;
|
9
|
+
var deps = [];
|
10
|
+
parser.parse(expression, {
|
11
|
+
current: {
|
12
|
+
addDependency: function(dep) {
|
13
|
+
dep.userRequest = name;
|
14
|
+
deps.push(dep);
|
15
|
+
}
|
16
|
+
},
|
17
|
+
module: parser.state.module
|
18
|
+
});
|
19
|
+
parser.state.current.addVariable(name, expression, deps);
|
20
|
+
return true;
|
21
|
+
};
|
@@ -1,21 +1,21 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function NamedModulesPlugin(options) {
|
6
|
-
this.options = options || {};
|
7
|
-
}
|
8
|
-
module.exports = NamedModulesPlugin;
|
9
|
-
NamedModulesPlugin.prototype.apply = function(compiler) {
|
10
|
-
compiler.plugin("compilation", function(compilation) {
|
11
|
-
compilation.plugin("before-module-ids", function(modules) {
|
12
|
-
modules.forEach(function(module) {
|
13
|
-
if(module.id === null && module.libIdent) {
|
14
|
-
module.id = module.libIdent({
|
15
|
-
context: this.options.context || compiler.options.context
|
16
|
-
});
|
17
|
-
}
|
18
|
-
}, this);
|
19
|
-
}.bind(this));
|
20
|
-
}.bind(this));
|
21
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function NamedModulesPlugin(options) {
|
6
|
+
this.options = options || {};
|
7
|
+
}
|
8
|
+
module.exports = NamedModulesPlugin;
|
9
|
+
NamedModulesPlugin.prototype.apply = function(compiler) {
|
10
|
+
compiler.plugin("compilation", function(compilation) {
|
11
|
+
compilation.plugin("before-module-ids", function(modules) {
|
12
|
+
modules.forEach(function(module) {
|
13
|
+
if(module.id === null && module.libIdent) {
|
14
|
+
module.id = module.libIdent({
|
15
|
+
context: this.options.context || compiler.options.context
|
16
|
+
});
|
17
|
+
}
|
18
|
+
}, this);
|
19
|
+
}.bind(this));
|
20
|
+
}.bind(this));
|
21
|
+
};
|