Repository navigation
Fix Optional Dependencies & CJS - #63
Merged
Merged
Conversation
@tanstack/react-table was declared an optional peer dependency but was
never optional. src/extra.ts re-exported DataTable, and Rollup resolves
re-exported modules whether or not their exports are used, so every
consumer of `baukasten-ui` or `baukasten-ui/extra` had to have the package
installed. Without it the production build failed with MISSING_EXPORT, dev
served a stub that threw on page load, and tsc only passed because
skipLibCheck hid the eight unresolved imports in the .d.ts.
DataTable now lives at `baukasten-ui/data-table` and is no longer exported
from `extra` or the root barrel. Nothing reachable from `.`, `./core` or
`./extra` touches react-table, so consumers who skip DataTable neither
install nor bundle it.
Measured on a consumer outside the workspace with react-table absent: root,
/core and /extra all build with zero react-table symbols. `{ Avatar }` from
the root entry previously shipped 186,365 bytes gzipped including the whole
table library; it is now 157,496 with none of it. `{ Tabs }` went from
182,825 to 138,690.
Also updates the two LogTable examples, the website DataTable page and its
five code samples, and the write-baukasten skill; adds @tanstack/react-table
to the vscode example and website, which were relying on hoisting.
BREAKING CHANGE: import DataTable from 'baukasten-ui/data-table' rather than
'baukasten-ui' or 'baukasten-ui/extra'. The helpers and types move with it:
createSelectColumn, useDataTable, useDataTableData, applyDataTransaction,
mergeTransactions, ColumnDef, SortingState, PaginationState,
RowSelectionState, ColumnResizeMode and Row.
…built `exports` declared "./styles" pointing at ./dist/styles.mjs and ./dist/styles.js, and CLAUDE.md listed it as a public entry point, but vite.config.ts has no `styles` entry and never has — none of the twelve commits touching that file ever added one, and the subpath has been in `exports` since the initial commit. Importing it failed with ERR_MODULE_NOT_FOUND in Node and "Rollup failed to resolve import" in a bundler. Unlike the CJS entry bug this broke every consumer, not just `require`; it went unnoticed because nothing in the repo imports it. Removing rather than building it: src/core.ts already does `export * from './styles'`, so all 27 value exports and both types (Size, SizeConfig) are available from baukasten-ui/core. Adding the entry would have published a second import path to the same tokens and a second copy of them in consumer bundles. The path now fails with ERR_PACKAGE_PATH_NOT_EXPORTED, which names the real problem instead of implying a missing build artifact.
package.json sets "type": "module", which makes Node treat every .js file in
the package as ESM. The CJS build was named .js, so `require('baukasten-ui')`
loaded a CommonJS file, parsed it as ESM, and died on its first statement
with "ReferenceError: exports is not defined". The same applied to /core,
/extra and /data-table.
Vite already named the shared chunks .cjs itself; only the entry files go
through the fileName callback, which is why the output looked correct. The
build has been broken this way since the cjs format was added in 03376c8 —
no commit has ever emitted a .cjs entry or pointed a require condition at one.
Repoints the four require conditions and the legacy `main` field to match.
Verified from a plain CommonJS package outside the workspace: all four
entries now load (root 92 exports, /core 63, /extra 29, /data-table 6), and
ESM imports still resolve.
Known gap: only .d.ts is emitted, no .d.cts, so a CJS consumer on
moduleResolution node16 gets working runtime with ESM-typed declarations
(TS1479). moduleResolution bundler is unaffected. Tracked separately.
The CI format check failed on three files edited earlier here. Both failures are knock-on effects of content edits: rewriting the Core/Extra criteria row in CLAUDE.md and removing the DataTable row from the SKILL.md component table changed the widest cell in each table, so Prettier re-pads every row to the new width. The third is Prettier normalising *not* to _not_ in datatable.md. Whitespace only apart from that emphasis marker — `git diff -w` reports zero content changes in either table. Produced by `npm run format`; `npm run format:check` now passes.
The vscode-db-explorer example landed on main after this branch was cut, so it still imported DataTable from the root barrel and relied on a hoisted @tanstack/react-table. Both break once DataTable moves to its own entry point.
praisethemoon
force-pushed
the
sch/optional-deps-fix
branch
from
September 24, 2026 08:44
25f5d76 to
49e7148
Compare
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.
Fixes #58:
@tanstack/react-tablewas declared an optional peer dependency but never was.src/extra.tsre-exportedDataTable, and Rollup resolves re-exported moduleswhether or not their exports are used — so every consumer of
baukasten-uiorbaukasten-ui/extrahad to have it installed. Without it, production buildsfailed with
MISSING_EXPORT, dev served a stub that threw on page load, andtsconly passed becauseskipLibCheckhid the unresolved imports.DataTable now has its own entry point and is no longer in the root or
extrabarrels.
Breaking Changes
Moving with it:
createSelectColumn,useDataTable,useDataTableData,applyDataTransaction,mergeTransactions, and the typesColumnDef,SortingState,PaginationState,RowSelectionState,ColumnResizeMode,Row. Examples, the website DataTable page and thewrite-baukastenskill areupdated in this PR.
Also fixed
Two unrelated packaging bugs found while verifying, both present since the
initial commit:
baukasten-ui/stylesnever existed. Declared inexportsand documentedas a public entry point, but there was no
stylesbuild entry, so it failedfor every consumer. Removed rather than built —
baukasten-ui/corealreadyre-exports all of it.
require()was broken on every entry."type": "module"plus CJS entriesnamed
.jsmeant Node parsed the CommonJS build as ESM and died withReferenceError: exports is not defined. Entries now emit.cjs.Risk level: