Skip to content

Initialization order bug when using AMD loaders in browser #321

@emil-mi

Description

@emil-mi

Hi,

The rangy-highlighter AMD module is defined with a dependency on rangy-core as far as RequireJS is concerned, but with an additional dependency on rangy-classapplier in the rangy.createModule call.
It is possible that the rangy-classapplier loading is delayed and the whole thing crashes in

                if (!requiredModule || !(requiredModule instanceof Module)) {
                    throw new Error("required module '" + moduleName + "' not found");
                }

The fastest way to fix this would be to remove the ClassApplier dependency since it is not used anyway in the initialization code. Like:

rangy.createModule("Highlighter", [""], function(api, module) {

The alternative would be to fix the code in build.js to define the module with the required dependencies which is not trivial (due to naming issues, and choice of automation), or to ditch rangy.createModule in favor of proper AMD/CommonJS code.

I can prepare a PR that implements "the fast way"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions