Skip to content

BREAKING: Make module ESM only#2272

Merged
fb55 merged 3 commits intomasterfrom
esm
Mar 17, 2026
Merged

BREAKING: Make module ESM only#2272
fb55 merged 3 commits intomasterfrom
esm

Conversation

@fb55
Copy link
Copy Markdown
Owner

@fb55 fb55 commented Mar 17, 2026

  • Set type: module, update tsconfig to nodenext
  • Output to dist/ instead of lib/, remove dual CJS/ESM build
  • Simplify exports to ESM-only
  • Migrate Jest to Vitest
  • Bump dom-serializer to ^3.0.0, domelementtype to ^3.0.0, domhandler to ^6.0.0
  • Remove deprecated findOneChild, deprecated domhandler re-exports
  • Add engines >= 20.19.0
  • Fix publish workflow (npm + JSR)

BREAKING CHANGE: This package is now ESM-only.

Copilot AI review requested due to automatic review settings March 17, 2026 22:52
@fb55 fb55 merged commit 3591b54 into master Mar 17, 2026
15 checks passed
@fb55 fb55 deleted the esm branch March 17, 2026 22:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the package for an ESM-only distribution, aligning the TypeScript build and package metadata with Node’s ESM resolution, updating dependencies to newer major versions, and migrating the test suite from Jest to Vitest while updating CI/publish workflows accordingly.

Changes:

  • Switch TypeScript compilation to nodenext and emit build artifacts to dist/ (removing the dual CJS/ESM setup).
  • Update package exports to ESM-only and remove deprecated/legacy exports and APIs.
  • Migrate tests from Jest to Vitest and adjust GitHub Actions workflows for testing and publishing (npm + JSR).

Reviewed changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
tsconfig.json Moves to nodenext module settings and changes build output to dist/.
package.json Declares ESM-only (type: module), updates exports/build scripts, switches to Vitest, bumps dependencies, adds Node engine floor.
biome.json Updates Biome schema reference.
.gitignore Replaces lib/ with dist/ and ignores jsr.json.
src/index.ts Removes deprecated domhandler re-exports; continues ESM-style .js specifiers for internal exports.
src/querying.ts Removes deprecated findOneChild.
src/*.spec.ts Migrates tests to Vitest and updates imports/ESM patterns.
src/__snapshots__/feeds.spec.ts.snap Updates snapshot header/keys for Vitest.
.github/workflows/nodejs-test.yml Updates CI test execution to Vitest and adjusts Node matrix.
.github/workflows/publish.yml Adds a publish workflow that generates jsr.json and publishes to JSR and npm.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

fail-fast: false
matrix:
node:
- 20
@@ -1,11 +1,12 @@
import { describe, expect, it } from "vitest";
import fixture from "./__fixtures__/fixture.js";
Comment on lines +4 to +11
import fixture from "./__fixtures__/fixture.js";
import {
getElementById,
getElements,
getElementsByClassName,
getElementsByTagName,
getElementsByTagType,
} from "./legacy";
} from "./legacy.js";
@@ -9,6 +10,10 @@ import {
replaceElement,
} from "./manipulation.js";
findOneChild,
} from "./querying";
import { describe, expect, it } from "vitest";
import { existsOne, filter, find, findAll, findOne } from "./querying.js";
"type": "commonjs",
"type": "module",
"name": "domutils",
"version": "3.2.2",

- uses: actions/setup-node@v6
with:
node-version: lts/*
Comment on lines +31 to +39
const jsrJson = {
name: `@cheerio/${p.name}`,
version: p.version,
exports: { ".": "./src/index.ts" },
imports: {
"dom-serializer": `jsr:@cheerio/dom-serializer@${p.dependencies["dom-serializer"]}`,
"domelementtype": `jsr:@cheerio/domelementtype@${p.dependencies.domelementtype}`,
"domhandler": `jsr:@cheerio/domhandler@${p.dependencies.domhandler}`,
},
compareDocumentPosition,
removeSubsets,
uniqueSort,
} from "./helpers.js";
import { parseDocument } from "htmlparser2";
import { getFeed } from "./feeds";
import { describe, expect, test } from "vitest";
import { getFeed } from "./feeds.js";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants