-
-
Notifications
You must be signed in to change notification settings - Fork 435
Description
Describe the bug
Since upgrading to htmlhint@1.8.1, importing HTMLHint as a named export in an ESM context throws an error indicating that the module does not provide the HTMLHint export.
In previous versions, the following ESM import worked:
import { HTMLHint } from "htmlhint";With 1.8.1, Node.js reports that htmlhint is a CommonJS module and that the named export cannot be resolved.
To Reproduce
Environment:
- Node.js: v24.13.0
- OS: Windows (reproducible in other environments as well)
- Module system: ESM
Steps:
npm install --save-exact htmlhint@1.8.1
node --eval 'import { HTMLHint } from "htmlhint";'Result:
SyntaxError: Named export 'HTMLHint' not found. The requested module 'htmlhint' is a CommonJS module...
Node suggests using:
import pkg from "htmlhint";
const { HTMLHint } = pkg;Expected behavior
The following command should execute without error:
node --eval 'import { HTMLHint } from "htmlhint";'—or the documentation / changelog should explicitly mention that named ESM imports are no longer supported if this is an intentional breaking change.
The change broke things for some users so I reverted the change in v1.9.1.
For now if this issue effects you, you can you use v1.9.0 if that works for you.
Perhaps we'll reintroduce the following change in a semantic-release friendly v2.0.0 release:
"exports": {
".": {
"import": "./dist/core/core.js",
"require": "./dist/htmlhint.js"
},
"./package.json": "./package.json"
},