Skip to content
New issue

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

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

Already on GitHub? # to your account

Non-AMD Dependency Support #30

Closed
cschram opened this issue May 10, 2013 · 5 comments
Closed

Non-AMD Dependency Support #30

cschram opened this issue May 10, 2013 · 5 comments
Assignees
Labels
bug Something that's not working as intended
Milestone

Comments

@cschram
Copy link

cschram commented May 10, 2013

There doesn't appear to be any way to handle non-AMD dependencies (i.e. jQuery plugins) in Intern, since the AMD shim configuration isn't supported by the Dojo loader (https://github.com/csnover/dojo2-core/issues/9).

I'm winding up with jQuery plugins that are not loaded correctly because they're loaded before jQuery.

@csnover
Copy link
Member

csnover commented May 10, 2013

These should be loading in parallel but executing in order (without shim). We’ll look into it and fix it if it’s not working correctly.

@ghost ghost assigned bitpshr May 10, 2013
@csnover
Copy link
Member

csnover commented May 11, 2013

I’ve confirmed that the loader is not working in the way it should be working for non-AMD modules. This will be resolved for 1.1.

@csnover
Copy link
Member

csnover commented May 20, 2013

@abjorn This has been implemented using an AMD loader plugin (intern/order), rather than shim, because:

  1. I do not want to pollute the loader with features that allow people to shoot themselves in the foot by paving over the fact that they are not using any real dependency management in their code;
  2. While I can make changes to the dojo2-core loader today, I can’t make the same changes to the Dojo 1 loader, so there would be a functional incongruity between the two branches for several months.

This feature will be available in 1.1, or if you are tracking master you can use it today. define(['intern/order!my/parentJavascript.js', 'intern/order!my/childJavascript.js' ], …)

Thanks for the report!

@cschram
Copy link
Author

cschram commented May 23, 2013

In my use case, the use of shim is in the interest of using third party libraries, rather than a lack of dependency management in the codebase itself. The problem arises where the project is using Require.js and jQuery, and Intern uses Dojo and it's AMD loader.

My codebase uses shim for third-party modules, so that I have them included in the arguments for a modules factory function. This becomes a problem when trying to use the Dojo loader without shim support - I could still access these libraries from window but because they're included in a factory function's arguments it gets overridden as undefined. I could use a work around, like checking for undefined dependencies and grabbing them from window, but ideally the test suite I'm using shouldn't force me to change my code for the testing environment.

I can change my code to work this way today, but I think in the future it should be supported by Intern via plugin (like the now defunct use plugin for Require.js) for compatibility-sake, unless you're only interested in officially supporting Dojo-based projects.

@csnover
Copy link
Member

csnover commented May 23, 2013

Hi Abjorn,

Those third party libraries are the code that I was referring to in point 1.

This is not a Dojo issue or a Dojo loader issue. Dojo 1, Dojo 2, curl.js, bdLoad, lsjs, almond.js, inject, pinf, NeedsJS, and brequire all do not implement shim. RequireJS is the only client-side AMD loader that I know of that implements this functionality. I am absolutely interested in supporting testing of as much code as possible, but I want to do so in a way that is also as responsible as possible.

If you really need shim for your own project, Intern does not use any Dojo-loader-specific functionality, so you can modify your client.html to use require.js instead and it should work just fine. I would strongly suggest that you contact plugin authors and request that they add proper AMD support to their libraries so you do not need any extra configuration to use them.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

3 participants