Skip to content

Nano 12 - make the library ESM-only. Exchange all "require"s for "import"s. - #355

Open
glynnbird wants to merge 3 commits into
mainfrom
esm
Open

glynnbird wants to merge 3 commits into
mainfrom
esm

Conversation

@glynnbird

@glynnbird glynnbird commented Sep 10, 2025 •

Copy link
Copy Markdown
Contributor

Overview

Nano 12.

  • Making the library ESM-first - remove any "require" use and replace with equivalent "import".
  • Update to version 12.
  • Remove a bunch of legacy Nano code that dates back to the request/axios days. It's a bit simpler to read now with the "relax" method making the request and handling the response.
  • The ..AsStream variants of the functions are now "async" - i.e. they return a Promise which resolves to a stream, rather than synchronously returning a dummy stream as before. This makes the code easier to use when errors occur (the Promise rejects), more consistent across the code-base and easier to maintain - but is a breaking change.
  • Use rolldown to build CommonJS and ESM variants of the code. The exports & main keys in package.json make it such that the package "just works" for both CJS and ESM code.
  • Use an npm prepublishOnly script to ensure that the transpiled artifacts are generated during an npm publish event, but are gitignored from the repo.

Testing recommendations

All the tests have changed in the require-->import sense, but are functionally identical.

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;
  • No AI used in the formation of the PR.

- Convert Nano code to use esm - eliminate all instances of require.
- All ...AsStream functions are now async.

added rolldown as dev dependency
@glynnbird
glynnbird marked this pull request as ready for review November 4, 2026 12:54
@glynnbird
glynnbird requested a review from janl November 4, 2026 14:32
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.

1 participant