fix(unplugin-typegpu): expose built artifacts via $built$ exports#2622
fix(unplugin-typegpu): expose built artifacts via $built$ exports#2622mvanhorn wants to merge 3 commits into
Conversation
Add $built$ sibling entries to the dev exports map so consumers can opt into the compiled dist artifacts instead of the raw TypeScript source, mirroring the mechanism already used by the typegpu package.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds explicit “built” export subpaths for unplugin-typegpu so consumers can import precompiled JS + .d.ts from dist/ alongside the existing TS source exports.
Changes:
- Added
./$built$export entries for the main entry and each bundler integration (rollup, vite, webpack, etc.) - Each new built export maps
typestodist/*.d.tsand runtime todist/*.js
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "./$built$": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| }, |
| "./$built$": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| }, |
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — adds $built$ sibling entries to the dev exports map so consumers can opt into compiled artifacts, matching the mechanism already used by the typegpu package.
- Add
$built$export subpaths for all 11 entry points — each existing subpath (.,rollup,babel,bun,esbuild,farm,rolldown,rolldown-browser,rspack,vite,webpack) gains a matching<subpath>/$built$entry pointing at./dist/<name>.jsand./dist/<name>.d.ts. - Original source exports and
publishConfig.exportsuntouched — only the devexportsmap is extended.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
iwoplaza
left a comment
There was a problem hiding this comment.
The exports only include the ESM export, I'd like them to export both the ESM and CJS exports, just like the published package
Address @iwoplaza review: the built ($built$) export subpaths only provided a default (ESM) condition. Give each explicit import/require conditions so both ESM and CJS consumers resolve, matching the published package layout (dist/*.cjs, dist/*.d.cts alongside dist/*.js, dist/*.d.ts).
|
Done in f201454 - each |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the new commit revises the dev $built$ exports to use nested import/require conditions, addressing the prior reviewer feedback that only ESM was exposed.
- Update
$built$exports to support both ESM and CJS — every$built$subpath now resolves ESM to./dist/<name>.js+./dist/<name>.d.tsand CJS to./dist/<name>.cjs+./dist/<name>.d.cts, matching the publishedpublishConfig.exportslayout. - Preserve source exports and publish config — the existing
./src/*.tsdev entries and the publishedpublishConfig.exportsmap remain unchanged.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the latest commit adds a catch-all default condition to every $built$ dev export and a clarifying comment in the bundler config.
- Added
defaultfallback to each$built$entry — after the ESM and CJS conditions, every subpath now mapsdefaultto./dist/<name>.js. - Added a workspace-only marker comment in
tsdown.config.ts— explains that$built$is replaced before publish.
Kimi K2 (free via Pullfrog for OSS) | 𝕏

Summary
Adds
$built$sibling entries to the devexportsmap inpackages/unplugin-typegpu/package.jsonso consumers can opt into the compileddist/*.jsartifacts instead of the raw TypeScript source. Every existing subpath (.,rollup,babel,bun,esbuild,farm,rolldown,rolldown-browser,rspack,vite,webpack) gains a matching<subpath>/$built$entry resolving to./dist/<name>.js(and./dist/<name>.d.tsfor types). The original./src/*.tsentries are left untouched, andpublishConfig.exportsis unchanged.This mirrors the exact mechanism already used by the sibling
typegpupackage, which exposes$built$variants of each export pointing at its compileddistoutput.Why this matters
Today the dev
exportsmap points every subpath directly at./src/*.ts. When the package is consumed outside the dev/monorepo resolution (or when a consumer simply wants the compiled output), there is no way to opt into the built artifacts, so the raw.tssource is imported. Issue #2605 requests exactly this, and the maintainer confirmed the direction:Testing
package.jsonremains valid JSON.pnpm --filter unplugin-typegpu build(tsdown) produces every referenceddistfile; no$built$entry points at a non-existent artifact (all 11 subpaths cross-checked against the tsdown entry list).require('unplugin-typegpu/babel/$built$')resolves to the compiled./dist/babel.js.pnpm --filter unplugin-typegpu test:typespasses;oxlintandoxfmt --checkreport no issues on the changed file.Fixes #2605