Skip to content

Add Electron Fuses to the packaging pipeline #3076

Closed

Description

@erickzhao

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

In Electron, Fuses are package-time toggle features that can disable certain features on a per-app basis. For example, apps might not want to ship with the ELECTRON_RUN_AS_NODE capability, and can turn it off for their app with a fuse.

See https://www.electronjs.org/docs/latest/tutorial/fuses

Proposed solution

Forge should include a way to easily configure fuses in the packaging process.

Alternatives considered

This can be implemented in various manners in the Forge process, and we don't really have existing guidelines on which one is better:

  • As an opt-in plugin
  • As a built-in part of the Forge config
  • As a written how-to guide in the Forge docs

Additional information

No response

Activity

  1. added
    package
    on Nov 16, 2022
  2. erikian commented on Nov 16, 2022

    @erikian
    Member

    Going for a plugin would potentially help with modularization, though it doesn't look like it's going to take a lot of code (@electron/fuses' docs show a complete example in just a few LOC), so maybe it can be just built into Forge (or packager?) directly. Either way, I'd happy to take on this once an approach is decided.

  3. pacocoursey commented on Dec 16, 2022

    @pacocoursey

    @erikian Why close that PR? It looked perfect for adding Fuses support in both places. Has anyone made a plugin to do support using Fuses through Forge/Packager yet?

  4. SpacingBat3 commented on Feb 2, 2023

    @SpacingBat3
    Contributor

    @erickzhao As a workaround / current way how to use Fuses with Electron Forge, you can use hooks like this:

    const { flipFuses } = require("@electron/fuses");
    const { resolve } = require("path");
    
    const electronPath = new Map([
    	/* PLATFORM                                BINARY */
    	[ "darwin", "Electron.app/Contents/MacOS/Electron" ],
    	[ "win32",                          "electron.exe" ],
    	[ "linux",                              "electron" ]
    ]);
    
    module.exports = {
    	// (...)
    	hooks: {
    		packageAfterExtract: (_forgeConfig, path, _electronVersion, platform) =>
    			flipFuses(resolve(path, electronPath.get(platform)), {
    				// Insert you Fuse config there.
    			})
    	},
    	// (...)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpackagerequest/plugin

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions