Skip to content

Use tsdown to bundle into ESM and CJS exports#9

Open
colinhemphill wants to merge 2 commits into
mainfrom
ch_tsdown_bundle
Open

Use tsdown to bundle into ESM and CJS exports#9
colinhemphill wants to merge 2 commits into
mainfrom
ch_tsdown_bundle

Conversation

@colinhemphill

Copy link
Copy Markdown

Summary

The API client was compiled with tsc but not bundled in a way that it could be properly consumed by an application without transpiling the dependency. In a Next.js project this would result in the failure Error [ERR_MODULE_NOT_FOUND]: Cannot find module.

Solution

I've migrated the project to use tsdown which is the modern iteration on the deprecated tsup bundler. Allows us to build and export ESM and CJS bundles with very little config.

Testing

I installed the new version in one of our internal projects using npm link and the app builds without transpilation.

Comment thread package.json
{
"name": "@bitly/api-client",
"version": "0.0.2",
"version": "0.0.3",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be a breaking change in any way—do we think a patch version number is sufficient?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with either; we could go with 0.1.0 or 0.0.3; There are new API changes here but yes i don't think they are breaking.

@colinhemphill colinhemphill requested a review from jehiah June 22, 2026 21:45
@qodo-for-bitly

Copy link
Copy Markdown

CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: build

Failed stage: Run npm ci [❌]

Failed test name: ""

Failure summary:

The action failed during the dependency installation step npm ci with npm error code EUSAGE because
package.json and package-lock.json are out of sync.
- npm ci requires the lockfile to exactly match
package.json, but the lockfile contains multiple mismatched versions (e.g. tsdown@0.15.12 vs
required tsdown@0.22.3, cac@6.7.14 vs required cac@7.0.0, various rolldown packages).
- The lockfile
is also missing required entries (e.g. import-without-cache@0.4.0,
@rolldown/binding-linux-ppc64-gnu@1.1.2, @types/jsesc@2.5.1, estree-walker@3.0.3,
@types/estree@1.0.9).
As a result, npm ci aborted and the job exited with code 1.

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

139:  node-version: 22.x
140:  check-latest: false
141:  token: ***
142:  package-manager-cache: true
143:  ##[endgroup]
144:  Found in cache @ /opt/hostedtoolcache/node/22.22.3/x64
145:  ##[group]Environment details
146:  node: v22.22.3
147:  npm: 10.9.8
148:  yarn: 1.22.22
149:  ##[endgroup]
150:  ##[group]Run npm ci
151:  �[36;1mnpm ci�[0m
152:  shell: /usr/bin/bash -e {0}
153:  ##[endgroup]
154:  npm error code EUSAGE
155:  npm error
156:  npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
157:  npm error
158:  npm error Invalid: lock file's tsdown@0.15.12 does not satisfy tsdown@0.22.3
159:  npm error Invalid: lock file's cac@6.7.14 does not satisfy cac@7.0.0
160:  npm error Invalid: lock file's hookable@5.5.3 does not satisfy hookable@6.1.1
161:  npm error Missing: import-without-cache@0.4.0 from lock file
162:  npm error Invalid: lock file's rolldown@1.0.0-beta.45 does not satisfy rolldown@1.1.2
163:  npm error Invalid: lock file's rolldown-plugin-dts@0.17.8 does not satisfy rolldown-plugin-dts@0.26.0
164:  npm error Invalid: lock file's @oxc-project/types@0.95.0 does not satisfy @oxc-project/types@0.137.0
165:  npm error Invalid: lock file's @rolldown/binding-android-arm64@1.0.0-beta.45 does not satisfy @rolldown/binding-android-arm64@1.1.2
166:  npm error Invalid: lock file's @rolldown/binding-darwin-arm64@1.0.0-beta.45 does not satisfy @rolldown/binding-darwin-arm64@1.1.2
167:  npm error Invalid: lock file's @rolldown/binding-darwin-x64@1.0.0-beta.45 does not satisfy @rolldown/binding-darwin-x64@1.1.2
168:  npm error Invalid: lock file's @rolldown/binding-freebsd-x64@1.0.0-beta.45 does not satisfy @rolldown/binding-freebsd-x64@1.1.2
169:  npm error Invalid: lock file's @rolldown/binding-linux-arm-gnueabihf@1.0.0-beta.45 does not satisfy @rolldown/binding-linux-arm-gnueabihf@1.1.2
170:  npm error Invalid: lock file's @rolldown/binding-linux-arm64-gnu@1.0.0-beta.45 does not satisfy @rolldown/binding-linux-arm64-gnu@1.1.2
171:  npm error Invalid: lock file's @rolldown/binding-linux-arm64-musl@1.0.0-beta.45 does not satisfy @rolldown/binding-linux-arm64-musl@1.1.2
172:  npm error Missing: @rolldown/binding-linux-ppc64-gnu@1.1.2 from lock file
173:  npm error Missing: @rolldown/binding-linux-s390x-gnu@1.1.2 from lock file
174:  npm error Invalid: lock file's @rolldown/binding-linux-x64-gnu@1.0.0-beta.45 does not satisfy @rolldown/binding-linux-x64-gnu@1.1.2
175:  npm error Invalid: lock file's @rolldown/binding-linux-x64-musl@1.0.0-beta.45 does not satisfy @rolldown/binding-linux-x64-musl@1.1.2
176:  npm error Invalid: lock file's @rolldown/binding-openharmony-arm64@1.0.0-beta.45 does not satisfy @rolldown/binding-openharmony-arm64@1.1.2
177:  npm error Invalid: lock file's @rolldown/binding-wasm32-wasi@1.0.0-beta.45 does not satisfy @rolldown/binding-wasm32-wasi@1.1.2
178:  npm error Invalid: lock file's @rolldown/binding-win32-arm64-msvc@1.0.0-beta.45 does not satisfy @rolldown/binding-win32-arm64-msvc@1.1.2
179:  npm error Invalid: lock file's @rolldown/binding-win32-x64-msvc@1.0.0-beta.45 does not satisfy @rolldown/binding-win32-x64-msvc@1.1.2
180:  npm error Invalid: lock file's @rolldown/pluginutils@1.0.0-beta.45 does not satisfy @rolldown/pluginutils@1.0.1
181:  npm error Invalid: lock file's @babel/generator@7.29.7 does not satisfy @babel/generator@8.0.0
182:  npm error Invalid: lock file's @babel/helper-validator-identifier@7.29.7 does not satisfy @babel/helper-validator-identifier@8.0.2
183:  npm error Invalid: lock file's @babel/parser@7.29.7 does not satisfy @babel/parser@8.0.0
184:  npm error Invalid: lock file's ast-kit@2.2.0 does not satisfy ast-kit@3.0.0
185:  npm error Invalid: lock file's birpc@2.9.0 does not satisfy birpc@4.0.0
186:  npm error Invalid: lock file's dts-resolver@2.1.3 does not satisfy dts-resolver@3.0.0
187:  npm error Invalid: lock file's get-tsconfig@4.14.0 does not satisfy get-tsconfig@5.0.0-beta.5
188:  npm error Invalid: lock file's @babel/types@7.29.7 does not satisfy @babel/types@8.0.0
189:  npm error Missing: @types/jsesc@2.5.1 from lock file
190:  npm error Invalid: lock file's @babel/helper-string-parser@7.29.7 does not satisfy @babel/helper-string-parser@8.0.0
191:  npm error Missing: estree-walker@3.0.3 from lock file
192:  npm error Missing: @types/estree@1.0.9 from lock file
193:  npm error
194:  npm error Clean install a project
195:  npm error
196:  npm error Usage:
197:  npm error npm ci
198:  npm error
199:  npm error Options:
200:  npm error [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]
201:  npm error [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
202:  npm error [--include <prod|dev|optional|peer> [--include <prod|dev|optional|peer> ...]]
203:  npm error [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit]
204:  npm error [--no-bin-links] [--no-fund] [--dry-run]
205:  npm error [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
206:  npm error [-ws|--workspaces] [--include-workspace-root] [--install-links]
207:  npm error
208:  npm error aliases: clean-install, ic, install-clean, isntall-clean
209:  npm error
210:  npm error Run "npm help ci" for more info
211:  npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2026-06-22T21_45_16_049Z-debug-0.log
212:  ##[error]Process completed with exit code 1.
213:  Post job cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants