Skip to content

feat!: migrate to ESM, require Node.js 22.12+, update htmlparser2/postcss-safe-parser, and restrict deep imports - #163

Merged
ota-meshi merged 5 commits into
masterfrom
major-v2-prep
Jul 31, 2026
Merged

ota-meshi merged 5 commits into
masterfrom
major-v2-prep

Conversation

@ota-meshi

@ota-meshi ota-meshi commented Jul 31, 2026 •

Copy link
Copy Markdown
Owner

Preparation for the v2 major release, following the Node.js support change in #162.

The package is now an ES module. The Node.js requirement rises to ^22.12 || >=24, the versions where require(esm) is enabled by default. CommonJS consumers keep working unchanged: the entry point declares the 'module.exports' interop export, so require("postcss-html") returns the same callable API as v1. A dedicated CommonJS test (test/cjs-interop.cjs) covers this path. stylelint 16/17 load custom syntaxes via import() and are unaffected. Staying CommonJS would have pinned htmlparser2 and js-tokens to their last CJS-compatible majors, since both are ESM-only upstream now.

Runtime dependency updates that were blocked by the old Node.js floor:

Deep imports into lib/ are no longer possible: the new exports field restricts consumers to the package root.

The stylelint integration tests now run against stylelint 17 and stylelint-config-standard 40 instead of stylelint 14, which is what current users actually install. This required adapting to stylelint 17 API changes (result.output removed in favor of result.code; ESM-only shareable configs). One finding worth attention: with stylelint 17, an overrides-only config such as stylelint-config-recommended-vue fails with ConfigurationError: No rules found within configuration as soon as the CLI resolves the formatter, because that resolution evaluates the config without a target file. The fixture works around it with a top-level rules: {}, but this looks like a real compatibility issue between stylelint 17 and stylelint-config-recommended-vue that affects end users. Relatedly, stylelint-config-recommended-vue's peerDependencies currently allow only postcss-html: ^1.0.0 and will need an update when v2 ships.

Remaining housekeeping visible in the diff: coverage moves from nyc to c8 because nyc's require-hook instrumentation cannot see ES modules; the deprecated and unused codecov package is removed; the explorer app needs webpack >=5.109 to handle the string-named export plus a NormalModuleReplacementPlugin so its browser shims also apply to node:-prefixed builtin imports.

🤖 Generated with Claude Code

ota-meshi and others added 3 commits July 31, 2026 19:25
…ge exports

htmlparser2 v9 changed the attribute endIndex passed to onattribend to
point one past the closing quote, so the style attribute guard in
extract-styles is adjusted accordingly. As a side effect, declarations
parsed from style attributes now get a proper source.end position
(previously undefined).

htmlparser2 v10+ and js-tokens v10 are ESM-only, so v9 is the ceiling
for both while this package remains CommonJS.

The new exports field restricts deep imports into lib/.

Co-Authored-By: Claude Fable 5 <[email protected]>
stylelint 17 removed the standalone result.output property (fixed code
is on result.code), and stylelint-config-standard v40 is ESM-only so
require() returns a module namespace object.

The recommended-vue fixture needs a top-level rules: {} because
stylelint 17 resolves the formatter option by evaluating the config
without a target file, and an overrides-only config fails that
evaluation with a ConfigurationError.

Co-Authored-By: Claude Fable 5 <[email protected]>
The package now requires Node.js ^22.12 || >=24. CommonJS consumers on
those versions keep working: require(esm) is unflagged there, and the
entry point declares the 'module.exports' interop export so require()
returns the same callable API as v1 (verified by test/cjs-interop.cjs).
stylelint 16/17 load custom syntaxes via import(), so they are
unaffected.

Coverage moves from nyc to c8 because nyc's require-hook based
instrumentation cannot see ES modules.

The explorer app needs webpack >=5.109 to handle the string-named
export, and a NormalModuleReplacementPlugin so its browser shims also
apply to node:-prefixed builtin imports.

Co-Authored-By: Claude Fable 5 <[email protected]>
@ota-meshi ota-meshi changed the title feat!: update runtime dependencies and add package exports for v2 feat!: migrate to ESM, require Node.js 22.12+, update htmlparser2/postcss-safe-parser, and restrict deep imports Jul 31, 2026
Co-Authored-By: Claude Fable 5 <[email protected]>
@ota-meshi ota-meshi closed this Jul 31, 2026
@ota-meshi ota-meshi reopened this Jul 31, 2026
Adopts the automerged chai 6 / mocha 11 / mocha-chai-jest-snapshot 1.1.7
updates; the ESM tests switch to chai's named exports because chai 6 has
no default export.

Co-Authored-By: Claude Fable 5 <[email protected]>
@ota-meshi
ota-meshi merged commit 6dd4136 into master Jul 31, 2026
4 checks passed
@ota-meshi
ota-meshi deleted the major-v2-prep branch July 31, 2026 13:41
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.

1 participant