Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 811166c

Browse files
author
Wenjie Xia
committed
refactor: don't panic when loader is undefined
1 parent 2facb19 commit 811166c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/app.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ export class Appliaction {
993993
if (shouldCompile) {
994994
let sourceCode = (new TextDecoder).decode(sourceContent)
995995
let loader = mod.loader
996+
996997
for (const plugin of this.config.plugins) {
997998
if (plugin.type === 'loader' && plugin.test.test(url)) {
998999
const { code, format = 'js' } = await plugin.transform(sourceContent, url)
@@ -1017,7 +1018,9 @@ export class Appliaction {
10171018
}
10181019

10191020
if (loader !== 'js' && loader !== 'ts' && loader !== 'jsx' && loader !== 'tsx') {
1020-
throw new Error(`Unknown loader '${path.extname(url).slice(1)}'`)
1021+
log.error(`Unknown loader '${path.extname(url).slice(1)}'`)
1022+
mod.error = new Error('unknown loader')
1023+
return mod
10211024
}
10221025

10231026
try {

0 commit comments

Comments
 (0)