✨ feat: expose package.json in exports field#640
Merged
Conversation
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.
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
Adds
"./package.json": "./package.json"to theexportsmap inpackage.jsonso 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-queryand most other libraries that ship with a restrictedexportsfield.Motivation
A Module Federation host that registers
@konstructio/uias a shared singleton needs the installed version string to pass tocreateInstance({ shared: { ... } }). Without this exports entry the import fails withERR_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/uias 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
resolveJsonModule: true(the default for most modern setups).Test plan
bun installsucceedsimport { version } from '@konstructio/ui/package.json'resolves in a downstream projectRelated
Used by Civo dashboard host: https://git.civo.com/civo/dashboard/dashboard-manager/-/merge_requests/75