Skip to content

Commit 9e64bde

Browse files
authored
Fix Webpack warnings for optional imports (#186)
* Add pino to peer dependencies * Add webpackIgnore comments
1 parent 2a07918 commit 9e64bde

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@
221221
"fastify-plugin": "^4 || ^5",
222222
"h3": "^2",
223223
"hono": "^4",
224-
"koa": "^2 || ^3"
224+
"koa": "^2 || ^3",
225+
"pino": "^8 || ^9 || ^10"
225226
},
226227
"peerDependenciesMeta": {
227228
"@adonisjs/core": {
@@ -265,6 +266,9 @@
265266
},
266267
"koa": {
267268
"optional": true
269+
},
270+
"pino": {
271+
"optional": true
268272
}
269273
},
270274
"devDependencies": {

src/common/sentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let sentry: typeof Sentry | undefined;
55
// Initialize Sentry when the module is loaded
66
(async () => {
77
try {
8-
sentry = await import("@sentry/node");
8+
sentry = await import(/* webpackIgnore: true */ "@sentry/node");
99
} catch (e) {
1010
// Sentry SDK is not installed, ignore
1111
}

src/loggers/nestjs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export async function patchNestLogger(
2020
}
2121

2222
try {
23-
const { Logger } = await import("@nestjs/common");
23+
const { Logger } = await import(/* webpackIgnore: true */ "@nestjs/common");
2424
const logMethods: LogLevel[] = [
2525
"log",
2626
"error",

src/loggers/pino.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function patchPinoLogger(
4242

4343
const originalStream = logger[originalStreamSym];
4444
if (originalStream) {
45-
const pino = await import("pino");
45+
const pino = await import(/* webpackIgnore: true */ "pino");
4646
const captureStream = new ApitallyLogCaptureStream(
4747
logsContext,
4848
logger[messageKeySym],

src/loggers/winston.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ export async function patchWinston(
1818
}
1919

2020
try {
21-
// @ts-expect-error - file is not typed
22-
const loggerModule = await import("winston/lib/winston/logger.js");
21+
const loggerModule = await import(
22+
// @ts-expect-error - file is not typed
23+
/* webpackIgnore: true */ "winston/lib/winston/logger.js"
24+
);
2325
if (loggerModule.default?.prototype?.write) {
2426
const originalWrite = loggerModule.default.prototype.write;
2527
loggerModule.default.prototype.write = function (info: any) {

0 commit comments

Comments
 (0)