Skip to content

Migrate to ES Module-only builds - #1358

Draft
shin19991207 wants to merge 7 commits into
redhat-developer:mainfrom
shin19991207:swtich-to-esm
Draft

shin19991207 wants to merge 7 commits into
redhat-developer:mainfrom
shin19991207:swtich-to-esm

Conversation

@shin19991207

@shin19991207 shin19991207 commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Migrate to ES Module-only builds and simplify its build, test, and coverage tooling:

  • Replace the separate CommonJS, UMD, and ESM builds with one ESM output under out/server, including TypeScript declarations
  • Replace Mocha with Node’s built-in node:test runner
  • Replace ts-node with tsc to compile tests before running them with Node’s built-in test runner
  • Replace nyc with c8
    • nyc adds counters to code but its default setup intercepts files loaded through CommonJS require(). Native ESM import uses a different loading mechanism, so that setup does not automatically measure those modules. Using nyc with ESM requires instrumenting the code before running tests. c8 reads coverage collected by Node’s JavaScript engine and works with native ESM without adding counters or an extra instrumentation step; therefore, switching to it.
  • Replace sinon, sinon-chai, and their typings with Node’s built-in mock.fn() and mock.method()
  • Replace source-map-support with Node’s built-in --enable-source-maps
  • Upgrade vscode-languageserver to 10.1.2, vscode-languageserver-types to 3.18.4, and adapt code to the new APIs. The newer types package lets webpack select its ESM build even when CommonJS dependencies load it through require(), making ESM selection consistent across the bundles.
  • Set the minimum supported Node version to 22.13.0 in package.json and CI because ESLint 10 requires 22.13.0 or newer, and npm run build includes ESLint

Breaking changes

  • Node.js 22.13.0 or newer is required
  • yaml-language-server publishes ESM-only builds. The package entry point and files under out/server/src are ESM; this directory previously contained CommonJS output. Consumers and build tools expecting CommonJS files must adapt their configuration.
  • lib/esm and lib/umd outputs are removed. Consumers using these paths must switch to the corresponding files under out/server/src.
  • The browser server entry point moves to yaml-language-server/out/server/src/webworker/yamlServerMain.js

What issues does this PR fix or reference?

Fixes #1199

Is it tested? How?

  • Verified the build and tests locally
  • CI

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to ESM

1 participant