YPE-1911: Fix imports in strict ESM runtimes like Deno#206
Conversation
Use tsup to produce proper index.js (ESM) and index.cjs (CJS) bundles instead of loose tsc output. Fixes imports in strict ESM runtimes like Deno that don't support Node-specific module resolution
🦋 Changeset detectedLatest commit: b19f943 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Greptile SummaryThis PR migrates Confidence Score: 5/5Safe to merge — the change is a well-scoped bundler migration with no runtime logic changes. All remaining findings are P2 style suggestions. The core fix (correct CJS/ESM split) is sound and consistent with the existing pattern in packages/core and packages/ui. Unified versioning is maintained via the changeset. packages/hooks/package.json — consider adding explicit React externals to the tsup invocations. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[src/index.ts] --> B{pnpm build}
B --> C[build:js\ntsup --format cjs,esm]
B --> D[build:types\ntsc -p tsconfig.build.json]
C --> E[dist/index.js\nESM bundle]
C --> F[dist/index.cjs\nCJS bundle]
D --> G[dist/index.d.ts\nType declarations]
D --> H[dist/index.d.ts.map\nDeclaration maps]
E --> I["exports.import / module field"]
F --> J["exports.require / main field"]
G --> K["exports.types / types field"]
L[pnpm dev] --> M[tsup --format cjs,esm --watch --dts]
M --> E
M --> F
M --> N[dist/index.d.ts\ntsup-bundled declarations]
Reviews (2): Last reviewed commit: "fix(hooks): emit type declarations durin..." | Re-trigger Greptile |
Add --dts flag to tsup watch command so consuming workspace packages get live type updates during local development. Amp-Thread-ID: https://ampcode.com/threads/T-019d303c-619e-76fe-870a-8df84da40419 Co-authored-by: Amp <amp@ampcode.com>
|
Hey @jaredhightower-youversion can you review this? These changes will allow people to use the React hooks and React UI SDK's in strict ESM runtimes, like Deno |
https://lifechurch.atlassian.net/browse/YPE-1911
Use tsup to produce proper index.js (ESM) and index.cjs (CJS) bundles instead of loose tsc output. Fixes imports in strict ESM runtimes like Deno that don't support Node-specific module resolution