Skip to content

Modernize for Node.js 22+ — ESM, async/await, ya-disk v5 - #342

Merged
RomiC merged 6 commits into
mainfrom
feat/341-node22-modernize
Aug 8, 2026
Merged

Modernize for Node.js 22+ — ESM, async/await, ya-disk v5#342
RomiC merged 6 commits into
mainfrom
feat/341-node22-modernize

Conversation

@RomiC

@RomiC RomiC commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Closes #341.

What changed

Breaking: Promise-based API

download() and upload() now return Promises instead of taking callbacks:

Before:

download(token, file, (stream) => stream.pipe(writeStream), console.error);
upload(token, file, true, (stream) => file.pipe(stream), console.error);

After:

const stream = await download(token, file);
stream.pipe(writeStream);

const stream = await upload(token, file, true);
file.pipe(stream);

ESM with CJS backward compatibility

  • Source converted to ESM with named exports, node: prefix, and .js extensions
  • CJS bundle generated via esbuild at dist/index.cjs
  • Conditional exports in package.jsonrequire('ya-disk-stream') works seamlessly

Upgraded to ya-disk v5.0.1

  • Async/await API, dual ESM/CJS, Node ≥ 22

Modernized internals

  • Replaced deprecated url.parse() with direct URL strings passed to https.request()
  • Used Promise.withResolvers() in integration tests
  • Removed stale .eslintignore

RomiC added 5 commits August 8, 2026 12:14
- Replaced onReady/onError callbacks with async/await in download, upload, and followRedirect
- Updated unit tests to mock fetch and https.request instead of ya-disk internals
- Updated integration test helpers for ya-disk v5 async API
- Migrated all source, specs, and examples to ESM with named exports
- Added esbuild to generate CJS bundle at dist/index.cjs
- Added conditional exports for seamless require/import support
- Used node: prefix for all built-in modules
@RomiC
RomiC force-pushed the feat/341-node22-modernize branch from 4b91fc9 to 2adbd37 Compare August 8, 2026 14:03
@coveralls

coveralls commented Aug 8, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 100.0%feat/341-node22-modernize into main. No base build found for main.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown

Greptile Summary

The PR modernizes the package for Node.js 22 by converting the API to Promises and ESM, adding a generated CommonJS bundle, upgrading ya-disk, and updating examples and tests. The previously reported ESM failure in the upload example is fixed by deriving __dirname from import.meta.url.

Confidence Score: 5/5

The PR appears safe to merge because the previously reported upload-example failure has been fixed and no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
examples/upload.js Defines an ESM-compatible __dirname using fileURLToPath(import.meta.url), resolving the previous runtime failure.
package.json Declares ESM packaging, conditional CommonJS exports, Node.js 22 support, and the build process.
index.js Replaces CommonJS exports with ESM named exports.
lib/download.js Converts download-link acquisition and stream creation to a Promise-based API.
lib/upload.js Converts upload-link acquisition and writable request creation to a Promise-based API.
lib/followRedirect.js Converts redirect handling to a Promise and rejects unexpected responses or request errors.

Reviews (2): Last reviewed commit: "fixup! Feat: [#341] Convert to ESM with ..." | Re-trigger Greptile

Comment thread examples/upload.js
@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

@RomiC RomiC self-assigned this Aug 8, 2026
@RomiC
RomiC merged commit e20caf9 into main Aug 8, 2026
8 checks passed
@RomiC
RomiC deleted the feat/341-node22-modernize branch August 8, 2026 14:15
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.

Modernize library for Node.js 22+ — ESM, async/await, ya-disk v5, and more

2 participants