angular-light icon indicating copy to clipboard operation
angular-light copied to clipboard

Electron error

Open rumkin opened this issue 9 years ago • 11 comments

Electron node.js application has both module.exports and window variables and thus alight get into module.exports instead of window variable.

rumkin avatar May 30 '16 17:05 rumkin

it's ok, when amd/commonjs is available, then alight works via "require" instead of put it to window

lega911 avatar May 30 '16 18:05 lega911

But it's not ok in electron browser.

rumkin avatar May 30 '16 18:05 rumkin

why? you can do: window.alight = require('alight')

lega911 avatar May 30 '16 18:05 lega911

Because I'm using it as a client library for ui and load it from bower component directory with <script>.

rumkin avatar May 30 '16 18:05 rumkin

some developers use requirejs for client libraries, and window shouldn't be spoiled. method "require" is available for you? is ok if you will use function "alightInitCallback" to receive alight?

lega911 avatar May 30 '16 18:05 lega911

I've tried alightInitCallback but with no success. Now I'm using require method. But I think It should be solved somehow or clarified in the doc.

rumkin avatar May 31 '16 11:05 rumkin

I've tried alightInitCallback but with no success.

I increased priority for "alightInitCallback", now it will test before define/require.

But I think It should be solved

I will add it to FAQ, if you have idea how to fix it, tell me (problem: if requirejs is used, then global alight shouldn't be created) as version, if "window.alightInitCallback === true", then alight works as default

lega911 avatar May 31 '16 18:05 lega911

I think it should be detected define function from requirejs.

rumkin avatar Jun 01 '16 13:06 rumkin

it checks if define is exist: https://github.com/lega911/angular-light/blob/master/src/js/postfix.js#L10

lega911 avatar Jun 01 '16 13:06 lega911

So we have wrong behaviour in atom when module.exports is presented. It could be solved with comparing global or window with this.

Code duplication found https://github.com/lega911/angular-light/blob/master/src/js/postfix.js#L16

rumkin avatar Jun 01 '16 13:06 rumkin

what do you propose? if(this != window) window.alight = alight; or if(typeof(global) !== 'undefined') window.alight = ...

Code duplication found

yes, thank you, I had fixed it

lega911 avatar Jun 03 '16 19:06 lega911