feat(build): add CommonJS build output and package entrypoints (#156) - #419
Open
vihaan-vijay wants to merge 1 commit into
Open
feat(build): add CommonJS build output and package entrypoints (#156)#419vihaan-vijay wants to merge 1 commit into
vihaan-vijay wants to merge 1 commit into
Conversation
vihaan-vijay
requested review from
AHB,
Billlynch,
andreas-karlsson,
fabriziodemaria,
mfranberg,
nicklasl,
sam-cook and
vahidlazio
as code owners
July 27, 2026 18:31
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.
Summary
Fixes #156
This PR adds dual-module distribution support by adding CommonJS (CJS) package entrypoints and conditional exports alongside the existing ES Modules (ESM) build outputs across
@spotify-confidence/sdkand related workspace packages.Problem
Projects relying on CommonJS
require()syntax or TypeScript tooling running with default CommonJS settings (e.g.ts-node) encounteredERR_PACKAGE_PATH_NOT_EXPORTEDerrors because:package.jsonmanifest lacked top-level"main","module", and"types"properties."exports"configuration map inpackage.jsondid not define a"require"conditional export pointing to CommonJS build artifacts.Changes Made
yarn.config.cjs&package.json):yarn.config.cjsto enforce"main","module","types", and"exports"invariants across workspace packages."main": "dist/index.cjs","module": "dist/index.mjs", and"types": "dist/index.d.ts"."require": "./dist/index.cjs"to the"exports"condition map.rollup.base.mjs):\) to forward slashes (/) innormalizePathso Rollup bundling executes cleanly across Windows and POSIX environments.packages/sdk/src/cjs.test.ts):@spotify-confidence/sdkCommonJS artifacts can be required and cleanly expose exported interfaces (Confidence,Value, etc.).Verification
yarn test— all 16 test suites (175 tests) passed cleanly.require('@spotify-confidence/sdk')in Node.js runtime without errors.import { Confidence } from '@spotify-confidence/sdk'in ESM runtime without errors.yarn constraintspasses without constraint errors.