Skip to content

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

Draft
glynnbird wants to merge 3 commits into
mainfrom
esm
Draft

Nano 12 - make the library ESM-only. Exchange all "require"s for "import"s.#355
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.

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