cli: explicit module type fallback for Node.js 22

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-12-26 21:51:05 +01:00
parent e6c049add0
commit a8dc7f2a7a
@@ -112,6 +112,10 @@ async function withDetectedModuleType(resolved) {
if (resolved.format) {
return resolved;
}
// Happens in Node.js v22 when there's a package.json without an explicit "type" field. Use the default.
if (resolved.format === null) {
return { ...resolved, format: DEFAULT_MODULE_FORMAT };
}
const ext = extname(resolved.url);