Skip to content

Breaks in Electron due to module definition #6

@salmonax

Description

@salmonax

The module definition looks like this:

    if (typeof define === 'function' && define.amd) {
        define([ 'module', 'angular' ], function (module, angular) {
            module.exports = factory(angular);
        });
    } else if (typeof module === 'object') {
        module.exports = factory(require('angular'));
    } else {
        if (!root.mp) {
            root.mp = {};
        }

        root.mp.deepBlur = factory(root.angular);
    }

Electron, but not Chrome, satisfies the "typeof module === 'object'" condition, but cannot then find the angular module.

Here is an example of a module definition that does not break Electron, from angular-cache, which uses webpackUniversalModuleDefinition():

    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = factory(require("angular"));
    else if(typeof define === 'function' && define.amd)
        define("angular-cache", ["angular"], factory);
    else if(typeof exports === 'object')
        exports["angularCacheModuleName"] = factory(require("angular"));
    else
        root["angularCacheModuleName"] = factory(root["angular"]);
    }

In the second case, Electron drops down to the last "else" block; forcing deep-blur to do the same fixes the error. Further than that, I can't really say. But I am having to patch around this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions