Skip to content

Commit 7a86738

Browse files
committed
fix: do the same in src/node/routes/vscode.ts.
fix: invalid ESM module path on Windows.
1 parent d70498c commit 7a86738

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/node/routes/vscode.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { promises as fs } from "fs"
55
import * as http from "http"
66
import * as net from "net"
77
import * as path from "path"
8+
import * as os from "os"
89
import { WebsocketRequest } from "../../../typings/pluginapi"
910
import { logError } from "../../common/util"
1011
import { CodeArgs, toCodeArgs } from "../cli"
@@ -58,7 +59,11 @@ async function loadVSCode(req: express.Request): Promise<IVSCodeServerAPI> {
5859
// which will also require that we switch to ESM, since a hybrid approach
5960
// breaks importing `rotating-file-stream` for some reason. To work around
6061
// this, use `eval` for now, but we should consider switching to ESM.
61-
const modPath = path.join(vsRootPath, "out/server-main.js")
62+
let modPath = path.join(vsRootPath, "out/server-main.js")
63+
if (os.platform() === "win32") {
64+
// On Windows, absolute paths of ESM modules must be a valid file URI.
65+
modPath = "file:///" + modPath.replace(/\\/g, "/")
66+
}
6267
const mod = (await eval(`import("${modPath}")`)) as VSCodeModule
6368
const serverModule = await mod.loadCodeWithNls()
6469
return serverModule.createServer(null, {

0 commit comments

Comments
 (0)