Skip to content

Commit 472b815

Browse files
author
Harald Kirschner
committed
docs: add cross-platform guidance for process spawning and ESM/CJS interop
1 parent 99070ab commit 472b815

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.github/copilot-instructions.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ VS Code extension: `node esbuild.mjs` from `vscode-extension/`; typecheck with `
2727
## Code Style
2828

2929
- ESM syntax everywhere (`"type": "module"`). TypeScript strict mode, ES2022 target.
30-
- Windows/macOS/Linux compatible — use `path.join()`, avoid shell-specific syntax.
3130
- Do not add new build/lint/test tools; use existing npm scripts.
3231

32+
### Cross-Platform (Windows/macOS/Linux)
33+
34+
- Use `path.join()` for all file paths; avoid shell-specific syntax.
35+
- **Spawning processes:** Never assume an executable is a native binary. On Windows, CLI tools often resolve to `.bat`/`.cmd` shims (e.g., VS Code globalStorage). Use `{ shell: true }` or detect script extensions and route through `cmd.exe /c` — bare `spawn()` of a `.bat` file throws `EINVAL`.
36+
- **ESM/CJS interop in bundles:** When bundling CJS dependencies (e.g., `vscode-jsonrpc`) into ESM output, `require()` is unavailable at runtime. If a dependency internally calls `require()`, the tsup banner must inject a `createRequire` shim. Watch for `"Dynamic require of X is not supported"` errors after adding new dependencies.
37+
- **File path separators:** Use `path.sep` or `path.normalize()` when comparing or displaying paths. Never hardcode `/` or `\` in path logic.
38+
3339
## Architecture
3440

3541
- **Entrypoint:** `src/index.ts``runCli()` in `src/cli.ts`

0 commit comments

Comments
 (0)