Skip to content

NPM-PACKAGE: Move @microsoft/kiota to ESM-only (lift of #7441)#7963

Open
gavinbarron wants to merge 5 commits into
mainfrom
gavinbarron-npm-package-esm-only
Open

NPM-PACKAGE: Move @microsoft/kiota to ESM-only (lift of #7441)#7963
gavinbarron wants to merge 5 commits into
mainfrom
gavinbarron-npm-package-esm-only

Conversation

@gavinbarron

Copy link
Copy Markdown
Contributor

Summary

Lifts #7441 (by @deinok) onto current main and fixes the issues that kept it from building, so CI automations can run against a clean state.

The npm package @microsoft/kiota moves to ESM-only:

  • Ship ESM only — dropped the dual CJS/ESM build and tsconfig.cjs.json / tsconfig.esm.json, single tsconfig.json with module/moduleResolution: nodenext.
  • Relocated the remaining root modules (config, connect, install, types, utils, runtime.json) into lib/. Because runtime.json is now under rootDir, tsc emits it to dist/, so the scripts/copy-files.js copy step is no longer needed and was removed.
  • package.json: single . export, "type": "module", main/types point at dist/index.js / dist/index.d.ts, files trimmed to dist.
  • CI (ci-build.yml, build-vscode-extension.yml): runtimeFilePath now points at vscode/packages/npm-package/lib/runtime.json.

Fixes on top of the original PR

  • vscode-jsonrpc/node did not resolve under nodenext (TS2307) because that CJS dependency has no exports map, so extensionless ESM subpath resolution fails. Added the explicit .js (vscode-jsonrpc/node.js) to all 12 importers. This also unblocked cascading implicit any errors in removeItem.ts. The specifier is valid under Node ESM, webpack, and jest.
  • tests/unit/install.spec.ts still imported ../../install; updated to ../../lib/install (the original PR missed this file).
  • Preserved current main package.json version and dependencies (the original PR carried a stale 1.30.0 bump — version is managed by CI).
  • Regenerated vscode/package-lock.json via npm install; it was already consistent, so there is no lockfile diff.

Validation

  • npm run build (both packages) — ✅ npm-package tsc build + extension webpack bundle succeed; dist/runtime.json is emitted.
  • npm run test:unit --w=@microsoft/kiota — ✅ 11 suites / 18 tests pass.
  • npm run lint — ✅ 0 errors (only pre-existing enum-naming warnings in types.ts).
  • Integration tests were left for CI to exercise.

Note (from the original PR): if this package is consumed outside the webpack-bundled VS Code extension, ESM-only may be a breaking change for CommonJS consumers.

Lifts PR #7441 (deinok) onto current main, with fixes so the build,
unit tests, lint and extension webpack bundling all pass.

- Ship ESM only (drop dual CJS/ESM build, tsconfig.cjs/esm.json)
- Relocate remaining root modules into lib/ so the imported runtime.json
  is emitted to dist by tsc (removes the copy-files.js script)
- Use explicit .js import specifiers under module/moduleResolution nodenext
- Point CI runtimeFilePath at vscode/packages/npm-package/lib/runtime.json

Fixes over the original PR:
- Add .js extension to vscode-jsonrpc/node imports so they resolve under
  nodenext ESM (was TS2307; also unblocked cascading implicit-any errors)
- Update tests/unit/install.spec.ts import to ../../lib/install
- Preserve current main package.json version and dependencies

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@gavinbarron
gavinbarron requested a review from a team as a code owner July 20, 2026 23:23
@msgraph-bot msgraph-bot Bot added this to Kiota Jul 20, 2026
@github-code-quality

github-code-quality Bot commented Jul 20, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in commit c9d997a in the gavinbarron-npm-pack... branch is 72%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main gavinbarron-npm-pack... c9d997a +/-
/home/runner/wo...guageRefiner.cs 98%
/home/runner/wo...criptRefiner.cs 98%
/home/runner/wo...MethodWriter.cs 97%
/home/runner/wo...MethodWriter.cs 96%
/home/runner/wo...MethodWriter.cs 96%
/home/runner/wo...MethodWriter.cs 95%
/home/runner/wo...rs/GoRefiner.cs 94%
/home/runner/wo...KiotaBuilder.cs 90%
/home/runner/wo...ationService.cs 89%
/home/runner/wo...xGenerator.g.cs 75%

Updated July 21, 2026 01:47 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant