Repository navigation
Drop the bundled provider's AMD branches, which fail Next.js builds with Turbopack - #12
Merged
Merged
Conversation
…lds with Turbopack crypto-js and ulid, which sinch-rtc uses, are UMD, and kept their AMD branch in the bundled adapter: typeof define=="function"&&define.amd? define(["./core"],t):…. No browser takes it, but Turbopack resolves the file names it lists, so a Next.js 16 app importing @sentdm/voice-client 0.2.0 failed its build with 114 "Can't resolve './core'" errors. Vite and Rollup ignore them. The bundle now defines the global define as undefined, so esbuild drops all 37 branches from adapter/sinch-rtc.js and .mjs. Nothing else in the bundle reads a global define. - A dist test fails if either adapter build makes an AMD define([...]) call - Apps can drop the Turbopack loader that stripped the branch
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.
@sentdm/voice-client0.2.0 doesn't build in a Next.js 16 app with Turbopack: 114Can't resolve './core'errors.The bundled
adapter/sinch-rtc.{js,mjs}still carries the UMD wrappers of crypto-js and ulid. That's 37 per file, each with an AMD branch such astypeof define=="function"&&define.amd?define(["./core"],t):…. No browser takes that branch, but Turbopack resolves the file names it lists. Vite and Rollup ignore it, which is whyexamples/browser-phonebuilds.scripts/bundle.mjssetsdefine: { define: 'undefined' }, so esbuild drops the branch. Nothing else in the bundle reads a globaldefine: every freedefinebefore this change belonged to one of the 37 wrappers. The bundle is about 3 KB smaller.tests/dist.test.tsfails if either bundle contains a freedefine([...])call, and lists the calls it finds. Without the fix it fails on both formats.dynamic(..., { ssr: false })as the samples do:ssr: false) still fails under Turbopack, with 0.2.0 and with this fix. Pubnub's Node entry pulls in formidable, whose dynamicrequire(path.join(__dirname, 'plugins', …))Turbopack can't resolve. Worth a docs note.Release: the commit is
fix:, so release-please makes this 0.2.1 for all three linked packages. Merge with a merge commit, not a squash, so release-please still sees thefix:subject. The automatic npm publish failed withENEEDAUTHfor 0.2.0 and went out from a manual run, so 0.2.1 is the first automatic OIDC publish. If it fails again, rerunpublish-npmby hand onmain.Once 0.2.1 is on npm, the samples (sent-dm-voice-samples-apps) can drop their
voice-client-amd-loader.cjsworkaround.Part of EPIC-4426 (Sent Voice): https://github.com/sentdm/sent-dm-agentic-org/blob/main/_pm/epics/EPIC-4426-sent-voice.md
How to test
./scripts/test: 286 pass, including the new dist check on both formats./scripts/lintpnpm packthe voice-client package, install the tarball into a Next.js 16 app, import it withdynamic(..., { ssr: false }), and runnext build. It succeeds, where 0.2.0 fails with 114 errors