Make SDK ESM-only; convert VS extension to ESM#425
Merged
Merged
Conversation
The SDK previously dual-published both ESM and CJS via tsconfig.cjs.json. With module: Node16, tsc respected the SDK's "type": "module" and emitted ESM syntax into dist/cjs/, which Node's CJS loader then rejected at runtime. Production paths (CLI, MCP, VSIX bundle) all consumed the ESM build, so the broken CJS output went unnoticed until vscode-test loaded out/test/*.js as CJS and required the SDK transitively (#422 added the first such SDK import to webdav-mappings.ts). Drop the CJS build entirely and simplify the SDK exports map to ESM-only. Convert the VS extension package to "type": "module" so its tsc test compile emits ESM; rename the esbuild output to dist/extension.cjs (still CJS-formatted, since VS Code requires a CJS extension entry) and point main at the new filename. Replace two __dirname usages in tests with fileURLToPath(import.meta.url). Re-enable the VS extension test step.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dist/cjswas emitting ESM syntax (becausetscwithmodule: Node16honors the SDK's"type": "module"), so the publishedrequirecondition resolved to a file Node's CJS loader rejected. Production paths (CLI, MCP, VSIX bundle) all consume the ESM build, which is why this went unnoticed until @W-22453800 site library support in libraries config #422 added an SDK import towebdav-mappings.tsandvscode-test(the only CJS consumer) tripped on it.exportsmap to ESM-only ({development, types, default}per subpath)."type": "module". Esbuild now writesdist/extension.cjs(still CJS-formatted; VS Code requires a CJS entry), andmainpoints there. Two test files swap__dirnameforfileURLToPath(import.meta.url).ci-vs-extension.yml(it was disabled in bf7e64d while this fix was prepared).Consumer impact
The SDK is no longer importable from CJS via
require(...)unless the consumer is on Node ≥22.12 (whererequire(esm)is stable for static-export modules). All in-tree consumers are ESM and unaffected.Test plan
pnpm -r run buildclean.pnpm run test:agent— SDK 1723 / CLI 1229 passing.pnpm --filter b2c-vs-extension test— 66 passing (includingout/test/webdav-mappings.test.js, the file that broke main).pnpm run typecheck:agent,pnpm run lint:agent,pnpm run -r format:checkclean.