Skip to content

Commit

Permalink
test: add a case for readRecords hook usage
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Apr 8, 2023
1 parent 83d049a commit d011d86
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
@@ -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;
1 change: 1 addition & 0 deletions test/configCases/records/with-readRecords-hook/async.js
@@ -0,0 +1 @@
import "vendor";
3 changes: 3 additions & 0 deletions test/configCases/records/with-readRecords-hook/index.js
@@ -0,0 +1,3 @@
it("should load fine", () => {
return import(/* webpackChunkName: "async" */"./async");
});
Empty file.
10 changes: 10 additions & 0 deletions test/configCases/records/with-readRecords-hook/records.json
@@ -0,0 +1,10 @@
{
"chunks": {
"byName": {
"vendors~async": 123
},
"bySource": {
"1 index.js ./async": 123
}
}
}
17 changes: 17 additions & 0 deletions test/configCases/records/with-readRecords-hook/webpack.config.js
@@ -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
}
}
};

0 comments on commit d011d86

Please sign in to comment.