-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly filter files that exist outside of the app directory (like hoisted modules) (fixes #2942) #2948
Conversation
…oisted modules) (fixes electron-userland#2942)
I didn't really explain the behavior of this change. We don't really know what the true "root" of the project is since a yarn workspace could live anywhere within the project. This takes a relaxed approach and, if a file outside the electron app is found, it will return whatever its path has in common with the path of the electron app. So if the electron app exists at |
Alright, I got it working in my own repo and made sure it compiles with TS. |
Thanks for PR! Even if it is not fully correct, such PR is the only way to force me to fix such bugs since it is a challenge :) |
|
Let me know the right way you think this should be fixed. Don't want to force you to do it :) I have to use a custom fork now though so I'd love to get rid of that. |
Fix will be tomorrow morning CET. Thanks a lot for your clear and full explanation. |
Thanks! To be clear: I also need the ability to exclude files from the root of the project. Yarn workspaces have installed a link to my other subpackage "loot-core" in the root node_modules, so with my PR, I can exclude a directory inside of it by adding Just want to make sure I can still somehow write |
Ideally, should be an another option to specify patterns for node modules, but for now we simply use only exclude patterns from main patterns (and base always |
…ike hoisted modules) Close electron-userland#2942, Close electron-userland#2948, Close electron-userland#2952, Close electron-userland#2892, Close electron-userland#2944, Close electron-userland#2945, Close electron-userland#2865, Close electron-userland#2953
…ike hoisted modules) Close electron-userland#2942, Close electron-userland#2948, Close electron-userland#2952, Close electron-userland#2892, Close electron-userland#2944, Close electron-userland#2945, Close electron-userland#2865, Close electron-userland#2953
…ike hoisted modules) Close electron-userland#2942, Close electron-userland#2948, Close electron-userland#2952, Close electron-userland#2892, Close electron-userland#2944, Close electron-userland#2945, Close electron-userland#2865, Close electron-userland#2953
…ike hoisted modules) Close electron-userland#2942, Close electron-userland#2948, Close electron-userland#2952, Close electron-userland#2892, Close electron-userland#2944, Close electron-userland#2945, Close electron-userland#2865, Close electron-userland#2953
…ike hoisted modules) Close electron-userland#2942, Close electron-userland#2948, Close electron-userland#2952, Close electron-userland#2892, Close electron-userland#2944, Close electron-userland#2945, Close electron-userland#2865, Close electron-userland#2953
I figured out the problem in #2942.
This isn't a Windows-specific issue like I first thought; I just hadn't tested my new build pipeline on macOS yet.
electron-builder supports yarn workspaces, where modules have been hoisted into a root repo. The electron app exists in a subpackage like
packages/desktop-electron
, while almost all dependencies have been hoisted up into a top-levelnode_modules
.The problem is this piece of code in
createFilter
:The problem is it assumes
it
, which is a path, exists belowsrcWithEndSlash
. This may not be the case with hoisted modules.it
may be~/project/node_modules/lib/foo.js
whilesrcWithEndSlash
is~/project/packages/desktop-electron/
. The result is thatit
will be erroneously cut off, since it will slice off the full length ofsrcWithEndSlash
.The result is you end up with partial paths, which then might falsely match filters. In my case, a dependency had a
dist
folder, and thenode_modules/lib/dist/file.js
path happened to get sliced intodist/file.js
which matches the!dist{,/**/*}
filter which makes it not include that file. (That filter is attempting to not include thedist
folder generated by electron-builder). The result is thedist
folder of an internal dependency is missing.This is probably not the right solution. I also haven't written TS before, but this is the code that works if I patch electron-builder in
node_modules
manually. I'm happy to help improve this and get some kind of fix in.