Skip to content

Commit 0476eb4

Browse files
author
Sven SAULEAU
authored
Merge branch 'master' into feat-rewrite-wasm
2 parents 7dbce96 + 0f70fcb commit 0476eb4

File tree

118 files changed

+1656
-824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1656
-824
lines changed

.editorconfig

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,11 @@ trim_trailing_whitespace = true
88
insert_final_newline = true
99
max_line_length = 233
1010

11-
[*.json]
12-
indent_style = space
13-
indent_size = 2
14-
1511
[.prettierrc]
1612
indent_style = space
1713
indent_size = 2
1814

19-
[*.yml]
20-
indent_style = space
21-
indent_size = 2
22-
23-
[*.yaml]
15+
[*.{yml,yaml,json}]
2416
indent_style = space
2517
indent_size = 2
2618

.eslintrc.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module.exports = {
2-
"root": true,
3-
"plugins": [
4-
"prettier",
5-
"node"
6-
],
7-
"extends": ["eslint:recommended", "plugin:node/recommended"],
8-
"env": {
9-
"node": true,
10-
"es6": true,
2+
root: true,
3+
plugins: ["prettier", "node"],
4+
extends: ["eslint:recommended", "plugin:node/recommended"],
5+
env: {
6+
node: true,
7+
es6: true
118
},
12-
"parserOptions": { "ecmaVersion": 2017 },
13-
"rules": {
9+
parserOptions: {
10+
ecmaVersion: 2017
11+
},
12+
rules: {
1413
"prettier/prettier": "error",
1514
"no-undef": "error",
1615
"no-extra-semi": "error",
@@ -25,7 +24,7 @@ module.exports = {
2524
"no-extra-bind": "warn",
2625
"no-process-exit": "warn",
2726
"no-use-before-define": "off",
28-
"no-unused-vars": ["error", { "args": "none" }],
27+
"no-unused-vars": ["error", { args: "none" }],
2928
"no-unsafe-negation": "error",
3029
"no-loop-func": "warn",
3130
"indent": "off",
@@ -34,16 +33,23 @@ module.exports = {
3433
"node/no-unsupported-features": "error",
3534
"node/no-deprecated-api": "error",
3635
"node/no-missing-import": "error",
37-
"node/no-missing-require": [
38-
"error",
39-
{
40-
"allowModules": [
41-
"webpack"
42-
]
43-
}
44-
],
36+
"node/no-missing-require": ["error", { allowModules: ["webpack"] }],
4537
"node/no-unpublished-bin": "error",
4638
"node/no-unpublished-require": "error",
4739
"node/process-exit-as-throw": "error"
48-
}
40+
},
41+
overrides: [
42+
{
43+
files: ["lib/**/*.runtime.js", "buildin/*.js", "hot/*.js"],
44+
env: {
45+
es6: false
46+
},
47+
globals: {
48+
Promise: false,
49+
},
50+
parserOptions: {
51+
ecmaVersion: 5
52+
}
53+
}
54+
]
4955
};

.jsbeautifyrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,7 @@ documentation pages:
2525

2626
## Setup
2727

28-
```bash
29-
git clone https://github.com/webpack/webpack.git
30-
cd webpack
31-
npm install -g yarn
32-
yarn install
33-
yarn link
34-
yarn link webpack
35-
```
36-
37-
To run the entire test suite use:
38-
39-
```bash
40-
yarn test
41-
```
28+
[Setup your local webpack repository](_SETUP.md)
4229

4330
## Submitting Changes
4431

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ yarn add webpack --dev
5252

5353
<h2 align="center">Introduction</h2>
5454

55-
> This README reflects Webpack v2.x and v3.x. The Webpack v1.x documentation has been deprecated and deleted.
55+
> This README reflects webpack v2.x and v3.x. The webpack v1.x documentation has been deprecated and deleted.
5656
5757
webpack is a bundler for modules. The main purpose is to bundle JavaScript
5858
files for usage in a browser, yet it is also capable of transforming, bundling,

_SETUP.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Setup
2+
3+
Setup your local webpack repository
4+
5+
```bash
6+
git clone https://github.com/webpack/webpack.git
7+
cd webpack
8+
npm install -g yarn
9+
yarn install
10+
yarn link
11+
yarn link webpack
12+
```
13+
14+
To run the entire test suite use:
15+
16+
```bash
17+
yarn test
18+
```

bin/webpack.js

100644100755
Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,82 @@
11
#!/usr/bin/env node
2+
function runCommand(command, options) {
3+
const cp = require("child_process");
4+
return new Promise((resolve, reject) => {
5+
const executedCommand = cp.spawn(command, options, {
6+
stdio: "inherit"
7+
});
8+
9+
executedCommand.on("error", error => {
10+
reject(error);
11+
});
12+
13+
executedCommand.on("exit", code => {
14+
if (code === 0) {
15+
resolve(true);
16+
} else {
17+
reject();
18+
}
19+
});
20+
});
21+
}
222

323
let webpackCliInstalled = false;
424
try {
525
require.resolve("webpack-cli");
626
webpackCliInstalled = true;
7-
} catch (e) {
27+
} catch (err) {
828
webpackCliInstalled = false;
929
}
1030

11-
if (webpackCliInstalled) {
12-
require("webpack-cli"); // eslint-disable-line node/no-missing-require, node/no-extraneous-require, node/no-unpublished-require
31+
if (!webpackCliInstalled) {
32+
const path = require("path");
33+
const fs = require("fs");
34+
const readLine = require("readline");
35+
const isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
36+
37+
const packageManager = isYarn ? "yarn" : "npm";
38+
const options = ["install", "-D", "webpack-cli"];
39+
40+
if (isYarn) {
41+
options[0] = "add";
42+
}
43+
44+
const commandToBeRun = `${packageManager} ${options.join(" ")}`;
45+
46+
const question = `Would you like to install webpack-cli? (That will run ${
47+
commandToBeRun
48+
}) `;
49+
50+
console.error("The CLI moved into a separate package: webpack-cli");
51+
const questionInterface = readLine.createInterface({
52+
input: process.stdin,
53+
output: process.stdout
54+
});
55+
questionInterface.question(question, answer => {
56+
questionInterface.close();
57+
switch (answer.toLowerCase()) {
58+
case "y":
59+
case "yes":
60+
case "1": {
61+
runCommand(packageManager, options)
62+
.then(result => {
63+
return require("webpack-cli"); //eslint-disable-line
64+
})
65+
.catch(error => {
66+
console.error(error);
67+
process.exitCode = 1;
68+
});
69+
break;
70+
}
71+
default: {
72+
console.error(
73+
"It needs to be installed alongside webpack to use the CLI"
74+
);
75+
process.exitCode = 1;
76+
break;
77+
}
78+
}
79+
});
1380
} else {
14-
console.error("The CLI moved into a separate package: webpack-cli.");
15-
console.error(
16-
"Please install 'webpack-cli' in addition to webpack itself to use the CLI."
17-
);
18-
console.error("-> When using npm: npm install webpack-cli -D");
19-
console.error("-> When using yarn: yarn add webpack-cli -D");
20-
process.exitCode = 1;
81+
require("webpack-cli"); // eslint-disable-line
2182
}

lib/AmdMainTemplatePlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
"use strict";
77

8-
const ConcatSource = require("webpack-sources").ConcatSource;
8+
const { ConcatSource } = require("webpack-sources");
99
const Template = require("./Template");
1010

1111
class AmdMainTemplatePlugin {

lib/BannerPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
"use strict";
77

8-
const ConcatSource = require("webpack-sources").ConcatSource;
8+
const { ConcatSource } = require("webpack-sources");
99
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
1010
const Template = require("./Template");
1111

lib/Chunk.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Chunk {
5555
this.files = [];
5656
this.rendered = false;
5757
this.hash = undefined;
58+
this.contentHash = Object.create(null);
5859
this.renderedHash = undefined;
5960
this.chunkReason = undefined;
6061
this.extraAsync = false;
@@ -340,15 +341,22 @@ class Chunk {
340341

341342
getChunkMaps(realHash) {
342343
const chunkHashMap = Object.create(null);
344+
const chunkContentHashMap = Object.create(null);
343345
const chunkNameMap = Object.create(null);
344346

345347
for (const chunk of this.getAllAsyncChunks()) {
346348
chunkHashMap[chunk.id] = realHash ? chunk.hash : chunk.renderedHash;
349+
for (const key of Object.keys(chunk.contentHash)) {
350+
if (!chunkContentHashMap[key])
351+
chunkContentHashMap[key] = Object.create(null);
352+
chunkContentHashMap[key][chunk.id] = chunk.contentHash[key];
353+
}
347354
if (chunk.name) chunkNameMap[chunk.id] = chunk.name;
348355
}
349356

350357
return {
351358
hash: chunkHashMap,
359+
contentHash: chunkContentHashMap,
352360
name: chunkNameMap
353361
};
354362
}

0 commit comments

Comments
 (0)