Skip to content

Commit 2ea6194

Browse files
authored
feat(native-plugin): output warn / debug logs from resolver (#343)
1 parent 56f94c7 commit 2ea6194

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

packages/vite/src/node/__tests__/resolve.spec.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,18 @@ describe('file url', () => {
214214
expect(resolved).toBeNull()
215215
})
216216

217-
// skip for native plugin because logs are not output (https://github.com/rolldown/rolldown/issues/4290)
218-
test.skipIf(!!process.env._VITE_TEST_NATIVE_PLUGIN)(
219-
'non declared node builtin',
220-
async () => {
221-
await expect(
222-
run({
223-
builtins: [
224-
/* empty */
225-
],
226-
idToResolve: 'node:fs',
227-
}),
228-
).rejects.toThrowError(
229-
/warning: Automatically externalized node built-in module "node:fs"/,
230-
)
231-
},
232-
)
217+
test('non declared node builtin', async () => {
218+
await expect(
219+
run({
220+
builtins: [
221+
/* empty */
222+
],
223+
idToResolve: 'node:fs',
224+
}),
225+
).rejects.toThrowError(
226+
/warning: Automatically externalized node built-in module "node:fs"/,
227+
)
228+
})
233229

234230
test('default to node-like builtins', async () => {
235231
const resolved = await run({

packages/vite/src/node/plugins/resolve.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,24 @@ export function oxcResolvePlugin(
348348
options.scan = scan
349349
return resolveSubpathImports(id, importer, options)
350350
},
351+
352+
...(partialEnv.config.command === 'serve'
353+
? {
354+
async onWarn(msg) {
355+
getEnv().logger.warn(`warning: ${msg}`, {
356+
clear: true,
357+
timestamp: true,
358+
})
359+
},
360+
}
361+
: {}),
362+
...(debug
363+
? {
364+
async onDebug(message) {
365+
debug(message)
366+
},
367+
}
368+
: {}),
351369
})
352370
},
353371
),

0 commit comments

Comments
 (0)