Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject configured dependencies into legacy factory function #270

Open
unscriptable opened this issue Jun 16, 2014 · 2 comments
Open

Inject configured dependencies into legacy factory function #270

unscriptable opened this issue Jun 16, 2014 · 2 comments

Comments

@unscriptable
Copy link
Member

At the moment, the factory function only receives the module/script name. If we inject the dependencies, as well, devs can solve more compatibility problems. For instance, some libraries don't export a global var when they detect and AMD define(). This prevents a legacy script from importing the library. Case in point: jquery.flot.time.js uses timezoneJS.

If flot.js's legacy config looked like the following, we could make this work:

"flot": {
    "requires": [ "timezoneJS" ],
    "factory": function factory (id, deps) {
        window.timezoneJS = deps[0];
        return window.$.plot;
    } 
}

Feels kinda hackish. :(

@unscriptable unscriptable changed the title Inject legacy deps into legacy factory function Inject configured dependencies into legacy factory function Jun 16, 2014
@ewjoachim
Copy link

As a complement, this it the declaration of the corresponding lib (and its definition as AMD module), timezoneJS, where we can see timezoneJS not being attached to root when AMD is detected. (Much kudos to @unscriptable for helping me figuring out what happened)

@unscriptable
Copy link
Member Author

I added a fix and some tests. I'm seeing intermittent failures on some unrelated tests in that test harness. Strange.

kshutkin pushed a commit to kshutkin/curl that referenced this issue May 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants