You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be more lazy in my forge config, I added a skip for web, since if nodeIntegration is enabled for a renderer, forge makes the target one of the electron- variants, whereas otherwise it's web. Forge's webpack plugin doesn't allow configuring different plugins for individual renderers, hence this takes advantage of that automatic target configuration by allowing everything to be passed in, only compiling the renderer that has nodeIntegration set to true.
/lib/utils.js
When nesting (multiple?) entry points the paths are resolved in a way that breaks the build; the folder name is given the .compiled extension instead of the file:
This: something/ui.compiled/index.jsc
Instead of: something/ui/index.compiled.jsc
Here is the diff that solved my problem:
diff --git a/node_modules/@herberttn/bytenode-webpack-plugin/lib/plugin.js b/node_modules/@herberttn/bytenode-webpack-plugin/lib/plugin.js
index c621dee..7acafbc 100644
--- a/node_modules/@herberttn/bytenode-webpack-plugin/lib/plugin.js+++ b/node_modules/@herberttn/bytenode-webpack-plugin/lib/plugin.js@@ -26,6 +26,16 @@ class BytenodeWebpackPlugin {
apply(compiler) {
const logger = compiler.getInfrastructureLogger(this.name);
setupLifecycleLogging(compiler, this.name, this.options);
+ if (this.options.compileForElectron) {+ const target = compiler.options.target;+ if (target) {+ const targets = Array.isArray(target) ? target : [target];+ if (!targets.some((target) => target.startsWith('electron-'))) {+ logger.warn(`Not using bytenode because [${targets.join(', ')}] is marked as "compileForElectron: true" but has "target: 'web'".`);+ return;+ }+ }+ }
logger.debug('original webpack.options.entry', compiler.options.entry);
const { entries: { ignored, loaders, targets }, modules } = prepare(compiler);
logger.debug('prepared ignores', Object.fromEntries(ignored.entries()));
diff --git a/node_modules/@herberttn/bytenode-webpack-plugin/lib/utils.js b/node_modules/@herberttn/bytenode-webpack-plugin/lib/utils.js
index 79abcda..116ed0c 100644
--- a/node_modules/@herberttn/bytenode-webpack-plugin/lib/utils.js+++ b/node_modules/@herberttn/bytenode-webpack-plugin/lib/utils.js@@ -55,7 +55,12 @@ function fromCompiledToTargetExtension(file) {
}
exports.fromCompiledToTargetExtension = fromCompiledToTargetExtension;
function fromTargetToCompiledExtension(file) {
- return file.replace(TARGET_EXTENSION_REGEX, COMPILED_EXTENSION);+ const dest = file.replace(TARGET_EXTENSION_REGEX, COMPILED_EXTENSION);+ if (!dest.includes('.compiled.jsc')) {+ const patchedDest = dest.replace('.compiled', '');+ return patchedDest.replace('.jsc', '.compiled.jsc');+ }+ return dest;
}
exports.fromTargetToCompiledExtension = fromTargetToCompiledExtension;
function isCompiledExtension(file) {
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
@herberttn/[email protected]
for the project I'm working on./lib/plugin.js
To be more lazy in my forge config, I added a skip for
web
, since ifnodeIntegration
is enabled for a renderer, forge makes the target one of theelectron-
variants, whereas otherwise it'sweb
. Forge's webpack plugin doesn't allow configuring different plugins for individual renderers, hence this takes advantage of that automatic target configuration by allowing everything to be passed in, only compiling the renderer that hasnodeIntegration
set totrue
./lib/utils.js
When nesting (multiple?) entry points the paths are resolved in a way that breaks the build; the folder name is given the .compiled extension instead of the file:
something/ui.compiled/index.jsc
something/ui/index.compiled.jsc
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: