Skip to content

Add types and exports to package.json#1857

Open
coliff wants to merge 1 commit intomainfrom
dev/coliff/add-exports-package-json
Open

Add types and exports to package.json#1857
coliff wants to merge 1 commit intomainfrom
dev/coliff/add-exports-package-json

Conversation

@coliff
Copy link
Copy Markdown
Member

@coliff coliff commented Apr 19, 2026

Add TypeScript declaration and an explicit exports map. Adds a top-level "types" pointing to dist/core/core.d.ts and an "exports" field mapping the package root to types/import/require paths and exposing ./package.json. This clarifies ESM/CJS entry points and improves TypeScript and module resolution for consumers.

Copilot AI review requested due to automatic review settings April 19, 2026 07:58
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the package.json file to include TypeScript type definitions and modern exports mapping for the library. A critical issue was identified regarding a Dual Package Hazard, as the current exports configuration points the import and require conditions to different files, which could lead to multiple singleton instances of the library; a suggestion was provided to unify the entry point to maintain a single shared state.

Comment thread package.json
Copy link
Copy Markdown
Contributor

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 updates the published package entrypoints to improve consumer module/type resolution by adding a TypeScript declaration entry and an explicit exports map.

Changes:

  • Add a top-level types entry pointing to the package’s declaration file.
  • Add an exports map defining conditional import/require/types resolution for the package root.
  • Expose ./package.json via exports for tooling compatibility.

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

Comment thread package.json Outdated
Comment thread package.json Outdated
Comment thread package.json
@cloudflare-workers-and-pages

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

@coliff
Copy link
Copy Markdown
Member Author

coliff commented Apr 19, 2026

@sangafabrice @sebastianjnuwu
Sorry to bother you but I would greatly appreciate your feedback on this PR.
This would be released as a v2.0.0.

Add TypeScript declaration and an explicit exports map. Adds a top-level "types" pointing to dist/core/core.d.ts and an "exports" field mapping the package root to types/import/require paths and exposing ./package.json. This clarifies ESM/CJS entry points and improves TypeScript and module resolution for consumers.

Point package import export to dist/htmlhint.js

Update package.json exports: change the 'import' entry from './dist/core/core.js' to './dist/htmlhint.js'. This aligns the ESM import entry with the CommonJS 'require' entry and ensures consumers import the intended bundled entry point.

Point package import export to dist/htmlhint.js

Update package.json exports: change the 'import' entry from './dist/core/core.js' to './dist/htmlhint.js'. This aligns the ESM import entry with the CommonJS 'require' entry and ensures consumers import the intended bundled entry point.

Document ESM usage and bump version to 2.0.0-beta-1

Update README to clarify programmatic usage for both ESM and CommonJS consumers, adding an ESM example that imports the default export (htmlhint) and extracts HTMLHint. Also bump package.json and package-lock.json version from 1.9.2 to 2.0.0-beta-1.

Document ESM usage and bump version to 2.0.0-beta-1

Update README to clarify programmatic usage for both ESM and CommonJS consumers, adding an ESM example that imports the default export (htmlhint) and extracts HTMLHint. Also bump package.json and package-lock.json version from 1.9.2 to 2.0.0-beta-1.
@coliff coliff force-pushed the dev/coliff/add-exports-package-json branch from e37b5d5 to c4edc1b Compare April 19, 2026 08:38
@coliff coliff requested a review from Copilot April 19, 2026 08:39

This comment was marked as resolved.

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