Skip to content

Patch mono-repo support by manually copying any externals that havent been already copied - #11

Open
FrozenKiwi wants to merge 2 commits into
timfish:masterfrom
FrozenKiwi:master
Open

FrozenKiwi wants to merge 2 commits into
timfish:masterfrom
FrozenKiwi:master

Conversation

@FrozenKiwi

@FrozenKiwi FrozenKiwi commented Jan 18, 2024 •

Copy link
Copy Markdown

Added support for (my) monorepo setup.

All packages (to the extent possible) hoisted to the root.

When packaging, electron-forge copies <root>/app/my-electron-app to it's temp folder, but it does not copy anything from <root>/node_modules

The plugins original code did not explicitly copy modules across, and simply prevented them from being ignored. This means any external modules that have been hoisted are not present in the final build.

This PR adds an explicit copy in the afterCopy hook to copy across any packages that have not been copied by electron-forge

Tested:

  • Correctly copies modules that have been skipped by electron-forge (eg, hoisted packages)
  • No changes on modules that forge copies (current behaviour - eg non-hoisted packages)

Comment thread index.js
.forEach((name) => foundModules.add(name));
.forEach((dep) => {
// How many occurences of `node_modules` in the path
const levels = dep.path.split(`${sep}node_modules${sep}`).length - 1;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while a little naive, finding nested modules by splitting on node_modules err's on the side of copying too much (less bad than not enough)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant