Skip to content

fix(forge): make electron-builder makers loadable by current Electron Forge - #10351

Merged
mmaietta merged 3 commits into
masterfrom
claude/forge-esm-maker-compat
Oct 20, 2026
Merged

mmaietta merged 3 commits into
masterfrom
claude/forge-esm-maker-compat

Conversation

@claude

@claude claude Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Requested by Mike Maietta · Slack thread

The electron-forge-maker-* packages still export a Forge 5 maker function. Since Forge 6, Forge has loaded a maker by importing the package's default export and calling new Maker(config, platforms), then using the MakerBase methods (platforms, prepareConfig, clone, make, …) on it. With these packages, Forge 8.0.1 fails right away with a TypeError from buildForge. This PR adds ElectronBuilderForgeMaker to app-builder-lib. It is shaped like Forge's MakerBase but does not depend on @electron-forge/*. Each maker package now exports a subclass as its default export and under the name the docs already use (MakerNsis, MakerNsisWeb, MakerAppImage, MakerSnap), with TypeScript declarations. The maker's config becomes the target's options (nsis, nsisWeb, appImage, snapcraft). Output goes to Forge's makeDir, and the executable name comes from Forge's packager, so electron-builder finds the binary Forge produced. The default export can still be called as a Forge 5 maker function, and require() still works, so nothing breaks for existing users.

I checked this with real @electron-forge/core@8.0.1 (make with fromPackage, by package name and as instances). All four makers reached electron-builder's target build step, where the sandbox blocked the toolset downloads from GitHub, so no installer was actually built end to end.


Generated by Claude Code

… Forge

Electron Forge 6+ resolves a `{ name, config }` maker by importing the
package's default export and constructing it with
`new Maker(config, platforms)`, then calls the MakerBase methods on it.
The electron-forge-maker-* packages still exported a Forge 5 maker
function, so Forge called buildForge() with the maker config as options
and failed with a TypeError.

Add ElectronBuilderForgeMaker to app-builder-lib, a class that is
structurally compatible with MakerBase. Each maker package now exports
a subclass, as the default export and by name. The maker config is
applied as the target's options. Output goes to Forge's makeDir, and
the executable name comes from Forge's packager. Calling the default
export as a Forge 5 maker function still works.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KEHdnzSYMevUEQMAbJNyDo
@changeset-bot

changeset-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a01acd1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Minor
electron-forge-maker-appimage Minor
electron-forge-maker-nsis Minor
electron-forge-maker-nsis-web Minor
electron-forge-maker-snap Minor
dmg-builder Minor
electron-builder-squirrel-windows Minor
electron-builder Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Pin @electron-forge/maker-base and @electron-forge/shared-types 8.0.1 as
app-builder-lib devDependencies. A type-only assertion now checks
ElectronBuilderForgeMaker against Forge's MakerBase members, ForgeConfig
makers, MakerOptions and ForgePlatform, so a Forge bump that changes the
maker contract fails `pnpm compile`. The assertion is @internal and type
only, so nothing from Forge reaches dist output or published dependencies.

forgeMakerTest now runs the real @electron-forge/core 8.0.1 `api.make`.
It loads each maker by package name and as a require()d instance and
checks that the maker config reaches electron-builder under the target's
key. This replaces the copied importSearch probe.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KEHdnzSYMevUEQMAbJNyDo
@socket-security

socket-security Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​electron-forge/​maker-base@​8.0.11001006795100
Added@​electron-forge/​shared-types@​8.0.11001006896100
Added@​electron-forge/​core@​8.0.1991008195100

View full report

…tors

Electron Forge 7 types ForgePlatform as `OfficialPlatform | string`. With
our narrower `ForgePlatform[]` parameter, a `platforms` variable typed
with Forge 7's type was rejected at compile time. The constructor now
takes `ReadonlyArray<string>`. The `platforms` getter keeps only the
platforms Forge knows, so the Forge 8 MakerBase assertions still hold.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KEHdnzSYMevUEQMAbJNyDo
@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

v26 backport: #10352 (draft, requested by @mmaietta).


Generated by Claude Code

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline doc-table finding, I also looked at the config-reuse concern raised during review: ElectronBuilderForgeMaker.prepareConfig() only resolves config once per instance (via the isConfigPrepared flag), which could leak one arch's config into another arch's build if Forge reused a single maker instance across archs — but the class implements clone() for exactly this case, and Forge's maker API is designed to clone a fresh instance per arch/platform rather than reuse one, so this isn't a live bug.

Extended reasoning...

The diff adds a new public ElectronBuilderForgeMaker base class and rewires four electron-forge-maker-* packages' main.js/main.d.ts to subclass it, plus compile-time structural checks against @ electron-forge/maker-base types, a new test file, and doc updates; it touches build/packaging tooling, not auth/crypto/data-exposure surfaces. The one confirmed finding is a documentation nit (breaking-changes table says "same export shape" while the PR's own section says the default export changed from function to class), not a code defect. I additionally examined the config-caching-across-arches concern raised during the hunt and ruled it out since the maker's clone() method exists precisely to avoid instance reuse across arch targets.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🟡 website/docs/migration/v27-breaking-changes.md — nit: The breaking-changes "at a glance" table still claims the Forge maker plugins have "same API, same export shape", but this PR's own section below (line 171) says the default export changed from a Forge 5 function to a MakerBase-compatible class. Fix: update the table row's "Action required" text to match the detailed section, e.g. note the export is now a class (still callable as before).

    Why this was flagged

    A reader skimming only the "Breaking changes at a glance" table (website/docs/migration/v27-breaking-changes.md:52) sees "None — same API, same export shape" for electron-forge-maker-* and assumes nothing about the export changed. The detailed section this same PR adds at website/docs/migration/v27-breaking-changes.md:171 says the default export is now a maker class (MakerNsis, etc.) rather than a plain function, which is a real shape change even though it remains callable. The table row was not updated to mention this, so the two parts of the same doc disagree.

    Verification: nit. Documentation inconsistency the PR introduces. The base electron-forge-maker-nsis/main.js exported a plain function as default (export default function (options) { return buildForge(...) }), while the merged version exports a maker class wrapped in a Proxy (class MakerNsis extends ElectronBuilderForgeMaker, const Maker = withLegacyForgeCall(MakerNsis); export default Maker). The default-export shape genuinely changed from a function to a class/constructor.

@claude

claude Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Test macOS (Shard 1) (job 118794866323) failed, but not because of this PR. No test ran: the job died during its "Setup Tests" step (that step was still in_progress when the job ended), and its only error annotation is a GitHub infrastructure failure: The hosted runner lost communication with the server. The job ran on a macos-26 runner, 18:01–18:46 UTC, and no log was kept (BlobNotFound). Every other macOS, Windows and Linux shard on this head passed, including the Linux shard that runs forgeMakerTest.

I tried to re-run that one job, but GitHub refused with 403 (The workflow run containing this job is already running): the rpm auto-updater e2e jobs in the same run are still going. The job can be re-run once the run finishes.


Generated by Claude Code

@mmaietta
mmaietta merged commit 1e32919 into master Oct 20, 2026
109 of 111 checks passed
@mmaietta
mmaietta deleted the claude/forge-esm-maker-compat branch October 20, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址