Skip to content

Fix registration or JS singletons across modules #1605

Open
@sabina-talipova

Description

@sabina-talipova

Description

We're assigning an instances to the ss namespace because singletons only the context on a single Browserify bundle. For example - the lib bundle exposes a singleton called router. If the framework imports router, as an external dependency, then all modules in framework will get the same copy of register when importing it.
Likewise if the custom bundle imports router as an external dependency, all modules in custom will get the same copy of router. This works as expected within the context of one bundle, all modules in that bundle importing router get the exact same copy, a singleton. However this is not true across bundles. While all modules in framework get a single copy of router and all modules in custom get a single copy of router, the copy of router in framework is not the same copy of router available in custom.
See SystemJS as a solution https://github.com/systemjs/systemjs

See:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions