From 9178da03e6914dc3389082d63ddbec30627e7dc6 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 19 Feb 2025 16:22:55 -0800 Subject: [PATCH] Support dynamic import with preload cache --- preload.wrapper.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/preload.wrapper.ts b/preload.wrapper.ts index ef7423b461..54854af8cf 100644 --- a/preload.wrapper.ts +++ b/preload.wrapper.ts @@ -7,7 +7,7 @@ import { Module } from 'node:module'; import { readFileSync, writeFileSync } from 'node:fs'; import { join, dirname } from 'node:path'; -import { Script } from 'node:vm'; +import { Script, constants } from 'node:vm'; import { ipcRenderer } from 'electron'; const srcPath = join(__dirname, 'preload.bundle.js'); @@ -38,6 +38,7 @@ function compile( filename, lineOffset: 0, cachedData, + importModuleDynamically: constants.USE_MAIN_CONTEXT_DEFAULT_LOADER, }); const compiledWrapper = script.runInThisContext({ @@ -45,6 +46,7 @@ function compile( lineOffset: 0, columnOffset: 0, displayErrors: true, + importModuleDynamically: constants.USE_MAIN_CONTEXT_DEFAULT_LOADER, }); return compiledWrapper;