Skip to content

Commit 5e43132

Browse files
authored
Make SDK ESM-only; convert VS extension to ESM (#425)
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.
1 parent 5bd9fe3 commit 5e43132

9 files changed

Lines changed: 91 additions & 309 deletions

File tree

.changeset/sdk-esm-only.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@salesforce/b2c-tooling-sdk': minor
3+
'b2c-vs-extension': patch
4+
---
5+
6+
The SDK is now ESM-only — the dual-format `dist/cjs` build has been removed and the package exports map exposes only ESM. CommonJS consumers that previously did `require('@salesforce/b2c-tooling-sdk')` from a CJS package must either switch to `import` or rely on Node's `require(esm)` (Node ≥22.12). The VS Code extension has been converted to a `"type": "module"` package; its bundled entry is now `dist/extension.cjs`.

.github/workflows/ci-vs-extension.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ jobs:
7373
- name: Build packages
7474
run: pnpm -r run build
7575

76-
# Temporarily disabled: SDK dist/cjs emits ESM syntax (tsc with module: Node16
77-
# respects the SDK's "type": "module"), which Node's CJS loader rejects when
78-
# vscode-test requires it transitively from out/test/*.js. The production VSIX
79-
# is unaffected because esbuild bundles the SDK directly. Re-enable once the
80-
# SDK CJS emit is fixed.
81-
# - name: Run VS Extension tests
82-
# working-directory: packages/b2c-vs-extension
83-
# run: xvfb-run -a pnpm run test
76+
- name: Run VS Extension tests
77+
working-directory: packages/b2c-vs-extension
78+
run: xvfb-run -a pnpm run test

0 commit comments

Comments
 (0)