Skip to content

Version 1.0.0+: Dependencies injected in lazy-loaded modules break page #198

@pixelbucket-dev

Description

@pixelbucket-dev

This functionality worked before with v0.5.0. Unfortunately with the new versions it breaks.

In our project we are using packs that are loaded through a configuration json. This json defines the main plugins that are required for the pack. It works like a single application, which can be completely different with another configuration, hence other loaded plugins.

Those plugins have to be loaded by ocLazyLoad, which happens in ui-router like this:

$ocLazyLoad.load(pluginsToLoad, {
    serie: true
})...

In some of the plug-ins we added dependencies like this:

angular.module('angularProject.module1', [{
    name: 'plugin1',
    files: [
        'plugin1.module.js',
        'plugin1.model.js',
        'plugin1.controller.js',
        'plugin1.directive.js',
    ],
    serie: true
}]);

Those modules may have dependencies set themselves. This creates a dependency chain.
However, now with ocLazyLoad 1.0.0+ this mechanism doesn't work anymore, despite mentioned in the readme.
There are a lot of errors which change randomly every page load, e.g.:

[$injector:nomod] Module '[...]' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

or

Error: no file to load has been found, if you're trying to load an existing module you should use the 'inject' method instead of 'load'.

To resolve this problem we have remove those dependency references from the modules and prepare the dependencies manually for each pack (in the pack's configuration json) in the right order for ozLazLoad to register them. This is obviously cumbersome and wastes a lot of time. I have no idea why the mechanism suddenly breaks.

Are we using ocLL wrong with chained dependencies?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions