kfranqueiro/electron-dojo-boilerplate

Require still points to dojoRequire

Closed this issue · 4 comments

From the src folder tying to run a simple electron app.
My index.html loads dojo something like

< script>
var dojoConfig = {
async: true,
deps: [ 'app/main' ],
has: {
'host-node': false
}
};
window.electronRequire = require;
delete window.require;
</script>
and
< script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" ></script>

on running the electron app, app loads dojo sucessfully but tries to load main.js from https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/app/main.js
and hence fails.

Is there anything else as well to be fixed to load dojo.

See the CDN tutorial for how to properly configure the loader to load custom modules alongside CDN Dojo.

I'd point out, though, that this boilerplate is set up out-of-the-box to run dojo locally as part of the application itself, and loading dojo from CDN would seemingly defeat part of the purpose of building a desktop application (at the very least it'd make initial startup take longer and make the application impossible to use offline).

Understood. Now i am using local dojo and it works
One thing though , my dojo app uses require at certain places, (more than a few, to load widget by namespace and its spread over my build scripts too) , so moving to a different variable requires me to customly change all the current structure.
Is there a way , in which i can do it reverse. I assign electron's require to some other variable and use that require to load all the electron modules ?

@kfranqueiro any solution for this, I am still stuck a situation where i need both dojo-require and electron-require.

Sorry for losing track of this. The most I can say is try removing the last inline script block in index.html to leave dojo's require as require - I haven't written apps that way myself, but I suspect it may work (IIRC all node modules get a locally-scoped require anyway?).

On the other hand, there generally shouldn't be a need to ever rely on AMD's global require in a well-structured app (the only global you should need is define; you can always explicitly request a local require within modules).