Skip to content

Convert to native ESM (vitest + oxc toolchain)#18

Merged
Marsup merged 7 commits into
hapijs:masterfrom
damusix:esm-conversion
Jul 1, 2026
Merged

Convert to native ESM (vitest + oxc toolchain)#18
Marsup merged 7 commits into
hapijs:masterfrom
damusix:esm-conversion

Conversation

@damusix

@damusix damusix commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Convert from CommonJS to native ESM ("type": "module", single . export with a co-located lib/index.d.ts).
  • Swap the test/lint toolchain: @hapi/lab + @hapi/code + @hapi/eslint-pluginvitest + @vitest/coverage-v8 + oxlint + oxfmt (shared @hapi/oxc-plugin config).
  • Raise engines.node to >= 22; move CI to the min-node-22-hapi-21 reusable workflow.

What this solves

Part of the hapi ecosystem ESM migration — formula is a Wave-1 leaf (no internal @hapi/* deps). Follows the bourne JS-ESM archetype: source stays JS, typed by a hand-written .d.ts, 100% coverage preserved under vitest. API.md + README.md now 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.

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.
@damusix damusix force-pushed the esm-conversion branch 2 times, most recently from d0568dc to 0a4ee15 Compare June 27, 2026 03:42
damusix added 2 commits June 26, 2026 23:48
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.
@Marsup Marsup added this to the 4.0.0 milestone Jul 1, 2026
@Marsup Marsup added the breaking changes Change that can breaking existing code label Jul 1, 2026
@Marsup Marsup self-assigned this Jul 1, 2026
@Marsup Marsup merged commit f374bd2 into hapijs:master Jul 1, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking changes Change that can breaking existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants