Skip to content

refactor!: publish ESM only with vp pack - #904

Merged
fengmk2 merged 1 commit into
masterfrom
refactor/esm-vp-pack
Sep 15, 2026
Merged

fengmk2 merged 1 commit into
masterfrom
refactor/esm-vp-pack

Conversation

@fengmk2

@fengmk2 fengmk2 commented Sep 15, 2026

Copy link
Copy Markdown
Member

Replace tshy with vp pack to remove the separate ESM and CommonJS builds. The package now provides one ESM entry point with TypeScript declarations.

The build reads the version from package.json. This removes the need for a separate replacement script. Package exports, examples, and documentation now use ESM.

Summary by CodeRabbit

  • New Features

    • The package is now ESM-only and requires Node.js 22.19.0 or later.
    • User-Agent values now include the package version and current runtime details.
    • TypeScript request responses provide stronger, more accurate type information.
  • Documentation

    • Updated usage guidance and examples for ESM imports, file uploads, and import.meta.filename.
  • Bug Fixes

    • Corrected file-upload examples and tests to use the ESM-compatible paths and syntax.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b324e155-a515-4dc2-ab9b-5e4a693a5361

📥 Commits

Reviewing files that changed from the base of the PR and between aaf4a08 and 3ae3d97.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (33)
  • .gitignore
  • CLAUDE.md
  • README.md
  • examples/h2-other-side-closed-exit-0-fetch.mjs
  • examples/h2-other-side-closed-exit-0.mjs
  • examples/httpclient.mjs
  • examples/longruning.mjs
  • examples/search_github.mjs
  • examples/timing.mjs
  • package.json
  • scripts/replace_urllib_version.js
  • src/HttpClient.ts
  • test/cjs/index.js
  • test/cjs/package.json
  • test/esm/index.js
  • test/esm/package.json
  • test/fixtures/ts-cjs-es2021/hello.ts
  • test/fixtures/ts-cjs-es2021/package.json
  • test/fixtures/ts-cjs-es2021/tsconfig.json
  • test/fixtures/ts-esm/hello.ts
  • test/fixtures/ts-esm/package.json
  • test/fixtures/ts-esm/tsconfig.json
  • test/fixtures/ts/hello.ts
  • test/fixtures/ts/package.json
  • test/fixtures/ts/tsconfig.json
  • test/mts/package.json
  • test/mts/src/index.mts
  • test/mts/tsconfig.json
  • test/options.files.test.ts
  • test/options.headers.test.ts
  • test/user-agent.test.ts
  • tsconfig.json
  • vite.config.ts
💤 Files with no reviewable changes (13)
  • test/fixtures/ts-cjs-es2021/tsconfig.json
  • test/cjs/package.json
  • test/cjs/index.js
  • test/fixtures/ts/tsconfig.json
  • scripts/replace_urllib_version.js
  • test/esm/package.json
  • test/fixtures/ts-cjs-es2021/package.json
  • test/fixtures/ts-cjs-es2021/hello.ts
  • test/fixtures/ts/hello.ts
  • test/fixtures/ts/package.json
  • test/mts/package.json
  • .gitignore
  • test/fixtures/ts-esm/package.json

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The package migrated from tshy to Vite Plus and now publishes ESM-only output. Runtime version data comes from package.json. Tests, TypeScript fixtures, documentation, and examples now use the ESM package model.

Changes

ESM and Vite Plus migration

Layer / File(s) Summary
Package and build configuration
package.json, vite.config.ts, scripts/replace_urllib_version.js, .gitignore, CLAUDE.md, test/cjs/*, test/esm/package.json
Package exports and scripts now target ESM output from Vite Plus. The tshy dependencies, version-replacement script, CommonJS test, and obsolete fixture settings were removed.
Runtime version and integration validation
src/HttpClient.ts, test/esm/index.js, test/user-agent.test.ts, test/options.headers.test.ts, test/options.files.test.ts
VERSION now comes from package.json. Tests validate the exact User-Agent and use ESM fixture paths.
TypeScript fixture and type validation
test/fixtures/ts*, test/mts/*, tsconfig.json
Legacy CommonJS and TypeScript fixtures were removed. ESM imports and strict typed request checks were updated.
ESM documentation and examples
README.md, examples/*.mjs
Documentation and examples now use ESM imports, published-package imports, ESM file paths, and the stated Node.js requirement.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 3ae3d

No concrete merge-blocking issue remains in the ESM migration.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main changes: replacing the build process with vp pack and publishing an ESM-only package.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/esm-vp-pack

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/node-modules/urllib@904

commit: 3ae3d97

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.24%. Comparing base (aaf4a08) to head (3ae3d97).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #904   +/-   ##
=======================================
  Coverage   94.24%   94.24%           
=======================================
  Files          10       10           
  Lines         747      747           
  Branches      235      235           
=======================================
  Hits          704      704           
  Misses         40       40           
  Partials        3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fengmk2
fengmk2 marked this pull request as ready for review September 15, 2026 16:55
Copilot AI lite review requested due to automatic review settings September 15, 2026 16:55

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.

🟡 Changes recommended

JSON imports currently cause TypeScript typechecking to fail because resolveJsonModule is not enabled.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Refactors urllib to publish a single ESM package using vp pack, replacing the dual CJS/ESM build.

Changes:

  • Adds ESM bundling, declarations, sourcemaps, and updated exports.
  • Updates tests, fixtures, examples, and documentation.
  • Removes tshy, CommonJS tooling, and version-replacement logic.
File summaries
File Summary
vite.config.ts Configures ESM packaging and declarations.
tsconfig.json Updates excluded test paths.
test/user-agent.test.ts Validates the package-derived user agent.
test/options.headers.test.ts Uses the exported user-agent constant.
test/options.files.test.ts References the ESM fixture.
test/mts/tsconfig.json Configures strict ESM type checking.
test/mts/src/index.mts Tests generated ESM declarations.
test/mts/package.json Removes redundant metadata.
test/fixtures/ts/tsconfig.json Removes obsolete CommonJS fixture configuration.
test/fixtures/ts/package.json Removes obsolete fixture metadata.
test/fixtures/ts/hello.ts Removes the obsolete CommonJS fixture.
test/fixtures/ts-esm/tsconfig.json Updates ESM compiler settings.
test/fixtures/ts-esm/package.json Removes redundant metadata.
test/fixtures/ts-esm/hello.ts Updates ESM type-only imports.
test/fixtures/ts-cjs-es2021/tsconfig.json Removes obsolete CommonJS fixture configuration.
test/fixtures/ts-cjs-es2021/package.json Removes obsolete fixture metadata.
test/fixtures/ts-cjs-es2021/hello.ts Removes the obsolete CommonJS fixture.
test/esm/package.json Removes redundant ESM metadata.
test/esm/index.js Tests built ESM integration.
test/cjs/package.json Removes obsolete CommonJS metadata.
test/cjs/index.js Removes obsolete CommonJS integration coverage.
src/HttpClient.ts Reads the package version directly.
scripts/replace_urllib_version.js Removes obsolete version replacement logic.
README.md Documents ESM-only usage.
pnpm-lock.yaml Removes obsolete tshy dependencies.
package.json Defines ESM exports and build scripts.
examples/timing.mjs Migrates the example to ESM imports.
examples/search_github.mjs Migrates the example to ESM imports.
examples/longruning.mjs Migrates the example to ESM imports.
examples/httpclient.mjs Migrates the example to ESM imports.
examples/h2-other-side-closed-exit-0.mjs Migrates the example to ESM imports.
examples/h2-other-side-closed-exit-0-fetch.mjs Migrates the example to ESM imports.
CLAUDE.md Documents the updated build model.
.gitignore Removes obsolete fixture and build entries.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file
  • Files reviewed: 31/34 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/HttpClient.ts
// @ts-ignore
import undiciSymbols from 'undici/lib/core/symbols.js';

import pkg from '../package.json' with { type: 'json' };
Comment thread test/user-agent.test.ts

import { describe, it, beforeAll, afterAll } from 'vite-plus/test';

import pkg from '../package.json' with { type: 'json' };
@fengmk2
fengmk2 merged commit e372cd3 into master Sep 15, 2026
21 checks passed
@fengmk2
fengmk2 deleted the refactor/esm-vp-pack branch September 15, 2026 17:02
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