Merge tag 'v4.28.3' into next

4.28.3
This commit is contained in:
Tobias Koppers 2018-12-29 12:59:56 +01:00
commit b241549d31
3 changed files with 41 additions and 5 deletions

View File

@ -1,12 +1,12 @@
This example demonstrates the AggressiveSplittingPlugin for splitting the bundle into multiple smaller chunks to improve caching. This works best with a HTTP2 web server elsewise there is an overhead for the increased number of requests.
This example demonstrates the AggressiveSplittingPlugin for splitting the bundle into multiple smaller chunks to improve caching. This works best with a HTTP2 web server, otherwise there is an overhead for the increased number of requests.
The AggressiveSplittingPlugin split every chunk until it reaches the specified `maxSize`. In this example it tries to create chunks with <50kB code (after minimizing this reduces to ~10kB). It groups modules together by folder structure. We assume modules in the same folder as similar likely to change and minimize and gzip good together.
AggressiveSplittingPlugin splits every chunk until it reaches the specified `maxSize`. In this example it tries to create chunks with <50kB raw code, which typically minimizes to ~10kB. It groups modules together by folder structure, because modules in the same folder are likely to have similar repetitive text, making them gzip efficiently together. They are also likely to change together.
The AggressiveSplittingPlugin records it's splitting in the webpack records and try to restore splitting from records. This ensures that after changes to the application old splittings (and chunks) are reused. They are probably already in the clients cache. Therefore it's heavily recommended to use records!
AggressiveSplittingPlugin records its splitting in the webpack records. When it is next run, it tries to use the last recorded splitting. Since changes to application code between one run and the next are usually in only a few modules (or just one), re-using the old splittings (and chunks, which are probably still in the client's cache), is highly advantageous.
Only chunks which are bigger than the specified `minSize` are stored into the records. This ensures that these chunks fill up as your application grows, instead of creating too many chunks for every change.
Only chunks which are bigger than the specified `minSize` are stored into the records. This ensures that these chunks fill up as your application grows, instead of creating many records of small chunks for every change.
Chunks can get invalid if a module changes. Modules from invalid chunks go back into the module pool and new chunks are created from all modules in the pool.
If a module changes, its chunks are declared to be invalid, and are put back into the module pool. New chunks are created from all modules in the pool.
There is a tradeoff here:

View File

@ -6,6 +6,8 @@
const { Tracer } = require("chrome-trace-event");
const fs = require("fs");
const mkdirp = require("mkdirp");
const path = require("path");
const validateOptions = require("schema-utils");
const schema = require("../../schemas/plugins/debug/ProfilingPlugin.json");
@ -99,6 +101,10 @@ const createTrace = outputPath => {
noStream: true
});
const profiler = new Profiler(inspector);
if (/\/|\\/.test(outputPath)) {
const dirPath = path.dirname(outputPath);
mkdirp.sync(dirPath);
}
const fsStream = fs.createWriteStream(outputPath);
let counter = 0;

View File

@ -0,0 +1,30 @@
"use strict";
const path = require("path");
const fs = require("fs");
const webpack = require("../");
const rimraf = require("rimraf");
describe("Profiling Plugin", function() {
it("should handle output path with folder creation", done => {
const finalPath = "test/js/profilingPath/events.json";
const outputPath = path.join(__dirname, "/js/profilingPath");
rimraf(outputPath, () => {
const compiler = webpack({
context: "/",
entry: "./fixtures/a.js",
plugins: [
new webpack.debug.ProfilingPlugin({
outputPath: finalPath
})
]
});
compiler.run(err => {
if (err) return done(err);
if (!fs.existsSync(outputPath))
return done(new Error("Folder should be created."));
done();
});
});
});
});