Skip to content

Commit b3a7c4d

Browse files
committed
Merge branch 'master' of git://github.com/webpack/webpack into ContextExclusionPlugin-types
2 parents d3bbb6d + fa02f3d commit b3a7c4d

File tree

19 files changed

+1435
-1457
lines changed

19 files changed

+1435
-1457
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ within webpack itself use this plugin interface. This makes webpack very
9292

9393
|Name|Status|Install Size|Description|
9494
|:--:|:----:|:----------:|:----------|
95-
|[extract-text-webpack-plugin][extract]|![extract-npm]|![extract-size]|Extracts Text (CSS) from your bundles into a separate file (app.bundle.css)|
95+
|[mini-css-extract-plugin][mini-css]|![mini-css-npm]|![mini-css-size]|Extracts CSS into separate files. It creates a CSS file per JS file which contains CSS.|
9696
|[compression-webpack-plugin][compression]|![compression-npm]|![compression-size]|Prepares compressed versions of assets to serve them with Content-Encoding|
9797
|[i18n-webpack-plugin][i18n]|![i18n-npm]|![i18n-size]|Adds i18n support to your bundles|
9898
|[html-webpack-plugin][html-plugin]|![html-plugin-npm]|![html-plugin-size]| Simplifies creation of HTML files (`index.html`) to serve your bundles|
99-
99+
|[extract-text-webpack-plugin][extract]|![extract-npm]|![extract-size]|Extract text from a bundle, or bundles, into a separate file|
100100

101101
[common-npm]: https://img.shields.io/npm/v/webpack.svg
102102
[extract]: https://github.com/webpack/extract-text-webpack-plugin
103103
[extract-npm]: https://img.shields.io/npm/v/extract-text-webpack-plugin.svg
104104
[extract-size]: https://packagephobia.now.sh/badge?p=extract-text-webpack-plugin
105+
[mini-css]: https://github.com/webpack-contrib/mini-css-extract-plugin
106+
[mini-css-npm]: https://img.shields.io/npm/v/mini-css-extract-plugin.svg
107+
[mini-css-size]: https://packagephobia.now.sh/badge?p=mini-css-extract-plugin
105108
[component]: https://github.com/webpack/component-webpack-plugin
106109
[component-npm]: https://img.shields.io/npm/v/component-webpack-plugin.svg
107110
[component-size]: https://packagephobia.now.sh/badge?p=component-webpack-plugin

lib/Compilation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ class Compilation extends Tapable {
888888
// leaking the Compilation object.
889889

890890
if (err) {
891+
// eslint-disable-next-line no-self-assign
891892
err.stack = err.stack;
892893
return callback(err);
893894
}

lib/DefinePlugin.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
99
const ParserHelpers = require("./ParserHelpers");
1010
const NullFactory = require("./NullFactory");
1111

12+
/** @typedef {import("./Compiler")} Compiler */
13+
/** @typedef {import("./Parser")} Parser */
14+
/** @typedef {null|undefined|RegExp|Function|string|number} CodeValuePrimitive */
15+
/** @typedef {CodeValuePrimitive|Record<string, CodeValuePrimitive>|RuntimeValue} CodeValue */
16+
1217
class RuntimeValue {
1318
constructor(fn, fileDependencies) {
1419
this.fn = fn;
@@ -37,6 +42,12 @@ const stringifyObj = (obj, parser) => {
3742
);
3843
};
3944

45+
/**
46+
* Convert code to a string that evaluates
47+
* @param {CodeValue} code Code to evaluate
48+
* @param {Parser} parser Parser
49+
* @returns {string} code converted to string that evaluates
50+
*/
4051
const toCode = (code, parser) => {
4152
if (code === null) {
4253
return "null";
@@ -60,6 +71,10 @@ const toCode = (code, parser) => {
6071
};
6172

6273
class DefinePlugin {
74+
/**
75+
* Create a new define plugin
76+
* @param {Record<string, CodeValue>} definitions A map of global object definitions
77+
*/
6378
constructor(definitions) {
6479
this.definitions = definitions;
6580
}
@@ -68,6 +83,11 @@ class DefinePlugin {
6883
return new RuntimeValue(fn, fileDependencies);
6984
}
7085

86+
/**
87+
* Apply the plugin
88+
* @param {Compiler} compiler Webpack compiler
89+
* @returns {void}
90+
*/
7191
apply(compiler) {
7292
const definitions = this.definitions;
7393
compiler.hooks.compilation.tap(
@@ -79,7 +99,18 @@ class DefinePlugin {
7999
new ConstDependency.Template()
80100
);
81101

102+
/**
103+
* Handler
104+
* @param {Parser} parser Parser
105+
* @returns {void}
106+
*/
82107
const handler = parser => {
108+
/**
109+
* Walk definitions
110+
* @param {Object} definitions Definitions map
111+
* @param {string} prefix Prefix string
112+
* @returns {void}
113+
*/
83114
const walkDefinitions = (definitions, prefix) => {
84115
Object.keys(definitions).forEach(key => {
85116
const code = definitions[key];
@@ -98,6 +129,12 @@ class DefinePlugin {
98129
});
99130
};
100131

132+
/**
133+
* Apply define key
134+
* @param {string} prefix Prefix
135+
* @param {string} key Key
136+
* @returns {void}
137+
*/
101138
const applyDefineKey = (prefix, key) => {
102139
const splittedKey = key.split(".");
103140
splittedKey.slice(1).forEach((_, i) => {
@@ -108,6 +145,12 @@ class DefinePlugin {
108145
});
109146
};
110147

148+
/**
149+
* Apply Code
150+
* @param {string} key Key
151+
* @param {CodeValue} code Code
152+
* @returns {void}
153+
*/
111154
const applyDefine = (key, code) => {
112155
const isTypeof = /^typeof\s+/.test(key);
113156
if (isTypeof) key = key.replace(/^typeof\s+/, "");
@@ -181,6 +224,12 @@ class DefinePlugin {
181224
});
182225
};
183226

227+
/**
228+
* Apply Object
229+
* @param {string} key Key
230+
* @param {Object} obj Object
231+
* @returns {void}
232+
*/
184233
const applyObjectDefine = (key, obj) => {
185234
parser.hooks.canRename
186235
.for(key)

lib/optimize/OccurrenceChunkOrderPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class OccurrenceOrderChunkIdsPlugin {
4949
if (aOccurs < bOccurs) return 1;
5050
const orgA = originalOrder.get(a);
5151
const orgB = originalOrder.get(b);
52-
return orgB - orgA;
52+
return orgA - orgB;
5353
});
5454
}
5555
);

lib/optimize/OccurrenceModuleOrderPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class OccurrenceOrderModuleIdsPlugin {
9191
if (aOccurs < bOccurs) return 1;
9292
const orgA = originalOrder.get(a);
9393
const orgB = originalOrder.get(b);
94-
return orgB - orgA;
94+
return orgA - orgB;
9595
});
9696
}
9797
);

lib/optimize/OccurrenceOrderPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class OccurrenceOrderPlugin {
9191
if (aOccurs < bOccurs) return 1;
9292
const orgA = originalOrder.get(a);
9393
const orgB = originalOrder.get(b);
94-
return orgB - orgA;
94+
return orgA - orgB;
9595
});
9696
}
9797
);
@@ -124,7 +124,7 @@ class OccurrenceOrderPlugin {
124124
if (aOccurs < bOccurs) return 1;
125125
const orgA = originalOrder.get(a);
126126
const orgB = originalOrder.get(b);
127-
return orgB - orgA;
127+
return orgA - orgB;
128128
});
129129
}
130130
);

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "4.16.0",
3+
"version": "4.16.1",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
66
"license": "MIT",
@@ -16,7 +16,7 @@
1616
"ajv-keywords": "^3.1.0",
1717
"chrome-trace-event": "^1.0.0",
1818
"enhanced-resolve": "^4.1.0",
19-
"eslint-scope": "^3.7.1",
19+
"eslint-scope": "^4.0.0",
2020
"json-parse-better-errors": "^1.0.2",
2121
"loader-runner": "^2.3.0",
2222
"loader-utils": "^1.1.0",
@@ -43,11 +43,11 @@
4343
"coveralls": "^2.11.2",
4444
"css-loader": "^0.28.3",
4545
"es6-promise-polyfill": "^1.1.1",
46-
"eslint": "^4.19.1",
46+
"eslint": "^5.1.0",
4747
"eslint-config-prettier": "^2.9.0",
4848
"eslint-plugin-jest": "^21.17.0",
4949
"eslint-plugin-node": "^6.0.1",
50-
"eslint-plugin-prettier": "^2.6.0",
50+
"eslint-plugin-prettier": "^2.6.2",
5151
"express": "~4.13.1",
5252
"file-loader": "^1.1.6",
5353
"glob": "^7.1.2",
@@ -61,9 +61,9 @@
6161
"json-loader": "^0.5.7",
6262
"less": "^2.5.1",
6363
"less-loader": "^4.0.3",
64-
"lint-staged": "^7.1.0",
64+
"lint-staged": "^7.2.0",
6565
"lodash": "^4.17.4",
66-
"prettier": "^1.13.5",
66+
"prettier": "^1.13.7",
6767
"pug": "^2.0.3",
6868
"pug-loader": "^2.4.0",
6969
"raw-loader": "~0.5.0",
@@ -73,7 +73,7 @@
7373
"script-loader": "~0.7.0",
7474
"simple-git": "^1.65.0",
7575
"style-loader": "^0.19.1",
76-
"typescript": "^2.9.1",
76+
"typescript": "^3.0.0-rc",
7777
"url-loader": "^0.6.2",
7878
"val-loader": "^1.0.2",
7979
"vm-browserify": "~0.0.0",

schemas/WebpackOptions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@
15921592
"type": "boolean"
15931593
},
15941594
"moduleIds": {
1595-
"description": "Define the algorithm to choose module ids (natural: numeric ids in order for usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)",
1595+
"description": "Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)",
15961596
"enum": [
15971597
"natural",
15981598
"named",

test/Compiler.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe("Compiler", () => {
8585
expect(Object.keys(files)).toEqual(["/main.js"]);
8686
const bundle = files["/main.js"];
8787
expect(bundle).toMatch("function __webpack_require__(");
88-
expect(bundle).toMatch("__webpack_require__(/*! ./a */ 0);");
88+
expect(bundle).toMatch(/__webpack_require__\(\/\*! \.\/a \*\/ \d\);/);
8989
expect(bundle).toMatch("./c.js");
9090
expect(bundle).toMatch("./a.js");
9191
expect(bundle).toMatch("This is a");
@@ -145,9 +145,9 @@ describe("Compiler", () => {
145145
it("should compile a file with multiple chunks", done => {
146146
compile("./chunks", {}, (stats, files) => {
147147
expect(stats.chunks).toHaveLength(2);
148-
expect(Object.keys(files)).toEqual(["/0.js", "/main.js"]);
148+
expect(Object.keys(files)).toEqual(["/main.js", "/1.js"]);
149149
const bundle = files["/main.js"];
150-
const chunk = files["/0.js"];
150+
const chunk = files["/1.js"];
151151
expect(bundle).toMatch("function __webpack_require__(");
152152
expect(bundle).toMatch("__webpack_require__(/*! ./b */");
153153
expect(chunk).not.toMatch("__webpack_require__(/* ./b */");

test/HotModuleReplacementPlugin.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ describe("HotModuleReplacementPlugin", () => {
5050
output: {
5151
path: path.join(__dirname, "js", "HotModuleReplacementPlugin")
5252
},
53-
plugins: [
54-
new webpack.HotModuleReplacementPlugin(),
55-
new webpack.optimize.OccurrenceOrderPlugin()
56-
]
53+
plugins: [new webpack.HotModuleReplacementPlugin()],
54+
optimization: {
55+
moduleIds: "size",
56+
chunkIds: "size"
57+
}
5758
});
5859
fs.writeFileSync(entryFile, "1", "utf-8");
5960
compiler.run((err, stats) => {

0 commit comments

Comments
 (0)