Skip to content

Commit 4acae7f

Browse files
committed
vx: fix ts-loader to ignore non-file URLs in Node 20+ loader bootstrap
1 parent 576bb27 commit 4acae7f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

vx/ts-loader.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export async function resolve(specifier, context, next) {
5050
return next(specifier, context);
5151
}
5252

53+
// eslint-disable-next-line complexity
5354
export async function load(url, context, next) {
5455
if (url.endsWith('.ts')) {
5556
const source = await readFile(new URL(url), 'utf8');
@@ -71,5 +72,17 @@ export async function load(url, context, next) {
7172
};
7273
}
7374

74-
return next(url, context);
75+
const result = await next(url, context);
76+
77+
// Ensure source is returned if missing (fixes ERR_INVALID_RETURN_PROPERTY_VALUE in some environments)
78+
if (!result.source && result.format !== 'builtin') {
79+
try {
80+
const source = await readFile(new URL(url), 'utf8');
81+
return { ...result, source };
82+
} catch {
83+
// Ignore errors if file cannot be read (e.g. wasm or internal)
84+
}
85+
}
86+
87+
return result;
7588
}

0 commit comments

Comments
 (0)