Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/version-export-from-manifest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'rowkit': patch
'@rowkit/tokens': patch
---

Fix the exported `version` constant reporting `0.0.0` on a released build.

Both packages exported a hand-written literal that a test pinned against
`package.json`. Changesets bumps the manifest and nothing updated the literal,
so the first release failed its own test — and had it passed, `version` would
have reported `0.0.0` from a `0.1.0` package.

It is now read from `package.json` directly, so the two cannot disagree. Rollup
tree-shakes the import down to the single string; nothing else from the manifest
ships.
5 changes: 5 additions & 0 deletions packages/tokens/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { describe, expect, it } from 'vitest'
import pkg from '../package.json' with { type: 'json' }
import { version } from './index'

/**
* The version is now read from `package.json`, so drift is impossible by
* construction — what this still catches is the import breaking, which would
* leave the export `undefined` while the manifest keeps its version.
*/
describe('@rowkit/tokens', () => {
it('exports a version matching package.json', () => {
expect(version).toBe(pkg.version)
Expand Down
8 changes: 6 additions & 2 deletions packages/tokens/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* ```
*/

import { version as pkgVersion } from '../package.json' with { type: 'json' }
import {
colorPrimitives,
danger,
Expand Down Expand Up @@ -114,6 +115,9 @@ export type Tokens = typeof tokens
/**
* The `@rowkit/tokens` version this build was produced from.
*
* Kept in sync with `package.json` by `index.test.ts`.
* Read from `package.json` rather than written out. A literal here went stale
* the moment Changesets bumped the manifest — it edits `package.json` and
* nothing was updating the constant, so the first release broke its own test.
* Rollup tree-shakes the JSON down to this one string, so nothing else ships.
*/
export const version = '0.0.0'
export const version: string = pkgVersion
5 changes: 5 additions & 0 deletions packages/ui/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { describe, expect, it } from 'vitest'
import pkg from '../package.json' with { type: 'json' }
import { version } from './index'

/**
* The version is now read from `package.json`, so drift is impossible by
* construction — what this still catches is the import breaking, which would
* leave the export `undefined` while the manifest keeps its version.
*/
describe('rowkit', () => {
it('exports a version matching package.json', () => {
expect(version).toBe(pkg.version)
Expand Down
9 changes: 7 additions & 2 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { version as pkgVersion } from '../package.json' with { type: 'json' }

export * from './components/Badge'
export * from './components/Button'
export * from './components/DataTable'
Expand Down Expand Up @@ -26,6 +28,9 @@ export type {
/**
* The `rowkit` version this build was produced from.
*
* Kept in sync with `package.json` by `index.test.ts`.
* Read from `package.json` rather than written out. A literal here went stale
* the moment Changesets bumped the manifest — it edits `package.json` and
* nothing was updating the constant, so the first release broke its own test.
* Rollup tree-shakes the JSON down to this one string, so nothing else ships.
*/
export const version = '0.0.0'
export const version: string = pkgVersion