Merge tag 'v4.24.0' into next

4.24.0
This commit is contained in:
Tobias Koppers 2018-11-02 18:02:39 +01:00
commit 31e189fcde
16 changed files with 501 additions and 383 deletions

View File

@ -21,23 +21,19 @@ matrix:
include:
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=basic
env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=basic
stage: basic
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=lint-unit
env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=lint-unit
stage: advanced
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
env: NO_WATCH_TESTS=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
stage: advanced
- os: linux
node_js: "10"
env:
NO_WATCH_TESTS=1 ALTERNATIVE_SORT=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
env: NO_WATCH_TESTS=1 ALTERNATIVE_SORT=1 JEST="--maxWorkers=2 --cacheDirectory .jest-cache" JOB_PART=integration
stage: advanced
- os: linux
node_js: "10"
@ -74,5 +70,4 @@ after_success:
notifications:
slack:
secure:
JduSdKWwbnLCwo7Z4E59SGE+Uw832UwnXzQiKEpg1BV45MYDPRiGltly1tRHmPh9OGjvGx3XSkC2tNGOBLtL4UL2SCkf012x0t7jDutKRfcv/njynl8jk8l+UhPmaWiHXDQAgGiiKdL4RfzPLW3HeVHCOWm0LKMzcarTa8tw+rE=
secure: JduSdKWwbnLCwo7Z4E59SGE+Uw832UwnXzQiKEpg1BV45MYDPRiGltly1tRHmPh9OGjvGx3XSkC2tNGOBLtL4UL2SCkf012x0t7jDutKRfcv/njynl8jk8l+UhPmaWiHXDQAgGiiKdL4RfzPLW3HeVHCOWm0LKMzcarTa8tw+rE=

View File

@ -32,5 +32,4 @@ test_script:
- cmd: yarn istanbul report --report lcovonly
- cmd: yarn unlink webpack
- cmd: yarn global add codecov && codecov -F %job_part% --disable=gcov
- cmd:
del /F /Q .jest-cache\\haste-map* .jest-cache\\perf-cache* 2> null || Ver > null
- cmd: del /F /Q .jest-cache\\haste-map* .jest-cache\\perf-cache* 2> null || Ver > null

View File

@ -1,6 +1,6 @@
# Examples
## Aggressive Merging
[aggressive-merging](aggressive-merging)
[aggressive-merging](aggressive-merging)
## Chunk
[chunkhash](chunkhash)
@ -31,9 +31,9 @@
[code-splitting-bundle-loader](code-splitting-bundle-loader) example demonstrating Code Splitting through the builder loader
[code-splitting-harmony](code-splitting-harmony)
[code-splitting-harmony](code-splitting-harmony)
[code-splitting-native-import-context](code-splitting-native-import-context)
[code-splitting-native-import-context](code-splitting-native-import-context)
[code-splitting-specify-chunk-name](code-splitting-specify-chunk-name)
@ -110,7 +110,7 @@ If you think an example is missing, please report it as issue. :)
# Building an Example
1. Run `yarn` in the root of the project.
2. Run `yarn link webpack` in the root of the project.
2. Run `yarn setup` in the root of the project.
3. Run `yarn add --dev webpack-cli` in the root of the project.
4. Run `node build.js` in the specific example directory. (Ex: `cd examples/commonjs && node build.js`)

View File

@ -27,11 +27,15 @@ class RuntimeValue {
}
exec(parser) {
for (const fileDependency of this.fileDependencies) {
parser.state.module.buildInfo.fileDependencies.add(fileDependency);
if (this.fileDependencies === true) {
parser.state.module.buildInfo.cacheable = false;
} else {
for (const fileDependency of this.fileDependencies) {
parser.state.module.buildInfo.fileDependencies.add(fileDependency);
}
}
return this.fn();
return this.fn({ module: parser.state.module });
}
}

View File

@ -309,10 +309,10 @@ class HotModuleReplacementPlugin {
c: {}
};
for (const key of Object.keys(records.chunkHashs)) {
const chunkId = isNaN(+key) ? key : +key;
const chunkId = key;
const currentChunk = find(
compilation.chunks,
chunk => chunk.id === chunkId
chunk => `${chunk.id}` === key
);
if (currentChunk) {
const newModules = chunkGraph

View File

@ -8,7 +8,7 @@
const ExternalsPlugin = require("../ExternalsPlugin");
const builtins =
// eslint-disable-next-line node/no-unsupported-features/node-builtins
// eslint-disable-next-line node/no-unsupported-features/node-builtins,node/no-deprecated-api
require("module").builtinModules || Object.keys(process.binding("natives"));
class NodeTargetPlugin {

View File

@ -504,8 +504,7 @@ rules:
# Move issue task
- filters:
open: true
comment:
"\\s*@webpack-bot\\s+move\\s+(?:to\\s+)?([a-z0-9_\\-\\.]+/[a-z0-9_\\-\\.]+)\\s*([\\s\\S]*)$"
comment: "\\s*@webpack-bot\\s+move\\s+(?:to\\s+)?([a-z0-9_\\-\\.]+/[a-z0-9_\\-\\.]+)\\s*([\\s\\S]*)$"
not:
comment_1:
matching: "moved\\-by\\-bot"

View File

@ -5,10 +5,10 @@
"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.",
"license": "MIT",
"dependencies": {
"@webassemblyjs/ast": "1.7.10",
"@webassemblyjs/helper-module-context": "1.7.10",
"@webassemblyjs/wasm-edit": "1.7.10",
"@webassemblyjs/wasm-parser": "1.7.10",
"@webassemblyjs/ast": "1.7.11",
"@webassemblyjs/helper-module-context": "1.7.11",
"@webassemblyjs/wasm-edit": "1.7.11",
"@webassemblyjs/wasm-parser": "1.7.11",
"acorn": "^6.0.0",
"acorn-dynamic-import": "^4.0.0",
"ajv": "^6.1.0",
@ -43,23 +43,23 @@
"coveralls": "^3.0.2",
"css-loader": "^0.28.3",
"es6-promise-polyfill": "^1.1.1",
"eslint": "^5.2.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-jest": "^21.18.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-prettier": "^2.6.2",
"eslint": "^5.8.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-jest": "^21.26.2",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"file-loader": "^1.1.6",
"glob": "^7.1.2",
"husky": "^1.0.0-rc.6",
"glob": "^7.1.3",
"husky": "^1.1.3",
"istanbul": "^0.4.5",
"jest": "24.0.0-alpha.1",
"json-loader": "^0.5.7",
"json-schema-to-typescript": "^6.0.1",
"less": "^2.5.1",
"less-loader": "^4.0.3",
"lint-staged": "^7.2.0",
"lint-staged": "^8.0.4",
"lodash": "^4.17.4",
"prettier": "^1.14.0",
"prettier": "^1.14.3",
"pug": "^2.0.3",
"pug-loader": "^2.4.0",
"raw-loader": "~0.5.0",

View File

@ -97,4 +97,78 @@ describe("HotModuleReplacementPlugin", () => {
});
});
});
it("should correct working when entry is Object and key is a number", done => {
const entryFile = path.join(
__dirname,
"js",
"HotModuleReplacementPlugin",
"entry.js"
);
const statsFile3 = path.join(
__dirname,
"js",
"HotModuleReplacementPlugin",
"HotModuleReplacementPlugin.test.stats3.txt"
);
const statsFile4 = path.join(
__dirname,
"js",
"HotModuleReplacementPlugin",
"HotModuleReplacementPlugin.test.stats4.txt"
);
const recordsFile = path.join(
__dirname,
"js",
"HotModuleReplacementPlugin",
"records.json"
);
try {
mkdirp.sync(path.join(__dirname, "js", "HotModuleReplacementPlugin"));
} catch (e) {
// empty
}
try {
fs.unlinkSync(recordsFile);
} catch (e) {
// empty
}
const compiler = webpack({
mode: "development",
cache: false,
entry: {
"0": entryFile
},
recordsPath: recordsFile,
output: {
path: path.join(__dirname, "js", "HotModuleReplacementPlugin")
},
plugins: [new webpack.HotModuleReplacementPlugin()],
optimization: {
namedChunks: true
}
});
fs.writeFileSync(entryFile, "1", "utf-8");
compiler.run((err, stats) => {
if (err) throw err;
const jsonStats = stats.toJson();
const hash = jsonStats.hash;
const trunkName = Object.keys(jsonStats.assetsByChunkName)[0];
fs.writeFileSync(statsFile3, stats.toString());
compiler.run((err, stats) => {
if (err) throw err;
fs.writeFileSync(statsFile4, stats.toString());
fs.writeFileSync(entryFile, "2", "utf-8");
compiler.run((err, stats) => {
if (err) throw err;
fs.writeFileSync(statsFile3, stats.toString());
const result = JSON.parse(
stats.compilation.assets[`${hash}.hot-update.json`].source()
)["c"][`${trunkName}`];
expect(result).toBe(true);
done();
});
});
});
});
});

View File

@ -1,5 +1,3 @@
(module
(func (export "a") (result i32)
(i32.const 1)
)
(func (export "a"))
)

View File

@ -114,3 +114,7 @@ it("should follow renamings in var (issue 5215)", function() {
expect(TEST).toBe("test");
expect(DEFINED_NESTED_KEY).toBe(5);
});
it("should check that runtimeValue callback argument is a module", function() {
expect(RUNTIMEVALUE_CALLBACK_ARGUMENT_IS_A_MODULE).toEqual(true);
});

View File

@ -1,4 +1,5 @@
var DefinePlugin = require("../../../../lib/DefinePlugin");
const Module = require("../../../../lib/Module");
module.exports = {
plugins: [
new DefinePlugin({
@ -26,7 +27,12 @@ module.exports = {
"typeof wurst": "typeof suppe",
"typeof suppe": "typeof wurst",
wurst: "suppe",
suppe: "wurst"
suppe: "wurst",
RUNTIMEVALUE_CALLBACK_ARGUMENT_IS_A_MODULE: DefinePlugin.runtimeValue(
function({ module }) {
return module instanceof Module;
}
)
})
]
};

View File

@ -13,3 +13,11 @@ it("should not update a define when dependencies list is missing", function() {
type: "string"
}));
});
it("should update always when fileDependencies is true", function() {
const module3 = require("./module3");
expect(module3).toEqual(nsObj({
default: WATCH_STEP,
type: "string"
}));
});

View File

@ -0,0 +1,2 @@
export default TEST_VALUE3;
export const type = typeof TEST_VALUE3;

View File

@ -16,7 +16,10 @@ module.exports = {
),
TEST_VALUE2: webpack.DefinePlugin.runtimeValue(() => {
return JSON.stringify(fs.readFileSync(valueFile, "utf-8").trim());
}, [])
}, []),
TEST_VALUE3: webpack.DefinePlugin.runtimeValue(() => {
return JSON.stringify(fs.readFileSync(valueFile, "utf-8").trim());
}, true)
})
]
};

708
yarn.lock

File diff suppressed because it is too large Load Diff