Skip to content

Commit

Permalink
reintroduce a fix for Windows compatibility that was lost in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcelhaney committed Sep 5, 2023
1 parent aa7033b commit 7539436
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/server/module-loader.ts
Expand Up @@ -87,7 +87,7 @@ export class ModuleLoader extends EventTarget {
// eslint-disable-next-line promise/prefer-await-to-then
.catch((error: unknown) => {
process.stdout.write(
`\nError loading ${pathName}:\n${String(error)}\n`,
`\nError loading ${fileUrl}:\n${String(error)}\n`,
);
});
},
Expand Down Expand Up @@ -142,9 +142,13 @@ export class ModuleLoader extends EventTarget {
directory: string,
file: Dirent,
) {
const fileUrl = `${pathToFileURL(
fullPath,
).toString()}?cacheBust=${Date.now()}`;

try {
// eslint-disable-next-line import/no-dynamic-require, no-unsanitized/method, @typescript-eslint/consistent-type-assertions
const endpoint: ContextModule | Module = (await import(fullPath)) as
const endpoint: ContextModule | Module = (await import(fileUrl)) as
| ContextModule
| Module;

Expand All @@ -167,7 +171,7 @@ export class ModuleLoader extends EventTarget {
this.registry.add(url, endpoint as Module);
}
} catch (error: unknown) {
process.stdout.write(`\nError loading ${fullPath}:\n${String(error)}\n`);
process.stdout.write(`\nError loading ${fileUrl}:\n${String(error)}\n`);
}
}
}

0 comments on commit 7539436

Please sign in to comment.