Skip to content

BE-7755: preserve platform-connect side-effects in sideEffects allowlist#196

Merged
svelichkin-keeper merged 1 commit into
mainfrom
be-7755-preserve-platform-connect-sideeffects
Jul 1, 2026
Merged

BE-7755: preserve platform-connect side-effects in sideEffects allowlist#196
svelichkin-keeper merged 1 commit into
mainfrom
be-7755-preserve-platform-connect-sideeffects

Conversation

@svelichkin-keeper

@svelichkin-keeper svelichkin-keeper commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

BE-7755

Summary

The sideEffects allowlist (["**/configureProtobuf*"]) was scoped to let downstream bundlers tree-shake proto.js. A consequence is that every module not listed is treated as side-effect-free — including the entry modules that call connectPlatform(...). Downstream bundlers (e.g. webpack) then drop that call, the module-level platform binding is never initialized, and a consumer that imports named exports and runs crypto in a separate bundle/realm — such as an MV3 offscreen document — sees platform as undefined at runtime and crypto fails.

How sideEffects behaves

  • Omitted: bundlers assume every module may have side effects, so nothing is dropped and connectPlatform always runs.
  • false: every module is treated as pure, so all side-effect-only imports are eligible for removal.
  • Allowlist [globs] (current): only the listed files may have side effects; everything else is treated as pure. The configureProtobuf* allowlist unintentionally excluded the connectPlatform entry modules.

This PR adds the browser entry modules to the allowlist, so bundlers preserve the platform connection while still tree-shaking proto.js:

  • dist/browser/index.jsconnectPlatform(browserPlatform)
  • dist/worker/browserWorker.js — browser worker entry

The change is additive metadata only: it makes consuming bundlers more conservative and cannot alter runtime behavior for consumers that were already working.

@svelichkin-keeper svelichkin-keeper marked this pull request as ready for review July 1, 2026 21:46

@tylerccarson tylerccarson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice find!

Comment thread keeperapi/package.json Outdated
@svelichkin-keeper svelichkin-keeper force-pushed the be-7755-preserve-platform-connect-sideeffects branch from 5b50ed1 to 2d23229 Compare July 1, 2026 22:20
@svelichkin-keeper svelichkin-keeper merged commit b50e1ec into main Jul 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants