Skip to content

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

Draft
glynnbird wants to merge 2 commits into
mainfrom
esm
Draft

Nano 12 - make the library ESM-only. Exchange all "require"s for "import"s.#355
glynnbird wants to merge 2 commits into
mainfrom
esm

Conversation

@glynnbird

@glynnbird glynnbird commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Overview

Preparation work for Nano 12.

  • Making the library ESM-only - remove any "require" use and replace with equivalent "import".
  • version 12.
  • Update README code to eliminate "require".
  • 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 maintain, but is a breaking change.
  • Use rolldown to build CommonJS and ESM variants of the code. The module & 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;

a nicer way to load the package.json to get pkg.name & pkg.version

simplify Nano a bit. Removed some old code and made "relax" a simpler function. At the same time, i have made the ...AsStream functions "async" as they were a bit odd in that regard, returning synchronously.

added test coverage output and ensure 100% test coverage of lib/nano.js

findAsStream returns a Promise which resolves as a stream

fix basicauth test

fix basic auth test

rename .js to .mjs

added CSM & EJS build steps
show breaking changes in Nano 12 at the top of the readme
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