Read the statement by Michael Teeuw here.
Divide Config.js into modules
-
I always want Conditional Loading or Lazy Loading. I want programmable Pre-processor for which module should be loaded or not by just mention it.
And if configuration for each module be separated, PPL would make less mistakes on configuration step and at least, It could be easier to find which configuration wrong. -
I can only agree 1 config file per module in the config folder and you can get rid of a lot of mistake
-
@sean thats all cool, but will take significant rewrite of the core services…
-
@sdetweil said in Divide Config.js into modules:
@artieikon require is not allowed in module.js, but you could use the getScripts function to load them
Also
Start mm in developers mode
npm start dev
Then select the console tab to see what’s going on in the modules
Node_helpers display info in the terminal windowYou are amazing! thank you so much for this
-
@Sean
Lazy loading is always a quality thing to have. Anything that takes away from startup times and pre-processing generally helps user experience greatly.I think it’s been overlooked because of the “hide modules using an orchestrater” so its not like functionality is being lost. But the benefit of it would still be there
-
@artieikon also, please create a config file is because of a syntax error in the config file…
from the MM folder do
npm config:check
fix errors from the top down
-
@artieikon yeh, but generally people startup once and it runs for months…
-
npm run config:check
but that actually came back valid since there are no syntax errors it just blew up on me runtime. The dev mode properly shows what is the issue though
-
I do two things myself to make it sane.
1st, I use geany to edit. It’s a dream to work with, and keeps all my { with my } …
2nd, I’ve reorganized my config file as follows (Config options and modules removed to protect secure data).
/* Magic Mirror * Live Config * By Brendan Keyport */ var config = { modules: [ // top_bar // top_left // top_center // top_right // upper_third // middle_center // lower_third // bottom_left // bottom_center // bottom_right // bottom_bar // fullscreen_above // fullscreen_below // Hidden & Background // End modules before this line, do not edit below ] }; if (typeof module !== "undefined") {module.exports = config;}
-
Stumbling though the process to get this working the way i want. Just felt like i should share.
From what i surmise config.js is used both client side and server side. This is why “require” doesnt work and the browser complains. That is a server side construct and cannot be used client side.
Cool whatever, we have other ways to do things. Next i started trying to use XMLHttpRequest.
This blew up on me because electron does not support hitting the filesystem from the browser unless you set webSecurity to false. Cool this seems doable as we can pass in that value in the electronOptions in the config.jsHere’s where the fun happens. This doesnt work because that is done server side and it also uses the same config.js. Server side it cant resolve XMLHttpRequest because you need a “requires” statement to get it but then that blows up client side.
I can hack it in by specifying the webSecurity setting in the js/electron.js file as a default but that seems far too darn hacky. Im still stuck with the client showing the modules properly but the server not loading them… next try will be to run server only and client only with slightly different configs :vomit: