Skip to content

Commit f13455e

Browse files
committed
fix(extension): bundle bin/axme-code as CJS, not ESM
The bundled binary in extension/bin/ has no file extension (shebang script). Without a ".mjs" suffix or a sibling package.json declaring "type":"module", Node loads the file as CJS and explodes on the first ESM `import` statement at runtime: SyntaxError: Cannot use import statement outside a module at wrapSafe (node:internal/modules/cjs/loader:1378:20) Surfaced when sideloading axme-code-dev.vsix into Cursor and trying to run AXME: Setup or any axme MCP tool — the MCP server failed to spawn, hooks crashed on first invocation. Fix: change esbuild output from --format=esm to --format=cjs. The shebang stays; the binary is now valid CJS that Node executes without --experimental flags. Tested locally: extension/bin/axme-code --version → 0.5.0 (was: SyntaxError) Updates the publish-extension.yml CI step that runs the same esbuild bundle inside the 5-platform matrix, so the Open VSX- distributed .vsix files don't ship with the same crash. #!axme pr=130 repo=AxmeAI/axme-code
1 parent 3e2fde6 commit f13455e

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

.github/workflows/publish-extension.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,29 @@ jobs:
6565
shell: bash
6666
run: |
6767
mkdir -p extension/bin
68-
# Bundle dist/cli.mjs into a single ESM file with everything inlined
69-
# except @anthropic-ai/claude-agent-sdk (provided at runtime) and
70-
# @cursor/sdk (loaded dynamically at runtime via optional dep).
68+
# Bundle dist/cli.mjs into a single CJS file with everything
69+
# inlined except @anthropic-ai/claude-agent-sdk (provided at
70+
# runtime) and @cursor/sdk (loaded dynamically via optional dep).
71+
#
72+
# WHY CJS, not ESM: the output is a shebang script with no file
73+
# extension (Windows uses .exe — see matrix.extension_bin).
74+
# Without ".mjs" extension AND without a sibling package.json
75+
# declaring "type":"module", Node loads the file as CJS and
76+
# ESM import statements throw at runtime.
7177
npx esbuild dist/cli.mjs \
7278
--bundle \
7379
--platform=node \
7480
--target=node20 \
75-
--format=esm \
81+
--format=cjs \
7682
--external:@anthropic-ai/claude-agent-sdk \
7783
--external:@cursor/sdk \
78-
--outfile=extension/bin/axme-code.mjs
84+
--outfile=extension/bin/axme-code.cjs
7985
# Wrap in a shebang shim so it's executable as a binary.
8086
{
8187
printf '#!/usr/bin/env node\n'
82-
cat extension/bin/axme-code.mjs
88+
cat extension/bin/axme-code.cjs
8389
} > extension/bin/${{ matrix.extension_bin }}
84-
rm extension/bin/axme-code.mjs
90+
rm extension/bin/axme-code.cjs
8591
chmod +x extension/bin/${{ matrix.extension_bin }} || true
8692
8793
- name: Install extension deps

0 commit comments

Comments
 (0)