Skip to content

Improve external dependency compatibility: native module detection and DLL exclusion option #3702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mulgyeol
Copy link

Improve External Dependency Compatibility: Native Module Detection & DLL Exclusion Option

Description

While working with Electron React Boilerplate, I noticed that some external packages—especially those with native modules or special export/dynamic import requirements—were causing unexpected build failures.
This PR updates the native module detection logic to be more accurate and adds a simple way for users to exclude problematic packages from the DLL bundle. I believe these changes will make it much easier to integrate a wider variety of dependencies without running into confusing errors.

Changes Made

  • .erb/scripts/check-native-dep.js
    • Updated the detection logic so that only packages with both a binding.gyp file and a direct entry in package.json dependencies are flagged as native.
    • Cleaned up the code by removing unnecessary npm ls parsing and the try-catch block.
  • .erb/configs/webpack.config.renderer.dev.dll.ts
    • Introduced a dllExclude array, allowing users to easily specify packages to exclude from the DLL bundle.
    • By default, this array is empty—users can add package names as needed for their setup.

Why

  • I ran into issues where some packages were incorrectly flagged as native modules, which blocked development and caused unnecessary build failures.
  • Additionally, certain packages would break the DLL build due to export or dynamic import issues, and there was no straightforward way to exclude them.
  • With these changes, false positives are avoided, and users have more control over which packages are included in the DLL bundle.

Testing

  • I tested with several packages that previously caused issues and confirmed they are no longer falsely detected as native.
  • I also checked that adding package names to dllExclude successfully excludes them from the DLL bundle.
  • The project continues to build and run as expected after these updates.

Mulgyeol added 2 commits June 24, 2025 19:46
Only treat packages as native dependencies if they have a binding.gyp file and are listed in package.json dependencies.
Remove unnecessary npm ls parsing and try-catch block.
Prevents false positives that could block development.
Introduce a dllExclude array in webpack.config.renderer.dev.dll.ts to allow users to easily exclude problematic packages from the DLL bundle.
By default, the array is empty. Users can add package names as needed for their environment.
Improves flexibility and compatibility with external dependencies.
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.

1 participant