Skip to content

test(target): add config case coverage for electron-main and electron-preload targets #20629

@junaiddshaukat

Description

@junaiddshaukat

Summary

Webpack supports three Electron target contexts in lib/config/target.js and lib/electron/ElectronTargetPlugin.js:

  • electron-main
  • electron-preload
  • electron-renderer

At the moment, there is only a visible config case for electron-renderer under test/configCases/target/electron-renderer.

That leaves electron-main and electron-preload with little or no dedicated integration-style config case coverage, even though they affect target properties, resolve behavior, and externals handling differently.

Proposal Description

Add dedicated config case tests for:

  • test/configCases/target/electron-main
  • test/configCases/target/electron-preload

These tests should validate behavior specific to those target contexts and help ensure the target/runtime behavior remains correct when Electron-related logic changes.

Suggested Scope

Some candidate assertions for the new config cases:

electron-main

  • should not behave like a browser target
  • should not prefer the browser field in package resolution
  • should preserve Node/Electron-style behavior expected in main context

electron-preload

  • should behave differently from electron-renderer
  • should not incorrectly enable browser-style resolution behavior
  • should preserve preload-specific environment assumptions

Why this is useful

This would improve test coverage around Electron targets and make future work related to target/runtime behavior easier and safer, especially as Electron support has been mentioned as one of the remaining unresolved target areas.

Related Code

  • lib/config/target.js
  • lib/electron/ElectronTargetPlugin.js
  • existing test:
    • test/configCases/target/electron-renderer

Related Context

This is adjacent to the target/runtime area and may also be useful groundwork for broader work around target compatibility and Universal Targets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions