Skip to content

[optimize] support ESM exports of NPM#36

Merged
TechQuery merged 4 commits into
masterfrom
copilot/support-npm-standard-esm-export
Jul 1, 2026
Merged

[optimize] support ESM exports of NPM#36
TechQuery merged 4 commits into
masterfrom
copilot/support-npm-standard-esm-export

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

PR-36 PR-36 PR-36 Powered by Pull Request Badge

web-utility exposed the right symbols in source, but published package entry resolution still fell back to CommonJS for bare ESM consumers. That caused Deno npm: imports like changeMonth to fail at module instantiation time.

  • Package entrypoints

    • add a standard exports map for the root package
    • route ESM consumers to ./dist/index.mjs
    • keep CommonJS consumers on ./dist/index.js
    • preserve type resolution via ./dist/index.d.ts
  • ESM artifact naming

    • switch the declared ESM entry from dist/index.esm.js to dist/index.mjs
    • align published metadata with the actual runtime expectation of Node/Deno ESM loaders
  • Regression coverage

    • add a focused package-level test that locks the exported entrypoint contract in package.json
{
  "main": "dist/index.js",
  "module": "dist/index.mjs",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.js",
      "default": "./dist/index.js"
    }
  }
}

Copilot AI linked an issue Jul 1, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Support NPM standard ESM export configuration Add standard npm ESM exports for Deno/Node consumers Jul 1, 2026
Copilot AI requested a review from TechQuery July 1, 2026 12:15
@TechQuery TechQuery added the bug Something isn't working label Jul 1, 2026
@TechQuery TechQuery changed the title Add standard npm ESM exports for Deno/Node consumers [optimize] support ESM exports of NPM Jul 1, 2026
@TechQuery TechQuery marked this pull request as ready for review July 1, 2026 20:19
Copilot AI review requested due to automatic review settings July 1, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown

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 entrypoint metadata so ESM consumers (including Deno npm: imports) resolve to an ESM build (dist/index.mjs) instead of falling back to CommonJS, and adds a regression test to lock the entrypoint contract.

Changes:

  • Switch package.json "module" entry to dist/index.mjs and add an "exports" map routing import vs require to the correct artifacts.
  • Add a package-level Jest test asserting the expected package.json entrypoint/export fields.
  • Bump package version from 4.7.1 to 4.7.2.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
package.json Adds an exports map and updates the ESM entry to dist/index.mjs (plus version bump).
test/package.spec.ts Adds a regression test asserting the package entrypoint/export contract.

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

Comment thread test/package.spec.ts
@TechQuery TechQuery merged commit 04eba11 into master Jul 1, 2026
1 check passed
@TechQuery TechQuery deleted the copilot/support-npm-standard-esm-export branch July 1, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

支持 NPM 标准 ESM 导出配置

3 participants