-
Notifications
You must be signed in to change notification settings - Fork 97
How do you properly pre-compile for release? #61
Comments
Basically, if you run electron-compile, it's going to create a folder in your source called |
That's what I figured, I just wasn't sure if the documentation was out of date or not. Where is the Thanks for the help, btw. This whole project is great. |
set |
So right now, you still need to include your original files along with the app and the |
So, in production mode, all of the files are precompiled, and electron-compile just intercepts the request for the file. Annoyingly though, because node.js's module system will attempt to stat the original file and we can't stop them, you still have to have the original files too (though actually if you want, you can zero the contents!) |
The folders are essentially a hash of the compiler name + version, and the files are GZipped files which are your app's contents (you can see them by |
I think in general, this thread is indicating that my user documentation sucks when it comes to production mode, I'll definitely try to beef up this. In general the idea though is:
|
So does electron-compile intercept the request for every file, and then uses a cached file if it's available within a relative |
I'm to the point where I'm trying to package my app and running into issues. The compiled app isn't finding module |
I had tried that as well. I ended up moving to a Grunt workflow and moving away from this library until it's a little more mature. I couldn't waste any more time trying to get this nice-to-have library to work correctly. I'll definitely keep my eyes on any updates and pick it back up in the future. 👍 |
You got it
Not sure I follow what this means, electron-compile never creates an explicit JS file |
When I try to run my built app I just get an error that resources/app/index.js can't be found. There is no index.js file there, because I'm using index.coffee instead. I've moved the compiled .cache over but it still is looking for index.js and can't find it. |
Stupid question, you aren't trying to require 'index.js' are you? |
No, I don't think I was. I've since moved on to using other tools to compile things, so won't be able to help troubleshoot this problem more. |
I'm working on a workshop and want to use electron-compile to help others get started with electron, but I'm running into an issue getting this to work. I have a very simple test app:
Here are the exact steps I've run through, based on what I read earlier in this thread:
When I run the app, I get the following error:
So, it doesn't look like it's picking up on the compiled cache. Am I doing something wrong? |
@reverentgeek Hm, what happens if you run |
@reverentgeek Ok, I think I know the problem. If you package the app via electron-packager, you basically don't have the trampoline that Basically, what it comes down to is I didn't think through how electron-prebuilt-compile would work with packaging :( Lemme work on this tonight, I want to get a solution that's as easy to work with as electron-prebuilt-compile is. Thanks for your patience and for reporting this great detailed info |
Ok, awesome. I love what I see with BTW, this exercise is specifically for a workshop I'm doing at JSConf UY next month, but have several talks on electron I'll be giving throughout this year. |
Alright, I didn't quite finish, but #79 sketches out the plan - basically there will soon be a |
Ok! This is now much better, here's how it works:
|
I've tried lots of variations, but yet to get this to work for me. My current attempt is to have a 2-package.json project structure that looks like the following screen shot: The script I have in my root package.json looks like:
After the compile finishes, and I try to launch my application, I get an error "Asked for [path]/main.js but it was not precompiled!" Oh, and half the time when I run the packager, I get the following error. Running it again seems to work.
|
@reverentgeek Can you share this project? |
@paulcbetts Here is my electron-starter-kit, to someday be a foundation for Electron apps at my company. |
Hah! You found an interesting bug - if you call your source folder |
Thanks for your help! Do I need to file an issue for the .svg rendering bug? If so, where? |
Here is fine |
Hey, so I believe I got the pre-compile working! The app works and as @paulcbetts mentioned I tried zeroing out the contents of My concern now is, I obviously don't want to manually zero every Also, is this a common enough need to add an option for it to |
@Haumed You could add it as an option to packager-cli, you'd probably do the zeroing here: https://github.com/electron/electron-compile/blob/master/src/packager-cli.js#L140 |
Ok cool. I'm actually still using regular electron-packager, but if I do get the code figured out I'll make sure to come back and add it. |
As @paulcbetts commented on #61 (comment),
electron-compile will check if the requested file is present in the .cache or not. What if that file is not present in the .cache? Will it serve the original file? I m getting similar issue. I've below project structure. And
And, I m pre-compiling using below command:
I m getting below error when I launch my app (Windows 8.1 64bit) I think I knew why is the error coming as I m pre-compiling So, when file is not present in .cache dir, won't the original file served? Can we've ignore option? Or can we already do that? Thanks. |
@manikantag See https://github.com/electron/electron-compile/blob/master/src/packager-cli.js#L73 Move your |
@MarshallOfSound I m not using electron-packager-compile as I m using electron-builder, and both are not compatible (#99), yet! I've moved the I've tried with below command, but still is pre-compiling
How to do the same with just |
And if I don't compile everything and instead only js files, then what will happen? In other words, what if a file is not present in .cache dir? Will it serve the original file? When I m compiling all the files, CSS files are not coming with proper MIME. Strange thing is few CSS files are coming fine. Ex: bootswatch-paper.min.css.
When I inspect the contents in devtools, it is showing blank. But when I unpack using |
I've verified that the contents in .cache are also present. I've got the file name from compiler-info.json in .cache dir. What could be the issue? |
@MarshallOfSound any inputs here? Thanks. |
Any help is much appreciated? I doubt this is a bug. |
@manikantag I don't have time to look into this atm but a quick fix would be to either use or steal the code from |
Similar issue is seen with I feel this is an issue with electron-compile itself. |
@manikantag I think you're right - I think we're somehow not getting |
@paulcbetts
So just to be clear, at the moment there doesn't seem to be a way to remove the original source files (although they can be zeroed) in a production app? |
@callodacity Correct - because the node module system will realpath these files before electron-compile has a chance to do anything with them. You could probably hack |
The current documentation is confusing,
What is
--appDir
? Is that where the compiled files will go? It seems like that flag does nothing.Does pre-compiling require you to have your
main.js
andpackage.json
inside of the./src
directory? I don't get how this while pre-compile thing is supposed to work. As it is now, I get this error when I boot the app withelectron .
after pre-compiling withelectron-compile --appDir . ./src ./resources
:If I remove the
.cache
directory, then the app runs correctly again. What's the correct way to package an app for release with this library?This is my current folder structure,
The text was updated successfully, but these errors were encountered: