Skip to content

fix(desktop): keep the browser pane chunk parseable - #60388

Closed
multiserviciossv wants to merge 3 commits into
anomalyco:devfrom
multiserviciossv:browser-pane-chunk
Closed

multiserviciossv wants to merge 3 commits into
anomalyco:devfrom
multiserviciossv:browser-pane-chunk

Conversation

@multiserviciossv

@multiserviciossv multiserviciossv commented Oct 29, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #60369
Fixes #60386
Related: #60023

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The desktop main build produces a browser pane chunk that cannot be parsed in 2.2.2. The fixed CommonJS banner declares a module-scoped require, while the bundled @effect/platform-node internal/http shim declares its own top-level require. The minifier renames both to n, so the lazy pane-*.js chunk dies with Identifier 'n' has already been declared and the browser panel never attaches.

This keeps require off the module scope by assigning it on globalThis (preserving an existing Electron require), and keeps the exact electron-vite shim in a comment so electron-vite's vite:esm-shim plugin still detects it and does not inject a second copy.

The fix is desktop build config only; the public API is unchanged.

How did you verify your code works?

  • cd packages/desktop && bunx electron-vite build
  • node --check on every out/main/*.js (650 chunks). It fails on pane-*.js before the change and passes after.
  • bun test electron.vite.config.test.ts
  • bun run typecheck

The failure reproduces on Linux from the v2.2.2 sources, so it is not Windows-only. I did not open the Electron app itself.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Fixes #60386

Related: #60023

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 29, 2026

@opencodejr opencodejr Bot 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.

The fix looks sound and does what it says. I built the desktop main process (bunx electron-vite build) on the base and with this PR, then ran node --check on all 650 out/main chunks. On the base only the browser pane-*.js chunk fails, with Identifier 'n' has already been declared. With the PR every chunk passes and none has two createRequire calls. electron.vite.config.test.ts passes. I didn't open the Electron app itself.

I also checked that the commented-out shim is needed. electron-vite's vite:esm-shim skips a chunk only when the code contains its exact shim text, and it sees the banner before minification removes the comment. With the comment taken out, the build adds a second const require to many chunks. So this depends on electron-vite's shim text staying the same, but the current config already relies on that.

Public API: unchanged (desktop build config only).

No blocking concerns.

Fixes #60386
Related: #60023

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@opencodejr opencodejr Bot 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.

The new commit only merges dev in, and the fix itself is unchanged. I rebuilt the desktop main process at the new head and ran node --check on all 650 out/main chunks: all pass, including the browser pane-* chunk. electron.vite.config.test.ts passes.

Public API: unchanged (desktop build config only).

No new concerns.

@opencodejr opencodejr Bot 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.

The new commit only merges dev in, and the fix itself is unchanged. I rebuilt the desktop main process at the new head and ran node --check on all 650 out/main chunks: all pass, including the browser pane-* chunk. electron.vite.config.test.ts passes.

Public API: unchanged (desktop build config only).

No new concerns.

@multiserviciossv

Copy link
Copy Markdown
Author

Superseded by #60430 (merged in v2.2.4). That change removes the banner and disables electron-vite's esm-shim, so Rolldown's scoped createRequire runtime is used. It fixes the same browser pane collision and adds bundle verification. #60369 is already closed. Closing this to avoid a duplicate fix; thanks for the reviews.

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.

Browser bug desktop: internal browser panel disappears — browser scope fails with SyntaxError: Identifier 'n' has already been declared

2 participants