Skip to content

feat: devtron integration - #4344

Open
erickzhao wants to merge 1 commit into
nextfrom
claude/epic-bell-cKVZc
Open

feat: devtron integration#4344
erickzhao wants to merge 1 commit into
nextfrom
claude/epic-bell-cKVZc

Conversation

@erickzhao

Copy link
Copy Markdown
Member

Summary

This PR adds support for automatically injecting the Devtron DevTools extension into Electron apps during development when using the Webpack or Vite build plugins.

Changes

Core Utilities (packages/utils/core-utils)

  • Added new devtron.ts module with:
    • getDevtronBootstrapCode(): Generates safe CommonJS bootstrap code that installs Devtron as a DevTools extension in the main process
    • canInjectDevtron(): Validates that @electron/devtron is installed and the Electron version is >= 36.0.0 (required for the DevTools extension API)
    • Comprehensive test coverage in devtron.spec.ts

Webpack Plugin (packages/plugin/webpack)

  • Added devtron configuration option to WebpackPluginConfig
  • Modified WebpackConfigGenerator.getMainConfig() to inject the Devtron bootstrap code as a webpack BannerPlugin when:
    • The devtron option is enabled
    • Building in development mode (not production)
    • The environment supports it (checked via canInjectDevtron())
  • Added comprehensive test coverage for all scenarios

Vite Plugin (packages/plugin/vite)

  • Added devtron configuration option to VitePluginConfig
  • Modified VitePlugin to:
    • Check if Devtron can be injected during the preStart hook
    • Store the result in devtronEnabled flag
    • Pass this flag to the serializable config for worker processes
  • Modified vite.main.config.ts to inject the bootstrap code as a Rollup banner and mark @electron/devtron as external when enabled
  • Added comprehensive test coverage for all scenarios

Behavior

  • Development builds only: The bootstrap is only injected when running electron-forge start, never in packaged builds
  • Safe injection: The bootstrap code guards against packaged apps, non-main processes, and ESM contexts where require is unavailable
  • Version checking: Warns users if their Electron version is too old (< 36.0.0) and skips injection
  • Graceful degradation: If @electron/devtron is not installed, an error is thrown with installation instructions

Testing

  • Added 95 lines of unit tests for the core devtron module covering bootstrap code validity, version checking, and installation detection
  • Added test coverage for both Webpack and Vite plugins covering all injection scenarios (enabled/disabled, dev/prod, supported/unsupported environments)
  • All tests pass with mocked file systems and dependency resolution

https://claude.ai/code/session_01PnzP6e9JFCCaDFgbpiWVms

Adds a `devtron: true` config option to @electron-forge/plugin-webpack and
@electron-forge/plugin-vite that installs the @electron/devtron DevTools
extension into the app during `electron-forge start`.

The bootstrap is prepended as a raw banner to the compiled main process
bundle in development only (webpack BannerPlugin / Rollup output.banner),
so the bundler never parses it and `@electron/devtron` resolves from the
app's node_modules at runtime. The snippet guards against packaged apps,
non-main Electron processes, and ESM output without `require`.

A shared helper in @electron-forge/core-utils validates that
@electron/devtron is installed in the app (actionable error otherwise) and
that the app's Electron version is >= 36 (warn and skip otherwise).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PnzP6e9JFCCaDFgbpiWVms
@erickzhao
erickzhao requested a review from a team as a code owner August 7, 2026 20:26
@github-actions github-actions Bot added the next label Aug 7, 2026
@erickzhao erickzhao changed the title Add Devtron DevTools extension support to Webpack and Vite plugins feat: devtron integration Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants