Skip to content

Commit 6198c88

Browse files
authored
fix: manually move copilot file extension from js to cjs (#6727)
Fixes #6718 Newer versions of node support `ejs` so they now try to parse `.js` files based on the package.json module type. This comes from a downstream dep but we manually move .js to .cjs
1 parent 025b455 commit 6198c88

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

marimo/_server/lsp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def get_command(self) -> list[str]:
196196
LOGGER.debug("LSP binary not found at %s", lsp_bin)
197197
return []
198198

199-
copilot_bin = self._lsp_dir() / "copilot" / "language-server.js"
199+
copilot_bin = self._lsp_dir() / "copilot" / "language-server.cjs"
200200
log_file = _loggers.get_log_directory() / "github-copilot-lsp.log"
201201

202202
# Use typed format to avoid quoting issues: copilot:<binary_path>

packages/lsp/move.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require("node:fs");
4+
const path = require("node:path");
5+
6+
// Copy node_modules/@github/copilot-language-server/dist/ to dist/
7+
const srcDir = path.join(
8+
__dirname,
9+
"node_modules/@github/copilot-language-server/dist",
10+
);
11+
const destDir = path.join(__dirname, "dist");
12+
13+
// Recursively copy directory
14+
fs.cpSync(srcDir, destDir, { recursive: true, dereference: true });
15+
16+
// Rename language-server.js to language-server.cjs
17+
const oldPath = path.join(destDir, "language-server.js");
18+
const newPath = path.join(destDir, "language-server.cjs");
19+
fs.renameSync(oldPath, newPath);
20+
21+
// biome-ignore lint/suspicious/noConsole: build script
22+
console.log("Successfully copied and renamed language-server files");

packages/lsp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "Apache-2.0",
66
"scripts": {
77
"build:ts": "tsup index.ts --format cjs --minify",
8-
"build:deps": "cp -LR node_modules/@github/copilot-language-server/dist/ dist/",
8+
"build:deps": "node move.js",
99
"typecheck": "tsgo",
1010
"build": "pnpm run build:ts && pnpm run build:deps",
1111
"test": "vitest"

tests/_server/test_lsp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_copilot_server_uses_typed_format(tmp_path: Path) -> None:
150150

151151
copilot_dir = lsp_dir_with_spaces / "copilot"
152152
copilot_dir.mkdir()
153-
copilot_bin = copilot_dir / "language-server.js"
153+
copilot_bin = copilot_dir / "language-server.cjs"
154154
copilot_bin.touch()
155155

156156
# Mock the _lsp_dir method to return our test directory

0 commit comments

Comments
 (0)