Skip to content

✨ feat: expose package.json in exports field#640

Merged
CristhianF7 merged 1 commit into
mainfrom
feat/expose-package-json-export
May 12, 2026
Merged

✨ feat: expose package.json in exports field#640
CristhianF7 merged 1 commit into
mainfrom
feat/expose-package-json-export

Conversation

@CristhianF7
Copy link
Copy Markdown
Contributor

Summary

Adds "./package.json": "./package.json" to the exports map in package.json so consumers can read the package version at runtime/build time via:

```ts
import { version } from '@konstructio/ui/package.json';
```

Same pattern is used by react, react-dom, react-router-dom, @tanstack/react-query and most other libraries that ship with a restricted exports field.

Motivation

A Module Federation host that registers @konstructio/ui as a shared singleton needs the installed version string to pass to createInstance({ shared: { ... } }). Without this exports entry the import fails with ERR_PACKAGE_PATH_NOT_EXPORTED, and the only workaround today is to hardcode the version constant alongside the bump — fragile and easy to drift.

This came up while wiring @konstructio/ui as a host-provided singleton in the Civo dashboard's micro-frontend setup; the host can now dedupe a ~2 MB UI library bundle per MF visit, but to do so it needs to advertise the version it provides.

Impact

  • Bundle size: no change. The exports map only describes what paths are reachable; nothing new is bundled.
  • Breaking changes: none. This is strictly additive.
  • TypeScript: works out of the box for projects with resolveJsonModule: true (the default for most modern setups).

Test plan

  • bun install succeeds
  • Pre-commit hook (lint + type-check + tests) passes
  • CI passes
  • After merge: verify import { version } from '@konstructio/ui/package.json' resolves in a downstream project

Related

Used by Civo dashboard host: https://git.civo.com/civo/dashboard/dashboard-manager/-/merge_requests/75

Allow consumers to read the package version at runtime/build time via
`import { version } from '@konstructio/ui/package.json'`, matching the
pattern used by react, react-router-dom and other libraries that ship
with restricted `exports`.

This unblocks Module Federation host shells that want to register
@konstructio/ui as a shared singleton — the host needs the installed
version string to pass to `createInstance({ shared: { ... } })`, and
without this entry the deep import fails with ERR_PACKAGE_PATH_NOT_EXPORTED.
@CristhianF7 CristhianF7 merged commit 550d256 into main May 12, 2026
1 check passed
@CristhianF7 CristhianF7 deleted the feat/expose-package-json-export branch May 12, 2026 16:15
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