NPM-PACKAGE - Move to ESM#7441
Conversation
baywet
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
I double checked and the other big consumer of this package is also using a bundler
https://github.com/OfficeDev/microsoft-365-agents-toolkit/blob/c0eb0bed661202bfd85b3bb1bd61e21b0b73c0b4/packages/fx-core/package.json#L87
|
@baywet I left two points unresolved. Also could you please trigger CI? |
done. Another aspect of cjs I forgot to mention earlier is jest's configuration that'll need to be updated. |
|
@deinok sorry, I had kind of forgotten about this one until #7528 started failing. Would you mind having a look at this failure please? https://github.com/microsoft/kiota/actions/runs/22797694626/job/66295106427?pr=7441 |
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall coverage in commit 325433e in the Show a code coverage summary of the most covered files.
Updated |
* NPM-PACKAGE: Move @microsoft/kiota to ESM-only 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> * Fix npm package Jest setup for ESM imports Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Address review feedback on npm-package ESM imports - Use node: prefix for Node builtin imports (crypto, https, fs, path, url, child_process) across install.ts, connect.ts, generatePlugin.ts. - Split utils.ts import into an import type for type-only symbols (KiotaLogEntry, LogLevel) while keeping MaturityLevel and DependencyType as value imports since they are enums accessed at runtime. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0c0540e6-edc8-43c3-ba28-e40e0781f759 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Closing this as the work was uplifted into #7963 and completed |
@baywet Getting clean ESM + CommonJS outputs without introducing bundling has been messy, so I went with this approach:
lib/foldertsconfig.jsonto includelib/instead of excluding everything elseThe VSCode plugin should still work fine with ESM because it’s bundled with webpack, so webpack will bundle what it needs from the ESM module and tree-shake unused exports where possible.