Merged
Conversation
Add dual CJS/ESM build to enable Turbopack compatibility. - Add tsconfig.esm.json for ES module build - Update tsconfig.json to output to dist/cjs - Add conditional exports and module field in package.json - Fix lodash import syntax for ESM compatibility SCAAS-2084
There was a problem hiding this comment.
Pull request overview
This PR adds dual CJS/ESM build support to @bitgo/sdk-core, following the established pattern from @bitgo/utxo-core. This enables compatibility with Next.js Turbopack by providing proper ESM exports while maintaining backward compatibility with existing CommonJS consumers. The changes address an issue where Turbopack fails to load WASM modules from @bitgo/wasm-utxo due to CJS-only exports.
Key Changes:
- Implemented dual build system with separate TypeScript configurations for CJS (node16) and ESM (ES2020) outputs
- Updated package.json with conditional exports, module, and browser fields for proper module resolution
- Fixed lodash import syntax from TypeScript-specific
requireto standard ES6importfor ESM compatibility
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
modules/sdk-core/tsconfig.json |
Updated CJS build to output to dist/cjs with module: node16 and moduleResolution: node16 |
modules/sdk-core/tsconfig.esm.json |
New ESM build configuration with module: ES2020, moduleResolution: bundler, and output to dist/esm |
modules/sdk-core/src/bitgo/tss/eddsa/eddsa.ts |
Changed lodash import from import _ = require('lodash') to import _ from 'lodash' for ESM compatibility |
modules/sdk-core/package.json |
Added dual build scripts, conditional exports, and updated entry points to support both CJS and ESM consumers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
OttoAllmendinger
approved these changes
Dec 3, 2025
bitgoAaron
approved these changes
Dec 3, 2025
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.
Ticket: SCAAS-2084
Summary
@bitgo/sdk-coreto enable Turbopack compatibility in Next.js(bitgo-ui)@bitgo/utxo-core(commit36c3cd47)@bitgo/wasm-utxodue to CJS-only exportsChanges
module: ES2020andmoduleResolution: bundlerdist/cjswithmodule: node16module,browser, and conditionalexportsfields for dual buildBackward Compatibility
These changes are backward compatible:
require('@bitgo/sdk-core')still works (routes to CJS)import from '@bitgo/sdk-core'now uses ESM