-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Modularize wails #2009
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
Modularize wails #2009
Conversation
Deploying with
|
| Latest commit: |
f087641
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://341cf4c7.wails.pages.dev |
| Branch Preview URL: | https://feature-1877-modularize-wail.wails.pages.dev |
stffabi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great enhancement 🚀 , left some minor comments.
Co-authored-by: stffabi <stffabi@users.noreply.github.com>
|
I feel a CLI rewrite coming on 😜 |
|
Just added a commit which should fix the buildassets comments. |
|
Hey, this works for what I need! 🥳 I only tested it briefly, thanks for the great instructions. But so far it's quite nice. |
|
Thanks for pushing for this. It really has been on the backburner for quite some time so good to get it done finally 🙏 |
|
Thank you for working on it. Wow, this was not a small change! One thing I just noticed, there does remain a Should that bin go in a temp dir somewhere? (Then again, come to think of it, MacOS may prohibit the execution of files in the temp path... I seem to recall that being so frustrating it was one of the reasons I switched to Linux on my desktop.) |
|
The folders are just the standard build/bin folders. I mean we could remove them but that's a standard place for builds to go. Or are you saying the Dev build is appearing in a different place and THAT needs removing? |
|
I think we are good with |
|
@leaanthony The dev build from I think they're supposed to be in the root of the project, right? (the build dir is at the root in the template project, at least) |
|
Thanks for explaining. Yeah, should use same build dir 👍 |
|
One thing I just thought of that I am curious your thoughts on, is that if I do change my It could be nice if Wails could infer the frontend dir from the So in summary, I don't know an easy way to infer the frontend dir, and this is not a big deal to me, and definitely not a blocker for this PR or the next release. But I wanted to document this nuance here for the record: if the Thanks again for this super handy improvement! |
|
It's a valid thought Matt. I guess I'd not expect this to change that often so I think the work involved in inferring this has little payoff. There are a few things I wish embed did better and reflection is one of them. Also default to zero values if the dir does not exist. I considered making a proposal for it: Anyway, off topic. |
|
It's pretty hard to infer that, since it is currently needed pretty early in the build process. So one would either need to do static analysis or build the binary in some special mode and execute it to get the inferred directory if the assets are an embed.FS. The problem is also how to find the root directory when inferring. IIRC the frontend dir is also not exactly the same as the assets dir since the assets dir would point to the output dir of the frontend, e.g. frontend/dist. I wonder if we could change that to some code generation method. We could add the assetdir again to wails.json which is the only source of truth for it. The build command could then create a 'assets.go' where 'main.go' is and with the correct go embed content. Would only work if the frontend dir is a child of the project dir. If it's in another dir one could add the embed there and add an import in the assts.go in the main package and referring to the assets in the other package. Just a quick thought without thinking too much about the details and consequences... |
|
@leaanthony Yep, totally understand. No problem. @stffabi Ah yeah, you're right... I forget that Anyway, carry on. 😄 |
@mholt - I am unable to reproduce this! The |
|
@leaanthony Ok, no worries then! I probably misconfigured something in my setup. I wouldn't worry about it right now or let it be a blocker. This LGTM to merge for now! |
|
No worries @mholt. Just let me know if you can reproduce with a clean project and we'll fix it! |
|
Just wanted to add a useless comment sharing how exciting this is, I can't wait to finally refactor my app to include all sub modules alongside the wails code ! |
stffabi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
|
Just leaving this note here for others that might have the same issue. The // THE FOLLOWING WON'T WORK
//go:embed all:../frontend/dist
var assets embed.FS |
This PR aims to make a Wails project more configurable as requested in #1877.
Changes:
frontend:direntry inwails.json. This can be an absolute path or a relative path from thewails.jsonfile. The last segment of this path is considered the name of the frontend directory. Not specifying this will result in the surrent default behaviour.go.modis not found in the same directory aswails.json, the cli will look up the parent directories to find it.Note: The CLI commands
buildanddevmust still be run in the same directory aswails.json.Example project in
v2/examples/customlayout