As of now, I am in the process of constructing the Ember.SimpleAuth library - a tool designed for facilitating authentication and authorization within Ember.js applications (https://github.com/simplabs/ember-simple-auth/tree/sub-packages). This library provides features for verifying the user of an Ember.js application. The authentication process can be carried out using various strategies such as logging in with credentials or through platforms like Facebook. My current goal is to break down the library structure so that users are required to incorporate the base library along with specific strategy libraries into their apps. For example:
<script src="../tmp/ember-simple-auth.js"></script>
<script src="../tmp/ember-simple-auth-oauth.js"></script>
To create this library, I am utilizing an ES6 module transpiler that converts my source code into AMD format. Subsequently, a loader is used to generate versions compatible with web browsers: https://github.com/simplabs/ember-simple-auth/blob/sub-packages/vendor/loader.js.
An issue arises when the strategy libraries rely on components from the base library. Since both files have separate module loaders with distinct module registries, one file cannot access the modules defined in the other. Currently, I am establishing a globally accessible module registry within the loader:
global.__ember_simple_auth_registry__ = global.__ember_simple_auth_registry__ || {};
var registry = global.__ember_simple_auth_registry__, seen = {};
This method ensures that all modules defined by Ember.SimpleAuth are universally available. Nevertheless, this approach may not be ideal. Is there a more effective solution to this challenge? Or could it be that there is a fundamental flaw in my overall implementation?