docs(webpack): document sandboxed preload default for Forge 7.x#261
Merged
Conversation
Preload scripts are compiled with the sandboxedPreload webpack target by default (Electron 20+ / Forge 7.x), which removes Node.js access. Add a "Preload scripts" section explaining this behavior change from 6.x and how to opt into full Node.js access via nodeIntegration or a preload-only entry point. Fixes electron/forge#3659 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8emyk2ZfnUyZyQpfRBmYc
The "You have two options" line only presented one clearly-headed option; the preload-only entry point was buried in a paragraph under the first option's heading. Split into two numbered subsections: (1) nodeIntegration on the window entry point, and (2) a preload-only entry point. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8emyk2ZfnUyZyQpfRBmYc
MarshallOfSound
approved these changes
Jul 1, 2026
erickzhao
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Samuel Attard · Slack thread
Fixes electron/forge#3659.
Before / After
Before: The Webpack Plugin page showed how to attach a
preloadscript to an entry point and how to consume the*_PRELOAD_WEBPACK_ENTRYglobal, but said nothing about how preload scripts are compiled. A reader upgrading from Forge 6 to 7 whose preload usedrequireor other Node.js APIs would find it silently broken with no explanation, and no guidance on how to fix it.After: The page gains a dedicated "Preload scripts" section that tells the reader:
sandboxedPreloadwebpack target, sorequire,process, and Node core modules are unavailable, and the recommended pattern iscontextBridge.nodeIntegration: trueon the window entry point (switching the preload to theelectronPreloadtarget), or declare a standalone preload-only entry point with its ownnodeIntegration: true.<NAME>_PRELOAD_WEBPACK_ENTRY), with a worked example matching what users hit in the issue.How
I confirmed current 7.x behavior against
packages/plugin/webpackinelectron/forge:WebpackConfig.tsderives the preload target as(entry.nodeIntegration ?? rendererOptions.nodeIntegration) ? 'electronPreload' : 'sandboxedPreload', andConfig.tsdefinesnodeIntegrationon the base entry-point interface (not on the preload object) plus aWebpackPluginEntryPointPreloadOnlytype. The new section documents exactly this. Docs-only change toconfig/plugins/webpack.md;electron-markdownlintandlint-roller-markdown-standardboth pass locally.Generated by Claude Code