Skip to content

Commit

Permalink
fix: getLogger is now defined in child loader
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung authored Sep 17, 2024
1 parent b1affb4 commit 158d52b
Show file tree
Hide file tree
Showing 11 changed files with 423 additions and 7 deletions.
198 changes: 194 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@commitlint/config-conventional": "^17.6.7",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"babel-loader": "^9.2.0",
"cross-env": "^7.0.2",
"cspell": "^6.31.2",
"css-loader": "^6.10.0",
Expand All @@ -68,6 +68,7 @@
"eslint-plugin-import": "^2.29.1",
"husky": "^4.3.0",
"jest": "^29.7.0",
"less-loader": "^10.2.0",
"lint-staged": "^10.5.0",
"lodash": "^4.17.20",
"memfs": "^3.5.1",
Expand Down
18 changes: 18 additions & 0 deletions src/WorkerPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,24 @@ class PoolWorker {
finalCallback();
break;
}
case 'getLogger': {
// initialise logger by name in jobData
const { data } = message;
const { data: jobData } = this.jobs[id];
if (!Object.hasOwnProperty.call(jobData.loggers, data.name)) {
jobData.loggers[data.name] = jobData.getLogger(data.name);
}
finalCallback();
break;
}
case 'logger': {
const { data } = message;
const { data: jobData } = this.jobs[id];
const logger = jobData.loggers[data.name];
logger[data.method](...data.args);
finalCallback();
break;
}
default: {
console.error(`Unexpected worker message ${type} in WorkerPool.`);
finalCallback();
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function pitch() {
sourceMap: this.sourceMap,
emitError: this.emitError,
emitWarning: this.emitWarning,
getLogger: this.getLogger,
loggers: {},
loadModule: this.loadModule,
resolve: this.resolve,
getResolve: this.getResolve,
Expand Down
Loading

0 comments on commit 158d52b

Please sign in to comment.