test: add a case for readRecords hook usage

This commit is contained in:
Nitin Kumar 2023-04-08 09:43:00 +05:30
parent 83d049a1bd
commit d011d86226
6 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,12 @@
class ReadRecordsPlugin {
apply(compiler) {
compiler.hooks.readRecords.tapAsync("ReadRecordsPlugin", callback => {
setTimeout(() => {
console.log("Done with reading records.");
callback();
}, 1000);
});
}
}
module.exports = ReadRecordsPlugin;

View File

@ -0,0 +1 @@
import "vendor";

View File

@ -0,0 +1,3 @@
it("should load fine", () => {
return import(/* webpackChunkName: "async" */"./async");
});

View File

View File

@ -0,0 +1,10 @@
{
"chunks": {
"byName": {
"vendors~async": 123
},
"bySource": {
"1 index.js ./async": 123
}
}
}

View File

@ -0,0 +1,17 @@
const path = require("path");
const ReadRecordsPlugin = require("./ReadRecordsPlugin");
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: "./index",
recordsInputPath: path.resolve(__dirname, "records.json"),
output: {
chunkFilename: "[name]-[chunkhash].js"
},
plugins: [new ReadRecordsPlugin()],
optimization: {
splitChunks: {
minSize: 0
}
}
};