Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support loaderContext.getLogger #216

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
finalCallback();
break;
}
case 'getLogger': {

Check warning on line 288 in src/WorkerPool.js

View check run for this annotation

Codecov / codecov/patch

src/WorkerPool.js#L288

Added line #L288 was not covered by tests
// initialise logger by name in jobData
const { data } = message;
const { data: jobData } = this.jobs[id];

Check warning on line 291 in src/WorkerPool.js

View check run for this annotation

Codecov / codecov/patch

src/WorkerPool.js#L290-L291

Added lines #L290 - L291 were not covered by tests
if (!Object.hasOwnProperty.call(jobData.loggers, data.name)) {
jobData.loggers[data.name] = jobData.getLogger(data.name);

Check warning on line 293 in src/WorkerPool.js

View check run for this annotation

Codecov / codecov/patch

src/WorkerPool.js#L293

Added line #L293 was not covered by tests
}
finalCallback();
break;

Check warning on line 296 in src/WorkerPool.js

View check run for this annotation

Codecov / codecov/patch

src/WorkerPool.js#L295-L296

Added lines #L295 - L296 were not covered by tests
}
case 'logger': {
const { data } = message;
const { data: jobData } = this.jobs[id];
const logger = jobData.loggers[data.name];
logger[data.method](...data.args);
finalCallback();
break;

Check warning on line 304 in src/WorkerPool.js

View check run for this annotation

Codecov / codecov/patch

src/WorkerPool.js#L298-L304

Added lines #L298 - L304 were not covered by tests
}
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
Loading