fix(core): publish a built @getworkbench/core/ui entrypoint - #50
Open
omarzeineddine-ai wants to merge 5 commits into
Open
fix(core): publish a built @getworkbench/core/ui entrypoint#50omarzeineddine-ai wants to merge 5 commits into
omarzeineddine-ai wants to merge 5 commits into
Conversation
The desktop app relies on building the dashboard from source (its alias map already reaches into packages/core/src for the UI's internal @/ imports). Make that source resolution explicit instead of depending on the package export map pointing at src, so the export map can move to built dist files for published consumers.
TanStack's createRouter touches window.history, so building the router at module scope crashed any non-browser import of the embeddable @getworkbench/core/ui entry (SSR frameworks evaluate the module on the server before rendering client-side). Defer creation to first render.
The ./ui and ./ui/styles.css exports pointed at src/ files, but only
dist/ is in the published files list, so the README-documented
'import { Dashboard } from "@getworkbench/core/ui"' could never
resolve from the npm tarball.
Build the entrypoint into the package instead:
- vite.lib.config.ts bundles src/ui/index.ts to dist/ui-lib/index.js
(ESM) plus the compiled Tailwind stylesheet dist/ui-lib/styles.css.
Only react/react-dom are external — the Dashboard brings its own
router and query client — so embedding apps just need React, declared
as optional peer dependencies to keep server-only consumers
warning-free.
- tsup gains a dts-only entry for dist/ui-lib/index.d.ts. The public
createAppRouter re-export is typed opaquely so the declarations don't
reference @tanstack/react-router or zod, which are bundled rather
than installed by consumers.
- The export map now points ./ui and ./ui/styles.css at the built
files.
Closes pontusab#32
Regression test for pontusab#32: every package.json export target must point into dist/, the only code directory included in the published tarball.
|
@omarzeineddine-ai is attempting to deploy a commit to the Pontus Abrahamsson's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
Closes #32
The
./uiand./ui/styles.cssexports point at./src/ui/...files, but onlydistis in the package'sfileslist — so the README-documentedimport { Dashboard } from "@getworkbench/core/ui"can never resolve from the npm tarball:Even if
srcwere published, the entry wouldn't be consumable: the UI source uses package-internal@/aliases and a raw Tailwind stylesheet that a consumer's bundler can't process.Solution
Ship the entrypoint built, per option 2 in the issue:
vite.lib.config.tsbundlessrc/ui/index.ts→dist/ui-lib/index.js(ESM) plus the compiled Tailwind stylesheetdist/ui-lib/styles.css. Onlyreact/react-domare external — theDashboardbrings its own router and query client — so embedding apps just need React, declared as optional peer dependencies (server-only consumers stay warning-free).dist/ui-lib/index.d.ts. The publiccreateAppRouterre-export is typed opaquely so the shipped declarations don't reference@tanstack/react-router/zod(bundled, not installed by consumers); the d.ts imports nothing butreact/jsx-runtimeand typechecks underskipLibCheck: false../uiand./ui/styles.cssat the built files.app.tsx: TanStack'screateRoutertoucheswindow.historyat module scope, which crashed any non-browser import of the entry — including the issue's exactnode -erepro and SSR frameworks like TanStack Start. The router is now created on first render.src.package.jsonmust point intodist/, the only published code directory.Verification
Against a real
npm packtarball installed into a fresh consumer app:node -e "import('@getworkbench/core/ui')"(the issue's repro) succeeds; all documented exports present;./ui/styles.cssresolves..tsxrendering<Dashboard />typechecks withskipLibCheck: false.dist/ui-lib/{index.js,index.d.ts,styles.css}and nosrc/files.bun test(18 pass),tsc --noEmit, biome on changed files, full core build, and the desktop app's build + typecheck all pass.Note: the lib bundle is ~480 KB gzipped since the Dashboard is self-contained (router, query client, charts, flow renderer). Only apps importing
/uipay that cost.