Commit b1190a3
The `--vscode-extension` codegen previously emitted a runtime require()
of `@hyperpolymath/affine-vscode` to source the WASM's `Vscode` and
`VscodeLanguageClient` import modules. That package isn't published to
npm yet (gated on owner action in #104), so the require failed,
extraImports() returned {}, and the WASM activation failed:
WebAssembly.instantiate(): Import #1 "Vscode":
module is not an object or function
The previous CI workaround (PR #377) added a `file:` install of the
in-tree adapter as a smoke-test-step bridge — useful but not a root
fix.
This commit eliminates the runtime npm dependency entirely:
1. New dune rule generates `lib/affine_vscode_adapter_source.ml` from
`packages/affine-vscode/mod.js` at build time, exposing the source
as an OCaml string constant.
2. `vscode_extension_wiring` in `lib/codegen_node.ml` now inlines the
adapter source into the generated `.cjs` as a CJS-style closure:
try { _makeVscodeBindings = require("@hyperpolymath/affine-vscode"); }
catch (_e) { /* fall through to embedded adapter */ }
if (typeof _makeVscodeBindings !== "function") {
const _adapterModule = { exports: null };
(function (module, exports) {
/* …embedded packages/affine-vscode/mod.js source… */
})(_adapterModule, _adapterModule.exports);
_makeVscodeBindings = _adapterModule.exports;
}
The require() is still attempted first so an upgraded adapter
installed via npm can override the embedded copy — but it's no
longer load-bearing.
3. Regenerated `editors/vscode/out/extension.cjs` with the new codegen
(618 lines, up from 121 — the delta is the inlined adapter source).
4. Dropped `optionalDependencies` for `@hyperpolymath/affine-vscode`
from `editors/vscode/package.json` — the extension no longer needs
it at install time. The package keeps its in-tree home at
`packages/affine-vscode/` as the source of truth for JSR/npm
publishing and for `--vscode-extension` codegen consumption.
5. Dropped `continue-on-error: true` from the vscode-smoke job in
`.github/workflows/ci.yml`. The job is now expected to be reliable;
a real regression should turn it red and gate.
Verified locally: the regenerated `extension.cjs` loads cleanly under
plain Node (`require()` works, `extraImports` is a function), and the
existing `tools/run_codegen_wasm_tests.sh` suite still passes.
Refs #139 (smoke harness), #104 (pending npm publish — no longer a
runtime blocker), gitbot-fleet#148.
Closes the "fundamental root cause" path opened in PR #377.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 44b5341 commit b1190a3
5 files changed
Lines changed: 569 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
225 | 220 | | |
226 | | - | |
227 | 221 | | |
228 | 222 | | |
229 | 223 | | |
| |||
236 | 230 | | |
237 | 231 | | |
238 | 232 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
247 | 239 | | |
248 | 240 | | |
249 | 241 | | |
| |||
0 commit comments