Add session#setPreloads()
API to set the JS script content directly
#14012
Labels
session#setPreloads()
API to set the JS script content directly
#14012
Is your feature request related to a problem? Please describe.
Being able to set preloads for a session is very useful, unfortunately having to set an absolute path is problematic when you use some kind of bundler for the code, as the preload script has to be excluded and handled manually since the path to the preload no longer exists when bundled. This is especially problematic for reusable modules using
session#setPreloads()
as the bundling is out of its control. (Example: sindresorhus/electron-timber#17).API: https://electronjs.org/docs/api/session#sessetpreloadspreloads
Describe the solution you'd like
I would like the ability to set session preloads as strings of content in addition to absolute paths.
The existing API can't be used for this as it already supports strings as paths.
I propose two solutions:
session.setPreloadScripts()
that accepts astring[]
with JS code:session.PreloadScript()
constructor that can be passed tosession#setPreloads()
:This would also let us create dynamic preload scripts, which can be useful for modules.
The text was updated successfully, but these errors were encountered: