Convert to native ESM (vitest + oxc toolchain)#18
Merged
Conversation
Convert @hapi/formula from CommonJS to native ESM and replace the
@hapi/lab + @hapi/code + @hapi/eslint-plugin toolchain with vitest +
@vitest/coverage-v8 and oxlint + oxfmt (via @hapi/oxc-plugin).
- "type": "module"; single "." export with a co-located lib/index.d.ts;
ship API.md + README.md in the published package
- drop the internals namespace (module scope is already private)
- engines.node >= 22; CI on the min-node-22-hapi-21 reusable workflow
ESM-only — CommonJS require('@hapi/formula') no longer resolves.
d0568dc to
0a4ee15
Compare
Pure rename (no content change) so the move is tracked as a rename; reference fixups follow in the next commit.
package.json exports/types -> src/index.mjs + src/index.d.mts; vitest coverage include -> src/**; test imports -> ../src/index.mjs; b64 also updates index.mjs internal re-exports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"type": "module", single.export with a co-locatedlib/index.d.ts).@hapi/lab+@hapi/code+@hapi/eslint-plugin→vitest+@vitest/coverage-v8+oxlint+oxfmt(shared@hapi/oxc-pluginconfig).engines.nodeto>= 22; move CI to themin-node-22-hapi-21reusable workflow.What this solves
Part of the hapi ecosystem ESM migration —
formulais a Wave-1 leaf (no internal@hapi/*deps). Follows thebourneJS-ESM archetype: source stays JS, typed by a hand-written.d.ts, 100% coverage preserved under vitest.API.md+README.mdnow ship in the tarball so the installed package carries its own docs.ESM-only: this drops the CommonJS build, a breaking change for any
require()consumer. The version bump is left to the release process.