Repository navigation
fix(forge): make electron-builder makers loadable by current Electron Forge - #10351
Conversation
… 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 detectedLatest commit: a01acd1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…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
|
v26 backport: #10352 (draft, requested by @mmaietta). Generated by Claude Code |
There was a problem hiding this comment.
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 aMakerBase-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.jsexported 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.
|
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 I tried to re-run that one job, but GitHub refused with 403 ( Generated by Claude Code |
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 callingnew Maker(config, platforms), then using theMakerBasemethods (platforms,prepareConfig,clone,make, …) on it. With these packages, Forge 8.0.1 fails right away with aTypeErrorfrombuildForge. This PR addsElectronBuilderForgeMakertoapp-builder-lib. It is shaped like Forge'sMakerBasebut 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'sconfigbecomes the target's options (nsis,nsisWeb,appImage,snapcraft). Output goes to Forge'smakeDir, 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, andrequire()still works, so nothing breaks for existing users.I checked this with real
@electron-forge/core@8.0.1(makewithfromPackage, 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